From gitlab at gitlab.haskell.org Wed Nov 1 00:04:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 31 Oct 2023 20:04:00 -0400 Subject: [Git][ghc/ghc][master] docs: fix ScopedTypeVariables example (#24101) Message-ID: <654195f051130_1baa2843041e68411564@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 1 changed file: - docs/users_guide/exts/scoped_type_variables.rst Changes: ===================================== docs/users_guide/exts/scoped_type_variables.rst ===================================== @@ -293,11 +293,11 @@ signatures/ of the methods. For example, the following will be accepted without explicitly enabling :extension:`ScopedTypeVariables`: :: class D a where - m :: [a] -> a + m :: a -> a - instance D [a] where + instance Num a => D [a] where m :: [a] -> [a] - m = reverse + m x = map (*2) x Note that writing ``m :: [a] -> [a]`` requires the use of the :extension:`InstanceSigs` extension. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a90020f167ab016cbfa95decafaa1a54a974bc6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a90020f167ab016cbfa95decafaa1a54a974bc6 You're receiving 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 Nov 1 00:04:38 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 31 Oct 2023 20:04:38 -0400 Subject: [Git][ghc/ghc][master] Fix pretty-printing of type family dependencies Message-ID: <6541961626b82_1baa28430387284148e4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 5 changed files: - compiler/GHC/Iface/Syntax.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -1067,8 +1067,9 @@ pprIfaceDecl ss (IfaceFamily { ifName = tycon = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind) , hang (text "type family" <+> pprIfaceDeclHead suppress_bndr_sig [] ss tycon binders + <+> pp_inj res_var inj <+> ppShowRhs ss (pp_where rhs)) - 2 (pp_inj res_var inj <+> ppShowRhs ss (pp_rhs rhs)) + 2 (ppShowRhs ss (pp_rhs rhs)) $$ nest 2 (ppShowRhs ss (pp_branches rhs)) ] ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1657,7 +1657,7 @@ module Data.Type.Bool where forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls type Not :: GHC.Types.Bool -> GHC.Types.Bool - type family Not a where = res | res -> a + type family Not a = res | res -> a where Not GHC.Types.False = GHC.Types.True Not GHC.Types.True = GHC.Types.False type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1657,7 +1657,7 @@ module Data.Type.Bool where forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls type Not :: GHC.Types.Bool -> GHC.Types.Bool - type family Not a where = res | res -> a + type family Not a = res | res -> a where Not GHC.Types.False = GHC.Types.True Not GHC.Types.True = GHC.Types.False type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1657,7 +1657,7 @@ module Data.Type.Bool where forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls type Not :: GHC.Types.Bool -> GHC.Types.Bool - type family Not a where = res | res -> a + type family Not a = res | res -> a where Not GHC.Types.False = GHC.Types.True Not GHC.Types.True = GHC.Types.False type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1657,7 +1657,7 @@ module Data.Type.Bool where forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls type Not :: GHC.Types.Bool -> GHC.Types.Bool - type family Not a where = res | res -> a + type family Not a = res | res -> a where Not GHC.Types.False = GHC.Types.True Not GHC.Types.True = GHC.Types.False type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f69f50afbfd352f0e9645b4dbe87200e63b37e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f69f50afbfd352f0e9645b4dbe87200e63b37e You're receiving 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 Nov 1 00:05:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 31 Oct 2023 20:05:32 -0400 Subject: [Git][ghc/ghc][master] 2 commits: gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 Message-ID: <6541964c8208c_1baa28435a8bf4418084@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 2 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -979,7 +979,7 @@ job_groups = , -- Nightly allowed to fail: #22343 modifyNightlyJobs allowFailure (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc)) - , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian10) llvm) + , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian12) llvm) , disableValidate (standardBuilds Amd64 (Linux Debian11)) , disableValidate (standardBuilds Amd64 (Linux Debian12)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 @@ -1003,7 +1003,7 @@ job_groups = , fastCI (standardBuilds AArch64 Darwin) , fastCI (standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla)) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian11) (splitSectionsBroken vanilla)) - , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm) + , onlyRule LLVMBackend (validateBuilds AArch64 (Linux Debian12) llvm) , standardBuildsWithConfig I386 (Linux Debian10) (splitSectionsBroken vanilla) -- Fully static build, in theory usable on any linux distribution. , fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine312) (splitSectionsBroken static)) @@ -1077,12 +1077,14 @@ platform_mapping = Map.map go combined_result where whitelist = [ "x86_64-linux-alpine3_12-validate" , "x86_64-linux-deb11-validate" + , "x86_64-linux-deb12-validate" , "x86_64-linux-deb10-validate+debug_info" , "x86_64-linux-fedora33-release" , "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" , "x86_64-windows-validate" , "nightly-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static" , "nightly-x86_64-linux-deb11-validate" + , "nightly-x86_64-linux-deb12-validate" , "x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static" , "nightly-aarch64-linux-deb10-validate" , "nightly-x86_64-linux-alpine3_12-validate" @@ -1092,6 +1094,7 @@ platform_mapping = Map.map go combined_result , "release-x86_64-linux-alpine3_12-release+no_split_sections" , "release-x86_64-linux-deb10-release" , "release-x86_64-linux-deb11-release" + , "release-x86_64-linux-deb12-release" , "release-x86_64-linux-fedora33-release" , "release-x86_64-windows-release" ] ===================================== .gitlab/jobs.yaml ===================================== @@ -126,6 +126,67 @@ "TEST_ENV": "aarch64-linux-deb10-validate" } }, + "aarch64-linux-deb12-validate+llvm": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh save_test_output", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "2 weeks", + "paths": [ + "ghc-aarch64-linux-deb12-validate+llvm.tar.xz", + "junit.xml", + "unexpected-test-output.tar.gz" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "aarch64-linux-deb12-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV", + "needs": [ + { + "artifacts": false, + "job": "hadrian-ghc-in-ghci" + } + ], + "rules": [ + { + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "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": [ + "aarch64-linux" + ], + "variables": { + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "", + "TEST_ENV": "aarch64-linux-deb12-validate+llvm" + } + }, "i386-linux-deb10-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -380,7 +441,7 @@ "XZ_OPT": "-9" } }, - "nightly-aarch64-linux-deb10-validate+llvm": { + "nightly-aarch64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -391,7 +452,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-aarch64-linux-deb10-validate+llvm.tar.xz", + "ghc-aarch64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -401,14 +462,14 @@ "when": "always" }, "cache": { - "key": "aarch64-linux-deb10-$CACHE_REV", + "key": "aarch64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -434,15 +495,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "aarch64-linux-deb10-validate+llvm", + "TEST_ENV": "aarch64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-aarch64-linux-deb11-validate": { + "nightly-aarch64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -453,7 +514,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-aarch64-linux-deb11-validate.tar.xz", + "ghc-aarch64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -463,14 +524,14 @@ "when": "always" }, "cache": { - "key": "aarch64-linux-deb11-$CACHE_REV", + "key": "aarch64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -496,11 +557,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "aarch64-linux-deb11-validate", + "TEST_ENV": "aarch64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, @@ -1523,18 +1584,18 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+llvm": { + "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": false, + "allow_failure": true, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1577,26 +1638,28 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", + "BUILD_FLAVOUR": "validate+thread_sanitizer", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+llvm", + "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-validate+thread_sanitizer": { + "nightly-x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1639,17 +1702,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions", + "TEST_ENV": "x86_64-linux-deb10-zstd-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb10-zstd-validate": { + "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1660,7 +1721,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1670,14 +1731,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1703,15 +1764,17 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate", + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1722,7 +1785,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1764,18 +1827,19 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1786,7 +1850,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1828,19 +1892,16 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", + "TEST_ENV": "x86_64-linux-deb11-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate": { + "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1851,7 +1912,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1894,15 +1955,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-validate", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "nightly-x86_64-linux-deb12-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1913,7 +1974,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -1923,14 +1984,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -1956,15 +2017,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc", + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate", "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb12-validate": { + "nightly-x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -1975,7 +2036,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb12-validate.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -2018,11 +2079,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate", - "BUILD_FLAVOUR": "validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb12-validate", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm", "XZ_OPT": "-9" } }, @@ -4969,7 +5030,7 @@ "TEST_ENV": "x86_64-linux-deb10-validate+debug_info" } }, - "x86_64-linux-deb10-validate+llvm": { + "x86_64-linux-deb10-validate+thread_sanitizer": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -4980,7 +5041,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+llvm.tar.xz", + "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5006,8 +5067,9 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "on_success" + "allow_failure": true, + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "manual" } ], "script": [ @@ -5023,14 +5085,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm", - "BUILD_FLAVOUR": "validate+llvm", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", + "BUILD_FLAVOUR": "validate+thread_sanitizer", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+llvm" + "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", + "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" } }, - "x86_64-linux-deb10-validate+thread_sanitizer": { + "x86_64-linux-deb10-zstd-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5041,7 +5105,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz", + "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5067,9 +5131,8 @@ ], "rules": [ { - "allow_failure": true, - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", - "when": "manual" + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "when": "on_success" } ], "script": [ @@ -5085,16 +5148,14 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer", - "BUILD_FLAVOUR": "validate+thread_sanitizer", - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "HADRIAN_ARGS": "--docs=none", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer", - "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + "TEST_ENV": "x86_64-linux-deb10-zstd-validate" } }, - "x86_64-linux-deb10-zstd-validate": { + "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5105,7 +5166,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb10-zstd-validate.tar.xz", + "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5115,14 +5176,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb10-$CACHE_REV", + "key": "x86_64-linux-deb11-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5131,7 +5192,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5148,14 +5209,16 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check", + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", + "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb10-zstd-validate" + "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5166,7 +5229,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5192,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5208,17 +5271,18 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", + "BIGNUM_BACKEND": "native", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", - "CROSS_TARGET": "aarch64-linux-gnu", + "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "js-emulator", + "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, - "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { + "x86_64-linux-deb11-validate+boot_nonmoving_gc": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5229,7 +5293,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5255,7 +5319,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5271,18 +5335,15 @@ "x86_64-linux" ], "variables": { - "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", - "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "javascript-unknown-ghcjs", - "RUNTEST_ARGS": "", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", + "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", + "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", + "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" } }, - "x86_64-linux-deb11-validate+boot_nonmoving_gc": { + "x86_64-linux-deb12-validate+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh save_test_output", @@ -5293,7 +5354,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz", + "ghc-x86_64-linux-deb12-validate+llvm.tar.xz", "junit.xml", "unexpected-test-output.tar.gz" ], @@ -5303,14 +5364,14 @@ "when": "always" }, "cache": { - "key": "x86_64-linux-deb11-$CACHE_REV", + "key": "x86_64-linux-deb12-$CACHE_REV", "paths": [ "cabal-cache", "toolchain" ] }, "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV", + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV", "needs": [ { "artifacts": false, @@ -5319,7 +5380,7 @@ ], "rules": [ { - "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], @@ -5336,11 +5397,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc", - "BUILD_FLAVOUR": "validate+boot_nonmoving_gc", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm", + "BUILD_FLAVOUR": "validate+llvm", "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check", - "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity", - "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc" + "RUNTEST_ARGS": "", + "TEST_ENV": "x86_64-linux-deb12-validate+llvm" } }, "x86_64-linux-fedora33-release": { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49f69f50afbfd352f0e9645b4dbe87200e63b37e...5b0392e062b1e73adccdb99f9057d15375ed793a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49f69f50afbfd352f0e9645b4dbe87200e63b37e...5b0392e062b1e73adccdb99f9057d15375ed793a You're receiving 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 Nov 1 08:33:17 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 01 Nov 2023 04:33:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24119 Message-ID: <65420d4d21e84_1baa284fcf0b084407b7@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24119 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24119 You're receiving 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 Nov 1 08:33:56 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 01 Nov 2023 04:33:56 -0400 Subject: [Git][ghc/ghc][wip/romes/24119] Fix in docs regarding SSymbol, SNat, SChar (#24119) Message-ID: <65420d7431455_1baa284fcf71384409fb@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24119 at Glasgow Haskell Compiler / GHC Commits: 7cdabe1d by Rodrigo Mesquita at 2023-11-01T08:33:45+00:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 2 changed files: - libraries/base/src/GHC/TypeLits.hs - libraries/base/src/GHC/TypeNats.hs Changes: ===================================== libraries/base/src/GHC/TypeLits.hs ===================================== @@ -358,7 +358,7 @@ type role SSymbol nominal -- -- @ -- f :: 'SSymbol' s -> .. --- f SSymbol = {- SSymbol s in scope -} +-- f SSymbol = {- KnownSymbol s in scope -} -- @ -- -- @since 4.18.0.0 @@ -461,7 +461,7 @@ type role SChar nominal -- -- @ -- f :: 'SChar' c -> .. --- f SChar = {- SChar c in scope -} +-- f SChar = {- KnownChar c in scope -} -- @ -- -- @since 4.18.0.0 ===================================== libraries/base/src/GHC/TypeNats.hs ===================================== @@ -362,7 +362,7 @@ type role SNat nominal -- -- @ -- f :: 'SNat' n -> .. --- f SNat = {- SNat n in scope -} +-- f SNat = {- KnownNat n in scope -} -- @ -- -- @since 4.18.0.0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7cdabe1d4d142ca92d6f2f30c5b3eea6c89a61ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7cdabe1d4d142ca92d6f2f30c5b3eea6c89a61ad You're receiving 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 Nov 1 09:03:38 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 05:03:38 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Build genapply per stage Message-ID: <6542146a85fb8_1baa285063252c451124@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: e111b004 by GHC GitLab CI at 2023-11-01T09:03:30+00:00 Build genapply per stage - - - - - 3 changed files: - hadrian/src/Builder.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Default.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -166,7 +166,7 @@ data Builder = Alex | Cc CcMode Stage | Configure FilePath | DeriveConstants - | GenApply + | GenApply Stage | GenPrimopCode | Ghc GhcMode Stage | GhcPkg GhcPkgMode Stage @@ -205,7 +205,7 @@ instance NFData Builder builderProvenance :: Builder -> Maybe Context builderProvenance = \case DeriveConstants -> context stage0Boot deriveConstants - GenApply -> context stage0Boot genapply + GenApply stage -> context (predStage stage) genapply GenPrimopCode -> context stage0Boot genprimopcode Ghc _ (Stage0 {})-> Nothing Ghc _ stage -> context (predStage stage) ghc @@ -330,7 +330,7 @@ instance H.Builder Builder where let env = AddEnv "CONFIG_SHELL" bash cmd' env [Cwd dir] ["sh", path] buildOptions buildArgs - GenApply -> captureStdout + GenApply {} -> captureStdout GenPrimopCode -> do stdin <- readFile' input ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -154,7 +154,7 @@ generatePackageCode context@(Context stage pkg _ _) = do when (pkg == rts) $ do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> - build $ target context GenApply [] [file] + build $ target context (GenApply stage) [] [file] root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ -> ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -70,7 +70,6 @@ stageBootPackages = return , hsc2hs , compareSizes , deriveConstants - , genapply , genprimopcode , unlit ] @@ -111,6 +110,7 @@ stage0Packages = do , transformers , unlit , hp2ps + , genapply , if windowsHost then win32 else unix ] ++ [ terminfo | not windowsHost, not cross ] @@ -160,6 +160,7 @@ stage1Packages = do , xhtml , haddock , hpcBin + , genapply , if winTarget then win32 else unix ] ++ [ iserv View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e111b004fb6df146271a3e5d1e9b44324b198340 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e111b004fb6df146271a3e5d1e9b44324b198340 You're receiving 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 Nov 1 10:01:55 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 06:01:55 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Build genapply per stage Message-ID: <65422213afcb4_1baa2851e0b4b4462247@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: d53f92c0 by GHC GitLab CI at 2023-11-01T10:01:48+00:00 Build genapply per stage - - - - - 4 changed files: - hadrian/src/Builder.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Default.hs - utils/genapply/Main.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -166,7 +166,7 @@ data Builder = Alex | Cc CcMode Stage | Configure FilePath | DeriveConstants - | GenApply + | GenApply Stage | GenPrimopCode | Ghc GhcMode Stage | GhcPkg GhcPkgMode Stage @@ -205,7 +205,7 @@ instance NFData Builder builderProvenance :: Builder -> Maybe Context builderProvenance = \case DeriveConstants -> context stage0Boot deriveConstants - GenApply -> context stage0Boot genapply + GenApply stage -> context (predStage stage) genapply GenPrimopCode -> context stage0Boot genprimopcode Ghc _ (Stage0 {})-> Nothing Ghc _ stage -> context (predStage stage) ghc @@ -330,7 +330,7 @@ instance H.Builder Builder where let env = AddEnv "CONFIG_SHELL" bash cmd' env [Cwd dir] ["sh", path] buildOptions buildArgs - GenApply -> captureStdout + GenApply {} -> captureStdout GenPrimopCode -> do stdin <- readFile' input ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -154,7 +154,7 @@ generatePackageCode context@(Context stage pkg _ _) = do when (pkg == rts) $ do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> - build $ target context GenApply [] [file] + build $ target context (GenApply stage) [] [file] root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ -> ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -70,7 +70,6 @@ stageBootPackages = return , hsc2hs , compareSizes , deriveConstants - , genapply , genprimopcode , unlit ] @@ -111,6 +110,7 @@ stage0Packages = do , transformers , unlit , hp2ps + , genapply , if windowsHost then win32 else unix ] ++ [ terminfo | not windowsHost, not cross ] @@ -160,6 +160,7 @@ stage1Packages = do , xhtml , haddock , hpcBin + , genapply , if winTarget then win32 else unix ] ++ [ iserv ===================================== utils/genapply/Main.hs ===================================== @@ -387,7 +387,7 @@ genMkPAP regstatus macro jump live _ticker disamb adj_reg_locs = [ (reg, off - adj + 1) | (reg,off) <- extra_reg_locs ] adj = case extra_reg_locs of - (reg, fst_off):_ -> fst_off + (_, fst_off):_ -> fst_off [] -> error "Impossible: genapply.hs : No extra register locations" size = snd (last adj_reg_locs) + 1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d53f92c0b2983e83ed477fccf0affef1cb3ef8b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d53f92c0b2983e83ed477fccf0affef1cb3ef8b6 You're receiving 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 Nov 1 10:09:11 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 06:09:11 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: docs: fix ScopedTypeVariables example (#24101) Message-ID: <654223c7e2528_1baa28520b1b784630a0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - ce2be6cd by Ryan Scott at 2023-11-01T06:08:56-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 748c90e2 by Sylvain Henry at 2023-11-01T06:09:07-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Syntax.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/Errors/Types/PromotionErr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/scoped_type_variables.rst - docs/users_guide/using-warnings.rst - libraries/base/src/GHC/JS/Prim.hs - rts/js/mem.js - rts/js/rts.js - testsuite/tests/ffi/should_run/all.T - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/polykinds/T7433.stderr - testsuite/tests/rename/should_fail/T22478e.hs - testsuite/tests/rename/should_fail/T22478e.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2488cbf2a7db0d0554845fb96a8478376aa5fdae...748c90e29f0ca5d639ab03030ccf4e6d3a059a2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2488cbf2a7db0d0554845fb96a8478376aa5fdae...748c90e29f0ca5d639ab03030ccf4e6d3a059a2d You're receiving 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 Nov 1 11:47:31 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 07:47:31 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.8.1 Message-ID: <65423ad3c2e82_1baa28547003d847713b@gitlab.mail> Matthew Pickering pushed new branch wip/ghc-9.8.1 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.8.1 You're receiving 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 Nov 1 11:48:29 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 07:48:29 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.8.1] Compability with 9.8.1 as boot compiler Message-ID: <65423b0d5cedf_1baa28546ff39847925d@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-9.8.1 at Glasgow Haskell Compiler / GHC Commits: 8e06fba1 by Matthew Pickering at 2023-11-01T11:48:04+00:00 Compability with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6 changed files: - hadrian/src/Settings/Packages.hs - libraries/ghc-heap/GHC/Exts/Stack.hs - libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc - libraries/ghc-heap/GHC/Exts/Stack/Decode.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghci/ghci.cabal.in Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -10,6 +10,7 @@ import Settings.Builders.Common (wayCcArgs) import GHC.Toolchain.Target import GHC.Platform.ArchOS +import Data.Version.Extra -- | Package-specific command-line arguments. packageArgs :: Args @@ -33,6 +34,7 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir + stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat --------------------------------- base --------------------------------- @@ -83,7 +85,7 @@ packageArgs = do -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal - , stage0 ? arg "+hadrian-stage0" + , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" , flag StaticLibzstd `cabalFlag` "static-libzstd" ] ===================================== libraries/ghc-heap/GHC/Exts/Stack.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE RecordWildCards #-} module GHC.Exts.Stack ===================================== libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc ===================================== @@ -3,7 +3,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Exts.Stack.Constants where -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) import Prelude ===================================== libraries/ghc-heap/GHC/Exts/Stack/Decode.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances #-} ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -23,7 +23,7 @@ library default-language: Haskell2010 build-depends: base >= 4.9.0 && < 5.0 - , ghc-prim > 0.2 && < 0.11 + , ghc-prim > 0.2 && < 0.12 , rts == 1.0.* , containers >= 0.6.2.1 && < 0.7 ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -76,7 +76,7 @@ library rts, array == 0.5.*, base >= 4.8 && < 4.20, - ghc-prim >= 0.5.0 && < 0.11, + ghc-prim >= 0.5.0 && < 0.12, binary == 0.8.*, bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e06fba144f86821330d2b5fdc546b3219d927fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e06fba144f86821330d2b5fdc546b3219d927fe You're receiving 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 Nov 1 12:26:35 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 08:26:35 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/update-bootstrap-plans2 Message-ID: <654243fbb332d_1baa2855a911a4487732@gitlab.mail> Matthew Pickering pushed new branch wip/update-bootstrap-plans2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/update-bootstrap-plans2 You're receiving 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 Nov 1 13:19:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 09:19:42 -0400 Subject: [Git][ghc/ghc][master] More robust checking for DataKinds Message-ID: <6542506e76b1_1baa285714e888507153@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 30 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.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/Errors/Types/PromotionErr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/using-warnings.rst - testsuite/tests/polykinds/T7433.stderr - testsuite/tests/rename/should_fail/T22478e.hs - testsuite/tests/rename/should_fail/T22478e.stderr - + testsuite/tests/typecheck/should_compile/T22141a.hs - + testsuite/tests/typecheck/should_compile/T22141a.stderr - + testsuite/tests/typecheck/should_compile/T22141b.hs - + testsuite/tests/typecheck/should_compile/T22141b.stderr - + testsuite/tests/typecheck/should_compile/T22141c.hs - + testsuite/tests/typecheck/should_compile/T22141c.stderr - + testsuite/tests/typecheck/should_compile/T22141d.hs - + testsuite/tests/typecheck/should_compile/T22141d.stderr - + testsuite/tests/typecheck/should_compile/T22141e.hs - + testsuite/tests/typecheck/should_compile/T22141e.stderr - + testsuite/tests/typecheck/should_compile/T22141e_Aux.hs - + testsuite/tests/typecheck/should_compile/T22141f.hs - + testsuite/tests/typecheck/should_compile/T22141g.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f9c92272b3ca11d54331cea83ad5e82e17fa062 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f9c92272b3ca11d54331cea83ad5e82e17fa062 You're receiving 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 Nov 1 13:20:43 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 09:20:43 -0400 Subject: [Git][ghc/ghc][master] JS: fix FFI "wrapper" and "dynamic" Message-ID: <654250ab96e91_1baa2857189a005102d8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 5 changed files: - compiler/GHC/HsToCore/Foreign/JavaScript.hs - libraries/base/src/GHC/JS/Prim.hs - rts/js/mem.js - rts/js/rts.js - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Foreign/JavaScript.hs ===================================== @@ -157,14 +157,17 @@ mkFExportJSBits platform c_nm maybe_target arg_htys res_hty is_IO_res_ty _cconv idTag i = let (tag, u) = unpkUnique (getUnique i) in CHeader (char tag <> word64 u) + normal_args = map (\(nm,_ty,_,_) -> nm) arg_info + all_args + | isNothing maybe_target = text "stableptr_offset" : normal_args + | otherwise = normal_args + fun_args | null arg_info = empty -- text "void" - | otherwise = hsep $ punctuate comma - $ map (\(nm,_ty,_,_) -> nm) arg_info + | otherwise = hsep $ punctuate comma all_args fun_proto - = text "async" <+> - text "function" <+> + = text "function" <+> (if isNothing maybe_target then text "h$" <> ftext c_nm else ftext c_nm) <> @@ -188,7 +191,7 @@ mkFExportJSBits platform c_nm maybe_target arg_htys res_hty is_IO_res_ty _cconv -- the target which will form the root of what we ask rts_evalIO to run the_cfun = case maybe_target of - Nothing -> text "h$deRefStablePtr(the_stableptr)" + Nothing -> text "h$deRefStablePtr(stableptr_offset)" Just hs_fn -> idClosureText hs_fn -- the expression we give to rts_eval @@ -210,8 +213,7 @@ mkFExportJSBits platform c_nm maybe_target arg_htys res_hty is_IO_res_ty _cconv $$ vcat [ lbrace , text "return" - <+> text "await" - <+> text "h$rts_eval" + <+> text "h$rts_eval_sync" <> parens ((if is_IO_res_ty then expr_to_run else text "h$rts_toIO" <> parens expr_to_run) ===================================== libraries/base/src/GHC/JS/Prim.hs ===================================== @@ -85,7 +85,7 @@ toIO x = pure x resolve :: JSVal# -> JSVal# -> Exts.Any -> IO () resolve accept reject x = resolveIO accept reject (pure x) -{-# NOINLINE resolveIO #-} +{-# NOINLINE resolveIO #-} -- used by the rts resolveIO :: JSVal# -> JSVal# -> IO Exts.Any -> IO () resolveIO accept reject x = (x >>= evaluate >>= js_callback_any accept) `catch` ===================================== rts/js/mem.js ===================================== @@ -519,8 +519,14 @@ function h$initPtrLbl(isFun, lbl) { return lbl; } -function h$callDynamic(f) { - return f.apply(f, Array.prototype.slice.call(arguments, 2)); +function h$callDynamic(f_d,f_o) { + // make sure that we got a StablePtr + if (f_d !== h$stablePtrBuf) { + throw ("callDynamic: expecting a StablePtr and got: " + f_d) + } + var f = h$deRefStablePtr(f_o); + var args = Array.prototype.slice.call(arguments, 2); + return f.apply(f, args); } // slice an array of heap objects ===================================== rts/js/rts.js ===================================== @@ -16,8 +16,8 @@ function h$rts_eval_sync(closure, unbox) { var res, status = 0; try { h$runSync(MK_AP3( h$baseZCGHCziJSziPrimziresolveIO - , MK_JSVAL(x => { status = 1; res = unbox(x); }) - , MK_JSVAL(e => { status = 2; res = new h$HaskellException(e); }) + , x => { status = 1; res = unbox(x); } + , e => { status = 2; res = new h$HaskellException(e); } , closure), false); } catch(e) { status = 2; res = e; } switch(status) { @@ -27,7 +27,6 @@ function h$rts_eval_sync(closure, unbox) { } } - function h$rts_apply(f, x) { return MK_AP1(f, x); } @@ -51,7 +50,7 @@ function h$rts_apply(f, x) { function h$rts_mkChar(x) { return x|0; } function h$rts_getChar(x) { return UNWRAP_NUMBER(x); } -function h$rts_mkWord(x) { return x|0; } +function h$rts_mkWord(x) { return x>>>0; } function h$rts_getWord(x) { return UNWRAP_NUMBER(x); } function h$rts_mkInt(x) { return x|0; } @@ -60,7 +59,7 @@ function h$rts_getInt(x) { return UNWRAP_NUMBER(x); } function h$rts_mkInt32(x) { return x|0; } function h$rts_getInt32(x) { return UNWRAP_NUMBER(x); } -function h$rts_mkWord32(x) { return x|0; } +function h$rts_mkWord32(x) { return x>>>0; } function h$rts_getWord32(x) { return UNWRAP_NUMBER(x); } function h$rts_mkInt16(x) { return (x<<16)>>16; } ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -38,7 +38,7 @@ test('ffi005', [ omit_ways(prof_ways), req_c ], compile_and_run, ['ffi005_c.c']) -test('ffi006', [normal, js_broken(22363)], compile_and_run, ['']) +test('ffi006', normal, compile_and_run, ['']) # Skip ffi00{7,8} for GHCi. These tests both try to exit or raise an # error from a foreign export, which shuts down the runtime. When @@ -59,7 +59,7 @@ else: opts = '' test('ffi010', normal, compile_and_run, ['']) -test('ffi011', [normal, js_broken(22363)], compile_and_run, ['']) +test('ffi011', normal, compile_and_run, ['']) # The stdcall calling convention works on Windows, and sometimes on # Linux, and fails everywhhere else. For now, we test only on Windows, @@ -115,7 +115,7 @@ test('T2276_ghci', [ only_ghci, pre_cmd('$MAKE -s --no-print-directory T2276_ghci_setup') ], compile_and_run, ['-fobject-code T2276_ghci_c.o']) -test('T2469', js_broken(22261), compile_and_run, ['-optc-std=gnu99']) +test('T2469', normal, compile_and_run, ['-optc-std=gnu99']) test('T2594', [req_c], compile_and_run, ['T2594_c.c']) @@ -143,7 +143,7 @@ if config.os == 'mingw32': flagsForT4038 = ['-optl-Wl,--stack,10485760'] else: flagsForT4038 = [''] -test('T4038', [js_broken(22261), when(arch('wasm32'), fragile(22606))], compile_and_run, flagsForT4038) +test('T4038', [when(arch('wasm32'), fragile(22606))], compile_and_run, flagsForT4038) test('T4221', [req_c, when(arch('wasm32'), fragile(22606))], compile_and_run, ['T4221_c.c']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/575d769096d60f4a7561b2b9625b8d75e0a3879c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/575d769096d60f4a7561b2b9625b8d75e0a3879c You're receiving 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 Nov 1 14:29:46 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 10:29:46 -0400 Subject: [Git][ghc/ghc][wip/update-bootstrap-plans2] 2 commits: ci: Add 9.8.1 bootstrap testing job Message-ID: <654260da5f265_1baa285949be94524757@gitlab.mail> Matthew Pickering pushed to branch wip/update-bootstrap-plans2 at Glasgow Haskell Compiler / GHC Commits: c1dc410b by Matthew Pickering at 2023-11-01T14:29:15+00:00 ci: Add 9.8.1 bootstrap testing job - - - - - edfeeecd by Matthew Pickering at 2023-11-01T14:29:27+00:00 Compatability with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 7 changed files: - .gitlab-ci.yml - hadrian/src/Settings/Packages.hs - libraries/ghc-heap/GHC/Exts/Stack.hs - libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc - libraries/ghc-heap/GHC/Exts/Stack/Decode.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghci/ghci.cabal.in Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 8035736da0a70f09bd9b63a696cf2eb7977694ec + DOCKER_REV: a55d4ae0f9da0a2fb3bc72a13f356e2511a4c4fd # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. @@ -105,6 +105,8 @@ workflow: DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - GHC_VERSION: 9.6.2 DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_6:$DOCKER_REV" + - GHC_VERSION: 9.8.1 + DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_8:$DOCKER_REV" # Allow linters to fail on draft MRs. # This must be explicitly transcluded in lint jobs which ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -10,6 +10,7 @@ import Settings.Builders.Common (wayCcArgs) import GHC.Toolchain.Target import GHC.Platform.ArchOS +import Data.Version.Extra -- | Package-specific command-line arguments. packageArgs :: Args @@ -33,6 +34,7 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir + stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat --------------------------------- base --------------------------------- @@ -83,7 +85,7 @@ packageArgs = do -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal - , stage0 ? arg "+hadrian-stage0" + , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" , flag StaticLibzstd `cabalFlag` "static-libzstd" ] ===================================== libraries/ghc-heap/GHC/Exts/Stack.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE RecordWildCards #-} module GHC.Exts.Stack ===================================== libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc ===================================== @@ -3,7 +3,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Exts.Stack.Constants where -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) import Prelude ===================================== libraries/ghc-heap/GHC/Exts/Stack/Decode.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances #-} ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -23,7 +23,7 @@ library default-language: Haskell2010 build-depends: base >= 4.9.0 && < 5.0 - , ghc-prim > 0.2 && < 0.11 + , ghc-prim > 0.2 && < 0.12 , rts == 1.0.* , containers >= 0.6.2.1 && < 0.7 ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -76,7 +76,7 @@ library rts, array == 0.5.*, base >= 4.8 && < 4.20, - ghc-prim >= 0.5.0 && < 0.11, + ghc-prim >= 0.5.0 && < 0.12, binary == 0.8.*, bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39ed44caf69737cedb5cae3c3111c1eae4ea3d93...edfeeecd1b519fb8b5c393cb56d9169d0d6c6374 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39ed44caf69737cedb5cae3c3111c1eae4ea3d93...edfeeecd1b519fb8b5c393cb56d9169d0d6c6374 You're receiving 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 Nov 1 15:24:00 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 11:24:00 -0400 Subject: [Git][ghc/ghc][wip/update-bootstrap-plans2] 2 commits: ci: Add 9.8.1 bootstrap testing job Message-ID: <65426d90dc8ae_1baa285a674490532890@gitlab.mail> Matthew Pickering pushed to branch wip/update-bootstrap-plans2 at Glasgow Haskell Compiler / GHC Commits: f0793b63 by Matthew Pickering at 2023-11-01T15:23:23+00:00 ci: Add 9.8.1 bootstrap testing job - - - - - 447dc345 by Matthew Pickering at 2023-11-01T15:23:43+00:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 7 changed files: - .gitlab-ci.yml - hadrian/src/Settings/Packages.hs - libraries/ghc-heap/GHC/Exts/Stack.hs - libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc - libraries/ghc-heap/GHC/Exts/Stack/Decode.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghci/ghci.cabal.in Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 8035736da0a70f09bd9b63a696cf2eb7977694ec + DOCKER_REV: a55d4ae0f9da0a2fb3bc72a13f356e2511a4c4fd # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. @@ -101,10 +101,12 @@ workflow: # which versions of GHC to allow bootstrap with .bootstrap_matrix : &bootstrap_matrix matrix: - - GHC_VERSION: 9.4.3 - DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - - GHC_VERSION: 9.6.2 + - GHC_VERSION: 9.4.7 + DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_4:$DOCKER_REV" + - GHC_VERSION: 9.6.3 DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_6:$DOCKER_REV" + - GHC_VERSION: 9.8.1 + DOCKER_IMAGE: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10-ghc9_8:$DOCKER_REV" # Allow linters to fail on draft MRs. # This must be explicitly transcluded in lint jobs which ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -10,6 +10,7 @@ import Settings.Builders.Common (wayCcArgs) import GHC.Toolchain.Target import GHC.Platform.ArchOS +import Data.Version.Extra -- | Package-specific command-line arguments. packageArgs :: Args @@ -33,6 +34,7 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir + stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat --------------------------------- base --------------------------------- @@ -83,7 +85,7 @@ packageArgs = do -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal - , stage0 ? arg "+hadrian-stage0" + , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" , flag StaticLibzstd `cabalFlag` "static-libzstd" ] ===================================== libraries/ghc-heap/GHC/Exts/Stack.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE RecordWildCards #-} module GHC.Exts.Stack ===================================== libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc ===================================== @@ -3,7 +3,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Exts.Stack.Constants where -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) import Prelude ===================================== libraries/ghc-heap/GHC/Exts/Stack/Decode.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances #-} ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -23,7 +23,7 @@ library default-language: Haskell2010 build-depends: base >= 4.9.0 && < 5.0 - , ghc-prim > 0.2 && < 0.11 + , ghc-prim > 0.2 && < 0.12 , rts == 1.0.* , containers >= 0.6.2.1 && < 0.7 ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -76,7 +76,7 @@ library rts, array == 0.5.*, base >= 4.8 && < 4.20, - ghc-prim >= 0.5.0 && < 0.11, + ghc-prim >= 0.5.0 && < 0.12, binary == 0.8.*, bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/edfeeecd1b519fb8b5c393cb56d9169d0d6c6374...447dc345ab7c4687b08c12781ec8d8a08b609222 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/edfeeecd1b519fb8b5c393cb56d9169d0d6c6374...447dc345ab7c4687b08c12781ec8d8a08b609222 You're receiving 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 Nov 1 16:24:27 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 12:24:27 -0400 Subject: [Git][ghc/ghc][wip/update-bootstrap-plans2] Compatibility with 9.8.1 as boot compiler Message-ID: <65427bbb2c6b6_1baa285be09d9453381e@gitlab.mail> Matthew Pickering pushed to branch wip/update-bootstrap-plans2 at Glasgow Haskell Compiler / GHC Commits: ab53905e by Matthew Pickering at 2023-11-01T16:24:20+00:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 8 changed files: - hadrian/src/Settings/Packages.hs - libraries/ghc-heap/GHC/Exts/Stack.hs - libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc - libraries/ghc-heap/GHC/Exts/Stack/Decode.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghci/ghci.cabal.in - linters/lint-whitespace/lint-whitespace.cabal - linters/linters-common/linters-common.cabal Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -10,6 +10,7 @@ import Settings.Builders.Common (wayCcArgs) import GHC.Toolchain.Target import GHC.Platform.ArchOS +import Data.Version.Extra -- | Package-specific command-line arguments. packageArgs :: Args @@ -33,6 +34,7 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir + stageVersion <- readVersion <$> (expr $ ghcVersionStage stage) mconcat --------------------------------- base --------------------------------- @@ -83,7 +85,7 @@ packageArgs = do -- not being fixed to `ghc`, when building stage0, we must set -- -this-unit-id to `ghc` because the boot compiler expects that. -- We do it through a cabal flag in ghc.cabal - , stage0 ? arg "+hadrian-stage0" + , stageVersion < makeVersion [9,8,1] ? arg "+hadrian-stage0" , flag StaticLibzstd `cabalFlag` "static-libzstd" ] ===================================== libraries/ghc-heap/GHC/Exts/Stack.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE RecordWildCards #-} module GHC.Exts.Stack ===================================== libraries/ghc-heap/GHC/Exts/Stack/Constants.hsc ===================================== @@ -3,7 +3,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Exts.Stack.Constants where -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) import Prelude ===================================== libraries/ghc-heap/GHC/Exts/Stack/Decode.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -#if MIN_TOOL_VERSION_ghc(9,7,0) +#if MIN_TOOL_VERSION_ghc(9,9,0) {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances #-} ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -23,7 +23,7 @@ library default-language: Haskell2010 build-depends: base >= 4.9.0 && < 5.0 - , ghc-prim > 0.2 && < 0.11 + , ghc-prim > 0.2 && < 0.12 , rts == 1.0.* , containers >= 0.6.2.1 && < 0.7 ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -76,7 +76,7 @@ library rts, array == 0.5.*, base >= 4.8 && < 4.20, - ghc-prim >= 0.5.0 && < 0.11, + ghc-prim >= 0.5.0 && < 0.12, binary == 0.8.*, bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, ===================================== linters/lint-whitespace/lint-whitespace.cabal ===================================== @@ -28,4 +28,4 @@ executable lint-whitespace base >= 4.14 && < 5, text - >= 1.2 && < 2.1, + >= 1.2 && < 3, ===================================== linters/linters-common/linters-common.cabal ===================================== @@ -16,7 +16,7 @@ library base >= 4.14 && < 5, text - >= 1.2 && < 2.1, + >= 1.2 && < 3, deepseq >= 1.1, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab53905e7b6214d74637db8a1c624c166b19ee1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab53905e7b6214d74637db8a1c624c166b19ee1b You're receiving 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 Nov 1 16:49:45 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 01 Nov 2023 12:49:45 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Correct GHC_PKG path Message-ID: <654281a9878ab_1baa285ca4f644534465@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: af3cf674 by GHC GitLab CI at 2023-11-01T16:47:29+00:00 Correct GHC_PKG path - - - - - 1 changed file: - hadrian/src/Rules/Test.hs Changes: ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -235,10 +235,10 @@ testRules = do pythonPath <- builderPath Python testGhc <- testCompiler <$> userSetting defaultTestArgs - bindir <- getBinaryDirectory testGhc cross <- getBooleanSetting TestCrossCompiling - test_target_platform <- getTestSetting TestTARGETPLATFORM - let cross_prefix = if cross then test_target_platform ++ "-" else "" + bindir <- getBinaryDirectory testGhc + compiler_path <- getCompilerPath testGhc + let cross_prefix = if cross then dropWhileEnd ((/=) '-') (takeFileName compiler_path) else "" let exe_path :: Package -> String exe_path pkg = bindir (cross_prefix ++ programBasename vanilla pkg) <.> exe View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af3cf674fced3a22856b39ad6fba3a178ebf5d89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af3cf674fced3a22856b39ad6fba3a178ebf5d89 You're receiving 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 Nov 1 20:50:08 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Wed, 01 Nov 2023 16:50:08 -0400 Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] T2T in Expressions (#23738) Message-ID: <6542ba005433d_27efe93ffb614782e4@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC Commits: 0fdb0d1c by Vladislav Zavialov at 2023-11-01T23:49:32+03:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 27 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - docs/users_guide/exts/required_type_arguments.rst - testsuite/tests/diagnostic-codes/codes.stdout - testsuite/tests/vdq-rta/should_compile/T22326_idv.hs - + testsuite/tests/vdq-rta/should_compile/T23738_basic.hs - + testsuite/tests/vdq-rta/should_compile/T23738_nested.hs - + testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs - + testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs - + testsuite/tests/vdq-rta/should_compile/T23738_th.hs - + testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs - + testsuite/tests/vdq-rta/should_compile/T23738_wild.hs - testsuite/tests/vdq-rta/should_compile/all.T - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr - testsuite/tests/vdq-rta/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -208,8 +208,6 @@ data EpAnnUnboundVar = EpAnnUnboundVar , hsUnboundHole :: EpaLocation } deriving Data -type instance XVar (GhcPass _) = NoExtField - -- Record selectors at parse time are HsVar; they convert to HsRecSel -- on renaming. type instance XRecSel GhcPs = DataConCantHappen @@ -430,6 +428,13 @@ tupArgPresent :: HsTupArg (GhcPass p) -> Bool tupArgPresent (Present {}) = True tupArgPresent (Missing {}) = False +tupArgPresent_maybe :: HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p)) +tupArgPresent_maybe (Present _ e) = Just e +tupArgPresent_maybe (Missing {}) = Nothing + +tupArgsPresent_maybe :: [HsTupArg (GhcPass p)] -> Maybe [LHsExpr (GhcPass p)] +tupArgsPresent_maybe = traverse tupArgPresent_maybe + {- ********************************************************************* * * ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -277,6 +277,14 @@ instance Diagnostic TcRnMessage where sole_msg = vcat [ text "except as the sole constraint" , nest 2 (text "e.g., deriving instance _ => Eq (Foo a)") ] + TcRnIllegalNamedWildcardInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal named wildcard in a required type argument:") + 2 (quotes (ppr rdr)) + TcRnIllegalImplicitTyVarInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal implicitly quantified type variable in a required type argument:") + 2 (quotes (ppr rdr)) TcRnDuplicateFieldName fld_part dups -> mkSimpleDecorated $ hsep [ text "Duplicate field name" @@ -1254,9 +1262,7 @@ instance Diagnostic TcRnMessage where text "A type pattern must be checked against a visible forall." TcRnIllformedTypeArgument e -> mkSimpleDecorated $ - hang (text "Ill-formed type argument:") 2 (ppr e) $$ - text "Expected a type expression introduced with the" - <+> quotes (text "type") <+> text "keyword." + hang (text "Ill-formed type argument:") 2 (ppr e) TcRnIllegalTypeExpr -> mkSimpleDecorated $ text "Illegal type expression." $$ @@ -1944,6 +1950,10 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnIllegalWildcardInType{} -> ErrorWithoutFlag + TcRnIllegalNamedWildcardInTypeArgument{} + -> ErrorWithoutFlag + TcRnIllegalImplicitTyVarInTypeArgument{} + -> ErrorWithoutFlag TcRnDuplicateFieldName{} -> ErrorWithoutFlag TcRnIllegalViewPattern{} @@ -2555,6 +2565,10 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.RecordWildCards] TcRnIllegalWildcardInType{} -> noHints + TcRnIllegalNamedWildcardInTypeArgument{} + -> [SuggestAnonymousWildcard] + TcRnIllegalImplicitTyVarInTypeArgument tv + -> [SuggestExplicitQuantification tv] TcRnDuplicateFieldName{} -> noHints TcRnIllegalViewPattern{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -712,6 +712,37 @@ data TcRnMessage where -> !BadAnonWildcardContext -> TcRnMessage + {-| TcRnIllegalNamedWildcardInTypeArgument is an error that occurs + when a named wildcard is used in a required type argument. + + Example: + + vfun :: forall (a :: k) -> () + x = vfun _nwc + -- ^^^^ + -- named wildcards not allowed in type arguments + + Test cases: + T23738_fail_wild + -} + TcRnIllegalNamedWildcardInTypeArgument + :: RdrName + -> TcRnMessage + + {- TcRnIllegalImplicitTyVarInTypeArgument is an error raised + when a type variable is implicitly quantified in a required type argument. + + Example: + vfun :: forall (a :: k) -> () + x = vfun (Nothing :: Maybe a) + -- ^^^ + -- implicit quantification not allowed in type arguments + + -} + TcRnIllegalImplicitTyVarInTypeArgument + :: RdrName + -> TcRnMessage + {-| TcRnDuplicateFieldName is an error that occurs whenever there are duplicate field names in a single record. @@ -4112,16 +4143,12 @@ data TcRnMessage where that specifies a required type argument (instantiates a visible forall) does not have a form that can be interpreted as a type argument. - At the moment, only expressions constructed using the @type@ keyword - are considered well-formed, but this restriction will be relaxed - when part 2 of GHC Proposal #281 is implemented. - Example: vfun :: forall (a :: k) -> () - x = vfun Int - -- ^^^ - -- expected `type Int` instead of `Int` + x = vfun (\_ -> _) + -- ^^^^^^^^^ + -- lambdas not allowed in type arguments Test cases: T22326_fail_raw_arg ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -23,6 +23,7 @@ import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcPolyExpr ) import GHC.Types.Var import GHC.Builtin.Types ( multiplicityTy ) import GHC.Tc.Gen.Head +import Language.Haskell.Syntax.Basic import GHC.Hs import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad @@ -51,8 +52,10 @@ import GHC.Builtin.Names import GHC.Driver.DynFlags import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) +import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -806,10 +809,210 @@ tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism ch -> LHsExpr GhcRn -- Argument type -> TcM (TcType, TcType) tcVDQ conc_tvs (tvb, inner_ty) arg - = do { hs_ty <- case stripParensLHsExpr arg of - L _ (HsEmbTy _ _ hs_ty) -> return hs_ty - e -> failWith $ TcRnIllformedTypeArgument e - ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_ty } + = do { hs_wc_ty <- expr_to_type (stripParensLHsExpr arg) + ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_wc_ty } + +-- Convert a HsExpr into the equivalent HsType. +-- See [RequiredTypeArguments and the T2T mapping] +expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) +expr_to_type earg = + case stripParensLHsExpr earg of + L _ (HsEmbTy _ _ hs_ty) -> + -- The entire type argument is guarded with the `type` herald, + -- e.g. `vfun (type (Maybe Int))`. This special case supports + -- named wildcards. See Note [Wildcards in the T2T translation] + return hs_ty + e -> + -- The type argument is not guarded with the `type` herald, or perhaps + -- only parts of it are, e.g. `vfun (Maybe Int)` or `vfun (Maybe (type Int))`. + -- Apply a recursive T2T transformation. + HsWC [] <$> go e + where + go :: LHsExpr GhcRn -> TcM (LHsType GhcRn) + go (L _ (HsEmbTy _ _ t)) = + -- HsEmbTy means there is an explicit `type` herald, e.g. vfun :: forall a -> blah + -- and the call vfun (type Int) + -- or vfun (Int -> type Int) + -- The T2T transformation can simply discard the herald and use the embedded type. + unwrap_wc t + go (L l (HsVar _ lname)) = + -- as per #281: variables and constructors (regardless of their namespace) + -- are mapped directly, without modification. + return (L l (HsTyVar noAnn NotPromoted lname)) + go (L l (HsApp _ lhs rhs)) = + do { lhs' <- go lhs + ; rhs' <- go rhs + ; return (L l (HsAppTy noExtField lhs' rhs')) } + go (L l (HsAppType _ lhs at rhs)) = + do { lhs' <- go lhs + ; rhs' <- unwrap_wc rhs + ; return (L l (HsAppKindTy noExtField lhs' at rhs')) } + go (L l e@(OpApp _ lhs op rhs)) = + do { lhs' <- go lhs + ; op' <- go op + ; rhs' <- go rhs + ; op_id <- unwrap_op_tv op' + ; return (L l (HsOpTy noAnn NotPromoted lhs' op_id rhs')) } + where + unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id + unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) + go (L l e@(HsOverLit _ lit)) = + do { tylit <- case ol_val lit of + HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) + HsIsString _ s -> return $ HsStrTy NoSourceText s + HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l e@(HsLit _ lit)) = + do { tylit <- case lit of + HsChar _ c -> return $ HsCharTy NoSourceText c + HsString _ s -> return $ HsStrTy NoSourceText s + _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l (ExplicitTuple _ tup_args boxity)) + -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted + | isBoxed boxity + , Just es <- tupArgsPresent_maybe tup_args + = do { ts <- traverse go es + ; return (L l (HsExplicitTupleTy noExtField ts)) } + go (L l (ExplicitList _ es)) = + do { ts <- traverse go es + ; return (L l (HsExplicitListTy noExtField NotPromoted ts)) } + go (L l (ExprWithTySig _ e sig_ty)) = + do { t <- go e + ; sig_ki <- (unwrap_sig <=< unwrap_wc) sig_ty + ; return (L l (HsKindSig noAnn t sig_ki)) } + where + unwrap_sig :: LHsSigType GhcRn -> TcM (LHsType GhcRn) + unwrap_sig (L _ (HsSig _ HsOuterImplicit{hso_ximplicit=bndrs} body)) + | null bndrs = return body + | otherwise = illegal_implicit_tvs bndrs + unwrap_sig (L l (HsSig _ HsOuterExplicit{hso_bndrs=bndrs} body)) = + return $ L l (HsForAllTy noExtField (HsForAllInvis noAnn bndrs) body) + go (L l (HsPar _ _ e _)) = + do { t <- go e + ; return (L l (HsParTy noAnn t)) } + go (L l (HsUntypedSplice splice_result splice)) + | HsUntypedSpliceTop finalizers e <- splice_result + = do { t <- go (L l e) + ; let splice_result' = HsUntypedSpliceTop finalizers t + ; return (L l (HsSpliceTy splice_result' splice)) } + go (L l (HsUnboundVar _ rdr)) + | isUnderscore occ = return (L l (HsWildCardTy noExtField)) + | startsWithUnderscore occ = + -- See Note [Wildcards in the T2T translation] + do { wildcards_enabled <- xoptM LangExt.NamedWildCards + ; if wildcards_enabled + then illegal_wc rdr + else not_in_scope } + | otherwise = not_in_scope + where occ = occName rdr + not_in_scope = failWith $ mkTcRnNotInScope rdr NotInScope + go (L l (XExpr (HsExpanded orig _))) = + -- Use the original, user-written expression (before expansion). + -- Example. Say we have vfun :: forall a -> blah + -- and the call vfun (Maybe [1,2,3]) + -- expanded to vfun (Maybe (fromListN 3 [1,2,3])) + -- (This happens when OverloadedLists is enabled). + -- The expanded expression can't be promoted, as there is no type-level + -- equivalent of fromListN, so we must use the original. + go (L l orig) + go e = failWith $ TcRnIllformedTypeArgument e + + unwrap_wc :: HsWildCardBndrs GhcRn t -> TcM t + unwrap_wc (HsWC wcs t) + = do { mapM_ (illegal_wc . nameRdrName) wcs + ; return t } + + illegal_wc :: RdrName -> TcM t + illegal_wc rdr = failWith $ TcRnIllegalNamedWildcardInTypeArgument rdr + + illegal_implicit_tvs :: [Name] -> TcM t + illegal_implicit_tvs tvs + = do { mapM_ (addErr . TcRnIllegalImplicitTyVarInTypeArgument . nameRdrName) tvs + ; failM } + +{- Note [RequiredTypeArguments and the T2T mapping] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The "T2T-Mapping" section of GHC Proposal #281 introduces a term-to-type transformation +that comes into play when we typecheck function applications to required type arguments. +Say we have a function that expects a required type argument, vfun :: forall a -> ... +then it is possible to call it as follows: + + vfun (Maybe Int) + +The Maybe Int argument is parsed and renamed as a term. There is no syntactic marker +to tell GHC that it is actually a type argument. We only discover this by the time +we get to type checking, where we know that f's type has a visible forall at the front, +so we are expecting a type argument. More precisely, this happens in tcVDQ in GHC/Tc/Gen/App.hs: + + tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] + -> (ForAllTyBinder, TcType) -- Function type + -> LHsExpr GhcRn -- Argument type + -> TcM (TcType, TcType) + +What we want is a type to instantiate the forall-bound variable. But what we have is an HsExpr, +and we need to convert it to an HsType in order to reuse the same code paths as we use for +checking f @ty (see tc_inst_forall_arg). + + f (Maybe Int) + -- ^^^^^^^^^ + -- parsed and renamed as: HsApp (HsVar "Maybe") (HsVar "Int") :: HsExpr GhcRn + -- must be converted to: HsTyApp (HsTyVar "Maybe") (HsTyVar "Int") :: HsType GhcRn + +We do this using a helper function: + + expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) + +This conversion is in the TcM monad because +* It can fail, if the expression is not convertible to a type. + vfun [x | x <- xs] Can't convert list comprehension to a type + vfun (\x -> x) Can't convert a lambda to a type +* It needs to check for LangExt.NamedWildCards to generate an appropriate + error message for HsUnboundVar. + vfun _a Not in scope: ‘_a’ + (NamedWildCards disabled) + vfun _a Illegal named wildcard in a required type argument: ‘_a’ + (NamedWildCards enabled) + +Note [Wildcards in the T2T translation] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose f1 :: forall a b. blah + f2 :: forall a b -> blah + +Consider the terms + f1 @_ @(Either _ _) + f2 (type _) (type (Either _ _)) +Those `_` wildcards are type wildcards, each standing for a monotype. +All good. + +Now consider this, with -XNamedWildCards: + f1 @_a @(Either _a _a) + f2 (type _a) (type (Either _a _a)) +Those `_a` are "named wildcards", specified by the user manual like this: "All +occurrences of the same named wildcard within one type signature will unify to +the same type". Note "within one signature". So each type argument is considered +separately, and the examples mean the same as: + f1 @_a1 @(Either _a2 _a2) + f2 (type _a1) (type (Either _a2 _a2)) +The repeated `_a2` ensures that the two arguments of `Either` are the same type; +but there is no connection with `_a1`. (NB: `_a1` and `_a2` only scope within +their respective type, no further.) + +Now, consider the T2T translation for + f2 _ (Either _ _) +This is fine: the term wildcard `_` is translated to a type wildcard, so we get +the same as if we had written + f2 (type _) (type (Either _ _)) + +But what about /named/ wildcards? + f2 _a (Either _a _a) +Now we are in difficulties. The renamer looks for a /term/ variable `_a` in scope, +and won't find one. Even if it did, the three `_a`'s would not be renamed separately +as above. + +Conclusion: we treat a named wildcard in the T2T translation as an error. If you +want that, use a `(type ty)` argument instead. +-} tc_inst_forall_arg :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] -> (ForAllTyBinder, TcType) -- Function type @@ -890,7 +1093,7 @@ At a call site we may have calls looking like this fs True -- Specified: type argument omitted fs @Bool True -- Specified: type argument supplied fr (type Bool) True -- Required: type argument is compulsory, `type` qualifier used - fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted (NB: not implemented) + fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted At definition sites we may have type /patterns/ to abstract over type variables fi x = rhs -- Inferred: no type pattern @@ -953,8 +1156,8 @@ Syntax of applications in HsExpr Why the difference? Because we /also/ need to express these /nested/ uses of `type`: - g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) - g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) + g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t + g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t This nesting makes `type` rather different from `@`. Remember, the HsEmbTy mainly just switches namespace, and is subject to the term-to-type transformation. @@ -993,7 +1196,7 @@ rnExpr delegates renaming of type arguments to rnHsWcType if possible: f (type t) -- HsApp and HsEmbTy, t is renamed with rnHsWcType But what about: - f t -- HsApp, no HsEmbTy (NB. not implemented) + f t -- HsApp, no HsEmbTy We simply rename `t` as a term using a recursive call to rnExpr; in particular, the type of `f` does not affect name resolution (Lexical Scoping Principle). We will later convert `t` from a `HsExpr` to a `Type`, see "Typechecking type @@ -1057,7 +1260,7 @@ This is done by tcVTA (if Specified) and tcVDQ (if Required). tcVDQ unwraps the HsEmbTy and uses the type contained within it. Crucially, in tcVDQ we know that we are expecting a type argument. This means that we can support - f (Maybe Int) -- HsApp, no HsEmbTy (NB. not implemented) + f (Maybe Int) -- HsApp, no HsEmbTy The type argument (Maybe Int) is represented as an HsExpr, but tcVDQ can easily convert it to HsType. This conversion is called the "T2T-Mapping" in GHC Proposal #281. ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -369,6 +369,8 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnIllegalFieldPunning" = 44287 GhcDiagnosticCode "TcRnIllegalWildcardsInRecord" = 37132 GhcDiagnosticCode "TcRnIllegalWildcardInType" = 65507 + GhcDiagnosticCode "TcRnIllegalNamedWildcardInTypeArgument" = 93411 + GhcDiagnosticCode "TcRnIllegalImplicitTyVarInTypeArgument" = 80557 GhcDiagnosticCode "TcRnDuplicateFieldName" = 85524 GhcDiagnosticCode "TcRnIllegalViewPattern" = 22406 GhcDiagnosticCode "TcRnCharLiteralOutOfRange" = 17268 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -474,6 +474,12 @@ data GhcHint -} | SuggestBindTyVarOnLhs RdrName + {-| Suggest using an anonymous wildcard instead of a named wildcard -} + | SuggestAnonymousWildcard + + {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} + | SuggestExplicitQuantification RdrName + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -266,6 +266,11 @@ instance Outputable GhcHint where ppr_r = quotes $ ppr r SuggestBindTyVarOnLhs tv -> text "Bind" <+> quotes (ppr tv) <+> text "on the LHS of the type declaration" + SuggestAnonymousWildcard + -> text "Use an anonymous wildcard" <+> quotes (text "_") + SuggestExplicitQuantification tv + -> hsep [ text "Use an explicit", quotes (text "forall") + , text "to quantify over", quotes (ppr tv) ] perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -80,7 +80,7 @@ module GHC.Types.Name.Occurrence ( isVarOcc, isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc, isFieldOcc, fieldOcc_maybe, - parenSymOcc, startsWithUnderscore, + parenSymOcc, startsWithUnderscore, isUnderscore, isTcClsNameSpace, isTvNameSpace, isDataConNameSpace, isVarNameSpace, isValNameSpace, isFieldNameSpace, isTermVarOrFieldNameSpace, @@ -912,6 +912,9 @@ startsWithUnderscore occ = case unpackFS (occNameFS occ) of '_':_ -> True _ -> False +isUnderscore :: OccName -> Bool +isUnderscore occ = occNameFS occ == fsLit "_" + {- ************************************************************************ * * ===================================== docs/users_guide/exts/required_type_arguments.rst ===================================== @@ -107,7 +107,5 @@ indistinguishble from ordinary function arguments:: n = id_vdq Integer 42 In this example we pass ``Integer`` as opposed to ``(type Integer)``. -**This is not currently implemented**, but it demonstrates how -:extension:`RequiredTypeArguments` is not tied to the ``type`` syntax. -For this reason, using the ``type`` syntax requires enabling the -:extension:`ExplicitNamespaces` extension separately. \ No newline at end of file +This means that :extension:`RequiredTypeArguments` is not tied to the ``type`` +syntax, which belongs to :extension:`ExplicitNamespaces`. \ No newline at end of file ===================================== testsuite/tests/diagnostic-codes/codes.stdout ===================================== @@ -65,7 +65,6 @@ [GHC-85337] is untested (constructor = TcRnSpecialiseNotVisible) [GHC-91382] is untested (constructor = TcRnIllegalKindSignature) [GHC-72520] is untested (constructor = TcRnIgnoreSpecialisePragmaOnDefMethod) -[GHC-10969] is untested (constructor = TcRnTyThingUsedWrong) [GHC-61072] is untested (constructor = TcRnGADTDataContext) [GHC-16409] is untested (constructor = TcRnMultipleConForNewtype) [GHC-54478] is untested (constructor = TcRnRedundantSourceImport) ===================================== testsuite/tests/vdq-rta/should_compile/T22326_idv.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RequiredTypeArguments #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE NamedWildCards #-} module T22326_idv where @@ -38,4 +39,8 @@ idv_wild (type _) x = x -- Usage (using a wildcard) rBool' = idv (type _) True -rChar' = idv (type _) 'x' \ No newline at end of file +rChar' = idv (type _) 'x' + +-- Usage (using named wildcards) +rMaybeX = idv (type (Maybe _a)) Nothing +rEitherCharChar = idv (type (Either _a _a)) (Left 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_basic.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Overloaded string literals checked in T23738_overlit. +{-# LANGUAGE NoOverloadedStrings #-} + +module T23738_basic where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2])) + {- term syntax: -} (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_nested.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_nested where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + (type (Either Int Bool)) + (Either (type Int) (type Bool)) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Non-overloaded string literals checked in T23738_basic. +{-# LANGUAGE OverloadedStrings #-} + +-- Non-overloaded lists are checked in T23738_basic. +{-# LANGUAGE OverloadedLists #-} + +module T23738_overlit where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '("Hello", [1, 2, 3])) + {- term syntax: -} ("Hello", [1, 2, 3]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_sigforall where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +r1 :: () +r1 = + checkEq + {- type syntax: -} (type (Left :: forall a b. a -> Either a b)) + {- term syntax: -} (Left :: forall a b. a -> Either a b) + +r2 :: () +r2 = + checkEq + {- type syntax: -} (type (Left :: forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall a. forall b. a -> Either a b) + +r3 :: () +r3 = + checkEq + {- type syntax: -} (type (Left :: forall. forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall. forall a. forall b. a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_th.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TemplateHaskell #-} + +module T23738_th where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type $[t| '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2]) |]) + {- term syntax: -} $[e| (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) |] \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} + +module T23738_tyvar where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: forall k. forall (f :: k -> Type) (t :: k) -> () +result (type f) (type t) = + checkEq + {- type syntax: -} (type (f t)) + {- term syntax: -} (f t) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool = idv _ True +rChar = idv _ 'x' + +rMaybeBool = idv (Maybe _) (Just True) +rMaybeChar = idv (Maybe _) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -10,6 +10,13 @@ test('T22326_sig', normal, compile, ['']) test('T17792_vdq', normal, compile, ['']) test('T14158_vdq', normal, compile, ['']) test('WithSpineVDQ_LintErr', normal, compile, ['']) +test('T23738_basic', normal, compile, ['']) +test('T23738_tyvar', normal, compile, ['']) +test('T23738_overlit', normal, compile, ['']) +test('T23738_nested', normal, compile, ['']) +test('T23738_wild', normal, compile, ['']) +test('T23738_sigforall', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) -test('T22326_th_pprint1', req_th, compile, ['']) \ No newline at end of file +test('T22326_th_pprint1', req_th, compile, ['']) +test('T23738_th', req_th, compile, ['']) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr ===================================== @@ -1,6 +1,5 @@ T22326_fail_raw_arg.hs:9:5: error: [GHC-29092] • Ill-formed type argument: \ _ -> _ - Expected a type expression introduced with the ‘type’ keyword. • In the expression: f (\ _ -> _) In an equation for ‘x’: x = f (\ _ -> _) ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_fail_implicit_tv where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +rNothing = vfun (Nothing :: Maybe a) +rLeft = vfun (Left :: a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr ===================================== @@ -0,0 +1,21 @@ + +T23738_fail_implicit_tv.hs:10:12: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Nothing :: Maybe a) + In an equation for ‘rNothing’: rNothing = vfun (Nothing :: Maybe a) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘b’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘b’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE TypeAbstractions #-} + +module T23738_fail_var where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +f :: Int -> () +f a = vfun a \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr ===================================== @@ -0,0 +1,6 @@ + +T23738_fail_var.hs:11:12: error: [GHC-10969] + • Local identifier ‘a’ used as a type + • In the type ‘a’ + In the expression: vfun a + In an equation for ‘f’: f a = vfun a ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_fail_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool' = idv _w True +rChar' = idv _w 'x' + +rMaybeBool' = idv (Maybe _w) (Just True) +rMaybeChar' = idv (Maybe _w) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr ===================================== @@ -0,0 +1,26 @@ + +T23738_fail_wild.hs:10:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w True + In an equation for ‘rBool'’: rBool' = idv _w True + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:11:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w 'x' + In an equation for ‘rChar'’: rChar' = idv _w 'x' + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:13:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just True) + In an equation for ‘rMaybeBool'’: + rMaybeBool' = idv (Maybe _w) (Just True) + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:14:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just 'x') + In an equation for ‘rMaybeChar'’: + rMaybeChar' = idv (Maybe _w) (Just 'x') + Suggested fix: Use an anonymous wildcard ‘_’ ===================================== testsuite/tests/vdq-rta/should_fail/all.T ===================================== @@ -11,4 +11,7 @@ test('T22326_fail_caseof', normal, compile_fail, ['']) test('T22326_fail_ado', normal, compile_fail, ['']) test('T22326_fail_n_args', normal, compile_fail, ['']) test('T22326_fail_patsyn', normal, compile_fail, ['']) -test('T22326_fail_match', normal, compile_fail, ['']) \ No newline at end of file +test('T22326_fail_match', normal, compile_fail, ['']) +test('T23738_fail_wild', normal, compile_fail, ['']) +test('T23738_fail_implicit_tv', normal, compile_fail, ['']) +test('T23738_fail_var', normal, compile_fail, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fdb0d1cf14ccff09f76030c2eab90bd251f8d75 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fdb0d1cf14ccff09f76030c2eab90bd251f8d75 You're receiving 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 Nov 1 20:55:34 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Wed, 01 Nov 2023 16:55:34 -0400 Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] T2T in Expressions (#23738) Message-ID: <6542bb461565f_27efe9403e2ac824bf@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC Commits: 54744419 by Vladislav Zavialov at 2023-11-01T23:55:10+03:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 27 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - docs/users_guide/exts/required_type_arguments.rst - testsuite/tests/diagnostic-codes/codes.stdout - testsuite/tests/vdq-rta/should_compile/T22326_idv.hs - + testsuite/tests/vdq-rta/should_compile/T23738_basic.hs - + testsuite/tests/vdq-rta/should_compile/T23738_nested.hs - + testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs - + testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs - + testsuite/tests/vdq-rta/should_compile/T23738_th.hs - + testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs - + testsuite/tests/vdq-rta/should_compile/T23738_wild.hs - testsuite/tests/vdq-rta/should_compile/all.T - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr - testsuite/tests/vdq-rta/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -208,8 +208,6 @@ data EpAnnUnboundVar = EpAnnUnboundVar , hsUnboundHole :: EpaLocation } deriving Data -type instance XVar (GhcPass _) = NoExtField - -- Record selectors at parse time are HsVar; they convert to HsRecSel -- on renaming. type instance XRecSel GhcPs = DataConCantHappen @@ -430,6 +428,13 @@ tupArgPresent :: HsTupArg (GhcPass p) -> Bool tupArgPresent (Present {}) = True tupArgPresent (Missing {}) = False +tupArgPresent_maybe :: HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p)) +tupArgPresent_maybe (Present _ e) = Just e +tupArgPresent_maybe (Missing {}) = Nothing + +tupArgsPresent_maybe :: [HsTupArg (GhcPass p)] -> Maybe [LHsExpr (GhcPass p)] +tupArgsPresent_maybe = traverse tupArgPresent_maybe + {- ********************************************************************* * * ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -277,6 +277,14 @@ instance Diagnostic TcRnMessage where sole_msg = vcat [ text "except as the sole constraint" , nest 2 (text "e.g., deriving instance _ => Eq (Foo a)") ] + TcRnIllegalNamedWildcardInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal named wildcard in a required type argument:") + 2 (quotes (ppr rdr)) + TcRnIllegalImplicitTyVarInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal implicitly quantified type variable in a required type argument:") + 2 (quotes (ppr rdr)) TcRnDuplicateFieldName fld_part dups -> mkSimpleDecorated $ hsep [ text "Duplicate field name" @@ -1254,9 +1262,7 @@ instance Diagnostic TcRnMessage where text "A type pattern must be checked against a visible forall." TcRnIllformedTypeArgument e -> mkSimpleDecorated $ - hang (text "Ill-formed type argument:") 2 (ppr e) $$ - text "Expected a type expression introduced with the" - <+> quotes (text "type") <+> text "keyword." + hang (text "Ill-formed type argument:") 2 (ppr e) TcRnIllegalTypeExpr -> mkSimpleDecorated $ text "Illegal type expression." $$ @@ -1944,6 +1950,10 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnIllegalWildcardInType{} -> ErrorWithoutFlag + TcRnIllegalNamedWildcardInTypeArgument{} + -> ErrorWithoutFlag + TcRnIllegalImplicitTyVarInTypeArgument{} + -> ErrorWithoutFlag TcRnDuplicateFieldName{} -> ErrorWithoutFlag TcRnIllegalViewPattern{} @@ -2555,6 +2565,10 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.RecordWildCards] TcRnIllegalWildcardInType{} -> noHints + TcRnIllegalNamedWildcardInTypeArgument{} + -> [SuggestAnonymousWildcard] + TcRnIllegalImplicitTyVarInTypeArgument tv + -> [SuggestExplicitQuantification tv] TcRnDuplicateFieldName{} -> noHints TcRnIllegalViewPattern{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -712,6 +712,37 @@ data TcRnMessage where -> !BadAnonWildcardContext -> TcRnMessage + {-| TcRnIllegalNamedWildcardInTypeArgument is an error that occurs + when a named wildcard is used in a required type argument. + + Example: + + vfun :: forall (a :: k) -> () + x = vfun _nwc + -- ^^^^ + -- named wildcards not allowed in type arguments + + Test cases: + T23738_fail_wild + -} + TcRnIllegalNamedWildcardInTypeArgument + :: RdrName + -> TcRnMessage + + {- TcRnIllegalImplicitTyVarInTypeArgument is an error raised + when a type variable is implicitly quantified in a required type argument. + + Example: + vfun :: forall (a :: k) -> () + x = vfun (Nothing :: Maybe a) + -- ^^^ + -- implicit quantification not allowed in type arguments + + -} + TcRnIllegalImplicitTyVarInTypeArgument + :: RdrName + -> TcRnMessage + {-| TcRnDuplicateFieldName is an error that occurs whenever there are duplicate field names in a single record. @@ -4112,16 +4143,12 @@ data TcRnMessage where that specifies a required type argument (instantiates a visible forall) does not have a form that can be interpreted as a type argument. - At the moment, only expressions constructed using the @type@ keyword - are considered well-formed, but this restriction will be relaxed - when part 2 of GHC Proposal #281 is implemented. - Example: vfun :: forall (a :: k) -> () - x = vfun Int - -- ^^^ - -- expected `type Int` instead of `Int` + x = vfun (\_ -> _) + -- ^^^^^^^^^ + -- lambdas not allowed in type arguments Test cases: T22326_fail_raw_arg ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -23,6 +23,7 @@ import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcPolyExpr ) import GHC.Types.Var import GHC.Builtin.Types ( multiplicityTy ) import GHC.Tc.Gen.Head +import Language.Haskell.Syntax.Basic import GHC.Hs import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad @@ -51,8 +52,10 @@ import GHC.Builtin.Names import GHC.Driver.DynFlags import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) +import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -806,10 +809,210 @@ tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism ch -> LHsExpr GhcRn -- Argument type -> TcM (TcType, TcType) tcVDQ conc_tvs (tvb, inner_ty) arg - = do { hs_ty <- case stripParensLHsExpr arg of - L _ (HsEmbTy _ _ hs_ty) -> return hs_ty - e -> failWith $ TcRnIllformedTypeArgument e - ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_ty } + = do { hs_wc_ty <- expr_to_type arg + ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_wc_ty } + +-- Convert a HsExpr into the equivalent HsType. +-- See [RequiredTypeArguments and the T2T mapping] +expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) +expr_to_type earg = + case stripParensLHsExpr earg of + L _ (HsEmbTy _ _ hs_ty) -> + -- The entire type argument is guarded with the `type` herald, + -- e.g. `vfun (type (Maybe Int))`. This special case supports + -- named wildcards. See Note [Wildcards in the T2T translation] + return hs_ty + e -> + -- The type argument is not guarded with the `type` herald, or perhaps + -- only parts of it are, e.g. `vfun (Maybe Int)` or `vfun (Maybe (type Int))`. + -- Apply a recursive T2T transformation. + HsWC [] <$> go e + where + go :: LHsExpr GhcRn -> TcM (LHsType GhcRn) + go (L _ (HsEmbTy _ _ t)) = + -- HsEmbTy means there is an explicit `type` herald, e.g. vfun :: forall a -> blah + -- and the call vfun (type Int) + -- or vfun (Int -> type Int) + -- The T2T transformation can simply discard the herald and use the embedded type. + unwrap_wc t + go (L l (HsVar _ lname)) = + -- as per #281: variables and constructors (regardless of their namespace) + -- are mapped directly, without modification. + return (L l (HsTyVar noAnn NotPromoted lname)) + go (L l (HsApp _ lhs rhs)) = + do { lhs' <- go lhs + ; rhs' <- go rhs + ; return (L l (HsAppTy noExtField lhs' rhs')) } + go (L l (HsAppType _ lhs at rhs)) = + do { lhs' <- go lhs + ; rhs' <- unwrap_wc rhs + ; return (L l (HsAppKindTy noExtField lhs' at rhs')) } + go (L l e@(OpApp _ lhs op rhs)) = + do { lhs' <- go lhs + ; op' <- go op + ; rhs' <- go rhs + ; op_id <- unwrap_op_tv op' + ; return (L l (HsOpTy noAnn NotPromoted lhs' op_id rhs')) } + where + unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id + unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) + go (L l e@(HsOverLit _ lit)) = + do { tylit <- case ol_val lit of + HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) + HsIsString _ s -> return $ HsStrTy NoSourceText s + HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l e@(HsLit _ lit)) = + do { tylit <- case lit of + HsChar _ c -> return $ HsCharTy NoSourceText c + HsString _ s -> return $ HsStrTy NoSourceText s + _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l (ExplicitTuple _ tup_args boxity)) + -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted + | isBoxed boxity + , Just es <- tupArgsPresent_maybe tup_args + = do { ts <- traverse go es + ; return (L l (HsExplicitTupleTy noExtField ts)) } + go (L l (ExplicitList _ es)) = + do { ts <- traverse go es + ; return (L l (HsExplicitListTy noExtField NotPromoted ts)) } + go (L l (ExprWithTySig _ e sig_ty)) = + do { t <- go e + ; sig_ki <- (unwrap_sig <=< unwrap_wc) sig_ty + ; return (L l (HsKindSig noAnn t sig_ki)) } + where + unwrap_sig :: LHsSigType GhcRn -> TcM (LHsType GhcRn) + unwrap_sig (L _ (HsSig _ HsOuterImplicit{hso_ximplicit=bndrs} body)) + | null bndrs = return body + | otherwise = illegal_implicit_tvs bndrs + unwrap_sig (L l (HsSig _ HsOuterExplicit{hso_bndrs=bndrs} body)) = + return $ L l (HsForAllTy noExtField (HsForAllInvis noAnn bndrs) body) + go (L l (HsPar _ _ e _)) = + do { t <- go e + ; return (L l (HsParTy noAnn t)) } + go (L l (HsUntypedSplice splice_result splice)) + | HsUntypedSpliceTop finalizers e <- splice_result + = do { t <- go (L l e) + ; let splice_result' = HsUntypedSpliceTop finalizers t + ; return (L l (HsSpliceTy splice_result' splice)) } + go (L l (HsUnboundVar _ rdr)) + | isUnderscore occ = return (L l (HsWildCardTy noExtField)) + | startsWithUnderscore occ = + -- See Note [Wildcards in the T2T translation] + do { wildcards_enabled <- xoptM LangExt.NamedWildCards + ; if wildcards_enabled + then illegal_wc rdr + else not_in_scope } + | otherwise = not_in_scope + where occ = occName rdr + not_in_scope = failWith $ mkTcRnNotInScope rdr NotInScope + go (L l (XExpr (HsExpanded orig _))) = + -- Use the original, user-written expression (before expansion). + -- Example. Say we have vfun :: forall a -> blah + -- and the call vfun (Maybe [1,2,3]) + -- expanded to vfun (Maybe (fromListN 3 [1,2,3])) + -- (This happens when OverloadedLists is enabled). + -- The expanded expression can't be promoted, as there is no type-level + -- equivalent of fromListN, so we must use the original. + go (L l orig) + go e = failWith $ TcRnIllformedTypeArgument e + + unwrap_wc :: HsWildCardBndrs GhcRn t -> TcM t + unwrap_wc (HsWC wcs t) + = do { mapM_ (illegal_wc . nameRdrName) wcs + ; return t } + + illegal_wc :: RdrName -> TcM t + illegal_wc rdr = failWith $ TcRnIllegalNamedWildcardInTypeArgument rdr + + illegal_implicit_tvs :: [Name] -> TcM t + illegal_implicit_tvs tvs + = do { mapM_ (addErr . TcRnIllegalImplicitTyVarInTypeArgument . nameRdrName) tvs + ; failM } + +{- Note [RequiredTypeArguments and the T2T mapping] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The "T2T-Mapping" section of GHC Proposal #281 introduces a term-to-type transformation +that comes into play when we typecheck function applications to required type arguments. +Say we have a function that expects a required type argument, vfun :: forall a -> ... +then it is possible to call it as follows: + + vfun (Maybe Int) + +The Maybe Int argument is parsed and renamed as a term. There is no syntactic marker +to tell GHC that it is actually a type argument. We only discover this by the time +we get to type checking, where we know that f's type has a visible forall at the front, +so we are expecting a type argument. More precisely, this happens in tcVDQ in GHC/Tc/Gen/App.hs: + + tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] + -> (ForAllTyBinder, TcType) -- Function type + -> LHsExpr GhcRn -- Argument type + -> TcM (TcType, TcType) + +What we want is a type to instantiate the forall-bound variable. But what we have is an HsExpr, +and we need to convert it to an HsType in order to reuse the same code paths as we use for +checking f @ty (see tc_inst_forall_arg). + + f (Maybe Int) + -- ^^^^^^^^^ + -- parsed and renamed as: HsApp (HsVar "Maybe") (HsVar "Int") :: HsExpr GhcRn + -- must be converted to: HsTyApp (HsTyVar "Maybe") (HsTyVar "Int") :: HsType GhcRn + +We do this using a helper function: + + expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) + +This conversion is in the TcM monad because +* It can fail, if the expression is not convertible to a type. + vfun [x | x <- xs] Can't convert list comprehension to a type + vfun (\x -> x) Can't convert a lambda to a type +* It needs to check for LangExt.NamedWildCards to generate an appropriate + error message for HsUnboundVar. + vfun _a Not in scope: ‘_a’ + (NamedWildCards disabled) + vfun _a Illegal named wildcard in a required type argument: ‘_a’ + (NamedWildCards enabled) + +Note [Wildcards in the T2T translation] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose f1 :: forall a b. blah + f2 :: forall a b -> blah + +Consider the terms + f1 @_ @(Either _ _) + f2 (type _) (type (Either _ _)) +Those `_` wildcards are type wildcards, each standing for a monotype. +All good. + +Now consider this, with -XNamedWildCards: + f1 @_a @(Either _a _a) + f2 (type _a) (type (Either _a _a)) +Those `_a` are "named wildcards", specified by the user manual like this: "All +occurrences of the same named wildcard within one type signature will unify to +the same type". Note "within one signature". So each type argument is considered +separately, and the examples mean the same as: + f1 @_a1 @(Either _a2 _a2) + f2 (type _a1) (type (Either _a2 _a2)) +The repeated `_a2` ensures that the two arguments of `Either` are the same type; +but there is no connection with `_a1`. (NB: `_a1` and `_a2` only scope within +their respective type, no further.) + +Now, consider the T2T translation for + f2 _ (Either _ _) +This is fine: the term wildcard `_` is translated to a type wildcard, so we get +the same as if we had written + f2 (type _) (type (Either _ _)) + +But what about /named/ wildcards? + f2 _a (Either _a _a) +Now we are in difficulties. The renamer looks for a /term/ variable `_a` in scope, +and won't find one. Even if it did, the three `_a`'s would not be renamed separately +as above. + +Conclusion: we treat a named wildcard in the T2T translation as an error. If you +want that, use a `(type ty)` argument instead. +-} tc_inst_forall_arg :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] -> (ForAllTyBinder, TcType) -- Function type @@ -890,7 +1093,7 @@ At a call site we may have calls looking like this fs True -- Specified: type argument omitted fs @Bool True -- Specified: type argument supplied fr (type Bool) True -- Required: type argument is compulsory, `type` qualifier used - fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted (NB: not implemented) + fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted At definition sites we may have type /patterns/ to abstract over type variables fi x = rhs -- Inferred: no type pattern @@ -953,8 +1156,8 @@ Syntax of applications in HsExpr Why the difference? Because we /also/ need to express these /nested/ uses of `type`: - g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) - g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) + g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t + g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t This nesting makes `type` rather different from `@`. Remember, the HsEmbTy mainly just switches namespace, and is subject to the term-to-type transformation. @@ -993,7 +1196,7 @@ rnExpr delegates renaming of type arguments to rnHsWcType if possible: f (type t) -- HsApp and HsEmbTy, t is renamed with rnHsWcType But what about: - f t -- HsApp, no HsEmbTy (NB. not implemented) + f t -- HsApp, no HsEmbTy We simply rename `t` as a term using a recursive call to rnExpr; in particular, the type of `f` does not affect name resolution (Lexical Scoping Principle). We will later convert `t` from a `HsExpr` to a `Type`, see "Typechecking type @@ -1057,7 +1260,7 @@ This is done by tcVTA (if Specified) and tcVDQ (if Required). tcVDQ unwraps the HsEmbTy and uses the type contained within it. Crucially, in tcVDQ we know that we are expecting a type argument. This means that we can support - f (Maybe Int) -- HsApp, no HsEmbTy (NB. not implemented) + f (Maybe Int) -- HsApp, no HsEmbTy The type argument (Maybe Int) is represented as an HsExpr, but tcVDQ can easily convert it to HsType. This conversion is called the "T2T-Mapping" in GHC Proposal #281. ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -369,6 +369,8 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnIllegalFieldPunning" = 44287 GhcDiagnosticCode "TcRnIllegalWildcardsInRecord" = 37132 GhcDiagnosticCode "TcRnIllegalWildcardInType" = 65507 + GhcDiagnosticCode "TcRnIllegalNamedWildcardInTypeArgument" = 93411 + GhcDiagnosticCode "TcRnIllegalImplicitTyVarInTypeArgument" = 80557 GhcDiagnosticCode "TcRnDuplicateFieldName" = 85524 GhcDiagnosticCode "TcRnIllegalViewPattern" = 22406 GhcDiagnosticCode "TcRnCharLiteralOutOfRange" = 17268 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -474,6 +474,12 @@ data GhcHint -} | SuggestBindTyVarOnLhs RdrName + {-| Suggest using an anonymous wildcard instead of a named wildcard -} + | SuggestAnonymousWildcard + + {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} + | SuggestExplicitQuantification RdrName + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -266,6 +266,11 @@ instance Outputable GhcHint where ppr_r = quotes $ ppr r SuggestBindTyVarOnLhs tv -> text "Bind" <+> quotes (ppr tv) <+> text "on the LHS of the type declaration" + SuggestAnonymousWildcard + -> text "Use an anonymous wildcard" <+> quotes (text "_") + SuggestExplicitQuantification tv + -> hsep [ text "Use an explicit", quotes (text "forall") + , text "to quantify over", quotes (ppr tv) ] perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -80,7 +80,7 @@ module GHC.Types.Name.Occurrence ( isVarOcc, isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc, isFieldOcc, fieldOcc_maybe, - parenSymOcc, startsWithUnderscore, + parenSymOcc, startsWithUnderscore, isUnderscore, isTcClsNameSpace, isTvNameSpace, isDataConNameSpace, isVarNameSpace, isValNameSpace, isFieldNameSpace, isTermVarOrFieldNameSpace, @@ -912,6 +912,9 @@ startsWithUnderscore occ = case unpackFS (occNameFS occ) of '_':_ -> True _ -> False +isUnderscore :: OccName -> Bool +isUnderscore occ = occNameFS occ == fsLit "_" + {- ************************************************************************ * * ===================================== docs/users_guide/exts/required_type_arguments.rst ===================================== @@ -107,7 +107,5 @@ indistinguishble from ordinary function arguments:: n = id_vdq Integer 42 In this example we pass ``Integer`` as opposed to ``(type Integer)``. -**This is not currently implemented**, but it demonstrates how -:extension:`RequiredTypeArguments` is not tied to the ``type`` syntax. -For this reason, using the ``type`` syntax requires enabling the -:extension:`ExplicitNamespaces` extension separately. \ No newline at end of file +This means that :extension:`RequiredTypeArguments` is not tied to the ``type`` +syntax, which belongs to :extension:`ExplicitNamespaces`. \ No newline at end of file ===================================== testsuite/tests/diagnostic-codes/codes.stdout ===================================== @@ -65,7 +65,6 @@ [GHC-85337] is untested (constructor = TcRnSpecialiseNotVisible) [GHC-91382] is untested (constructor = TcRnIllegalKindSignature) [GHC-72520] is untested (constructor = TcRnIgnoreSpecialisePragmaOnDefMethod) -[GHC-10969] is untested (constructor = TcRnTyThingUsedWrong) [GHC-61072] is untested (constructor = TcRnGADTDataContext) [GHC-16409] is untested (constructor = TcRnMultipleConForNewtype) [GHC-54478] is untested (constructor = TcRnRedundantSourceImport) ===================================== testsuite/tests/vdq-rta/should_compile/T22326_idv.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RequiredTypeArguments #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE NamedWildCards #-} module T22326_idv where @@ -38,4 +39,8 @@ idv_wild (type _) x = x -- Usage (using a wildcard) rBool' = idv (type _) True -rChar' = idv (type _) 'x' \ No newline at end of file +rChar' = idv (type _) 'x' + +-- Usage (using named wildcards) +rMaybeX = idv (type (Maybe _a)) Nothing +rEitherCharChar = idv (type (Either _a _a)) (Left 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_basic.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Overloaded string literals checked in T23738_overlit. +{-# LANGUAGE NoOverloadedStrings #-} + +module T23738_basic where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2])) + {- term syntax: -} (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_nested.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_nested where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + (type (Either Int Bool)) + (Either (type Int) (type Bool)) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Non-overloaded string literals checked in T23738_basic. +{-# LANGUAGE OverloadedStrings #-} + +-- Non-overloaded lists are checked in T23738_basic. +{-# LANGUAGE OverloadedLists #-} + +module T23738_overlit where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '("Hello", [1, 2, 3])) + {- term syntax: -} ("Hello", [1, 2, 3]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_sigforall where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +r1 :: () +r1 = + checkEq + {- type syntax: -} (type (Left :: forall a b. a -> Either a b)) + {- term syntax: -} (Left :: forall a b. a -> Either a b) + +r2 :: () +r2 = + checkEq + {- type syntax: -} (type (Left :: forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall a. forall b. a -> Either a b) + +r3 :: () +r3 = + checkEq + {- type syntax: -} (type (Left :: forall. forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall. forall a. forall b. a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_th.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TemplateHaskell #-} + +module T23738_th where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type $[t| '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2]) |]) + {- term syntax: -} $[e| (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) |] \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} + +module T23738_tyvar where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: forall k. forall (f :: k -> Type) (t :: k) -> () +result (type f) (type t) = + checkEq + {- type syntax: -} (type (f t)) + {- term syntax: -} (f t) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool = idv _ True +rChar = idv _ 'x' + +rMaybeBool = idv (Maybe _) (Just True) +rMaybeChar = idv (Maybe _) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -10,6 +10,13 @@ test('T22326_sig', normal, compile, ['']) test('T17792_vdq', normal, compile, ['']) test('T14158_vdq', normal, compile, ['']) test('WithSpineVDQ_LintErr', normal, compile, ['']) +test('T23738_basic', normal, compile, ['']) +test('T23738_tyvar', normal, compile, ['']) +test('T23738_overlit', normal, compile, ['']) +test('T23738_nested', normal, compile, ['']) +test('T23738_wild', normal, compile, ['']) +test('T23738_sigforall', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) -test('T22326_th_pprint1', req_th, compile, ['']) \ No newline at end of file +test('T22326_th_pprint1', req_th, compile, ['']) +test('T23738_th', req_th, compile, ['']) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr ===================================== @@ -1,6 +1,5 @@ T22326_fail_raw_arg.hs:9:5: error: [GHC-29092] • Ill-formed type argument: \ _ -> _ - Expected a type expression introduced with the ‘type’ keyword. • In the expression: f (\ _ -> _) In an equation for ‘x’: x = f (\ _ -> _) ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_fail_implicit_tv where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +rNothing = vfun (Nothing :: Maybe a) +rLeft = vfun (Left :: a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr ===================================== @@ -0,0 +1,21 @@ + +T23738_fail_implicit_tv.hs:10:12: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Nothing :: Maybe a) + In an equation for ‘rNothing’: rNothing = vfun (Nothing :: Maybe a) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘b’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘b’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE TypeAbstractions #-} + +module T23738_fail_var where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +f :: Int -> () +f a = vfun a \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr ===================================== @@ -0,0 +1,6 @@ + +T23738_fail_var.hs:11:12: error: [GHC-10969] + • Local identifier ‘a’ used as a type + • In the type ‘a’ + In the expression: vfun a + In an equation for ‘f’: f a = vfun a ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_fail_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool' = idv _w True +rChar' = idv _w 'x' + +rMaybeBool' = idv (Maybe _w) (Just True) +rMaybeChar' = idv (Maybe _w) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr ===================================== @@ -0,0 +1,26 @@ + +T23738_fail_wild.hs:10:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w True + In an equation for ‘rBool'’: rBool' = idv _w True + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:11:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w 'x' + In an equation for ‘rChar'’: rChar' = idv _w 'x' + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:13:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just True) + In an equation for ‘rMaybeBool'’: + rMaybeBool' = idv (Maybe _w) (Just True) + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:14:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just 'x') + In an equation for ‘rMaybeChar'’: + rMaybeChar' = idv (Maybe _w) (Just 'x') + Suggested fix: Use an anonymous wildcard ‘_’ ===================================== testsuite/tests/vdq-rta/should_fail/all.T ===================================== @@ -11,4 +11,7 @@ test('T22326_fail_caseof', normal, compile_fail, ['']) test('T22326_fail_ado', normal, compile_fail, ['']) test('T22326_fail_n_args', normal, compile_fail, ['']) test('T22326_fail_patsyn', normal, compile_fail, ['']) -test('T22326_fail_match', normal, compile_fail, ['']) \ No newline at end of file +test('T22326_fail_match', normal, compile_fail, ['']) +test('T23738_fail_wild', normal, compile_fail, ['']) +test('T23738_fail_implicit_tv', normal, compile_fail, ['']) +test('T23738_fail_var', normal, compile_fail, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54744419246007795d7572443ff19d43a4001ece -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/54744419246007795d7572443ff19d43a4001ece You're receiving 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 Nov 1 22:23:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 18:23:54 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: More robust checking for DataKinds Message-ID: <6542cffa8a7e1_27efe95be885488567@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 428a3452 by Alan Zimmerman at 2023-11-01T18:23:48-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - a0610f8a by Rodrigo Mesquita at 2023-11-01T18:23:49-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - c529cef2 by Matthew Pickering at 2023-11-01T18:23:50-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 0e8e35a8 by Matthew Pickering at 2023-11-01T18:23:50-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - cbad13e9 by Matthew Pickering at 2023-11-01T18:23:50-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 26 changed files: - .gitlab-ci.yml - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.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/Errors/Types/PromotionErr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/using-warnings.rst - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/plan-9_4_1.json - hadrian/bootstrap/plan-9_4_2.json - hadrian/bootstrap/plan-9_4_3.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/748c90e29f0ca5d639ab03030ccf4e6d3a059a2d...cbad13e90733dd0f3a254b7606e5e2b13ac7f2b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/748c90e29f0ca5d639ab03030ccf4e6d3a059a2d...cbad13e90733dd0f3a254b7606e5e2b13ac7f2b6 You're receiving 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 Nov 2 02:24:22 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 22:24:22 -0400 Subject: [Git][ghc/ghc][master] EPA: Use full range for Anchor Message-ID: <654308561fc6e_27efe9c02c6081061c6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/ThToHs.hs - testsuite/tests/driver/recompChangedPackage/q/q.cabal - testsuite/tests/ghc-api/exactprint/AddDecl1.expected.hs - 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/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/parser/should_compile/T23315/T23315.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81fb8885819c63e926376019b14cf994e88a167c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81fb8885819c63e926376019b14cf994e88a167c You're receiving 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 Nov 2 02:24:55 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 22:24:55 -0400 Subject: [Git][ghc/ghc][master] Fix in docs regarding SSymbol, SNat, SChar (#24119) Message-ID: <65430877b03ca_27efe9bec023810952c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 2 changed files: - libraries/base/src/GHC/TypeLits.hs - libraries/base/src/GHC/TypeNats.hs Changes: ===================================== libraries/base/src/GHC/TypeLits.hs ===================================== @@ -358,7 +358,7 @@ type role SSymbol nominal -- -- @ -- f :: 'SSymbol' s -> .. --- f SSymbol = {- SSymbol s in scope -} +-- f SSymbol = {- KnownSymbol s in scope -} -- @ -- -- @since 4.18.0.0 @@ -461,7 +461,7 @@ type role SChar nominal -- -- @ -- f :: 'SChar' c -> .. --- f SChar = {- SChar c in scope -} +-- f SChar = {- KnownChar c in scope -} -- @ -- -- @since 4.18.0.0 ===================================== libraries/base/src/GHC/TypeNats.hs ===================================== @@ -362,7 +362,7 @@ type role SNat nominal -- -- @ -- f :: 'SNat' n -> .. --- f SNat = {- SNat n in scope -} +-- f SNat = {- KnownNat n in scope -} -- @ -- -- @since 4.18.0.0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03e8251119fda652bd25c989d449f966419c82d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03e8251119fda652bd25c989d449f966419c82d6 You're receiving 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 Nov 2 02:25:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 01 Nov 2023 22:25:54 -0400 Subject: [Git][ghc/ghc][master] 3 commits: hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Message-ID: <654308b27b1d2_27efe9bec0238112531@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 9 changed files: - .gitlab-ci.yml - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/plan-9_4_1.json - hadrian/bootstrap/plan-9_4_2.json - hadrian/bootstrap/plan-9_4_3.json - hadrian/bootstrap/plan-9_4_4.json - hadrian/bootstrap/plan-9_4_5.json - + hadrian/bootstrap/plan-9_4_6.json - + hadrian/bootstrap/plan-9_4_7.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03e8251119fda652bd25c989d449f966419c82d6...ef3d20f83499cf129b1cacac07906b8d6188fc17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03e8251119fda652bd25c989d449f966419c82d6...ef3d20f83499cf129b1cacac07906b8d6188fc17 You're receiving 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 Nov 2 08:30:37 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 02 Nov 2023 04:30:37 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/upload.sh-cleanups Message-ID: <65435e2d3247a_27efe914c9e6b8117568@gitlab.mail> Bryan R deleted branch wip/upload.sh-cleanups at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Nov 2 17:43:22 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 02 Nov 2023 13:43:22 -0400 Subject: [Git][ghc/ghc][wip/spj-unf-size] More improvements Message-ID: <6543dfba33292_27efe92187d2e81812a7@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 35e4e67f by Simon Peyton Jones at 2023-11-02T17:42:00+00:00 More improvements Mainly doing the result-discounts as before. Some skirmishing about dealing with knownCon.. more to come - - - - - 5 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -1401,10 +1401,12 @@ type Size = Int type Discount = Int data ExprTree - = ExprTree { et_wc_tot :: {-# UNPACK #-} !Size -- ^ Worst-case size of whole tree - , et_size :: {-# UNPACK #-} !Size -- ^ Size of the bit apart from et_cases - , et_ret :: {-# UNPACK #-} !Discount -- ^ Discount when result is scrutinised - , et_cases :: Bag CaseTree + = ExprTree { et_wc_tot :: {-# UNPACK #-} !Size -- ^ Total worst-case size of whole tree + , et_ret :: {-# UNPACK #-} !Discount -- ^ Total discount when result is scrutinised + -- Both et_wc_tot and et_rec /include/ et_cases + + , et_size :: {-# UNPACK #-} !Size -- ^ Size of the tree /apart from/ et_cases + , et_cases :: Bag CaseTree -- ^ Case exprsions and discounts } data CaseTree ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -931,9 +931,9 @@ refineFromInScope :: HasDebugCallStack => SimplMode -> InScopeSet -> Var -> Var refineFromInScope mode in_scope v | isLocalId v = case lookupInScope in_scope v of Just v' -> v' - Nothing -> -- pprPanic "refineFromInScope" (ppr in_scope $$ ppr v) - pprTrace "refineFromInScope" - (ppr (sm_module mode) <+> ppr v) v + Nothing -> pprPanic "refineFromInScope" (ppr (sm_module mode) $$ ppr v $$ ppr in_scope) + -- pprTrace "refineFromInScope" + -- (ppr (sm_module mode) <+> ppr v) v -- c.f #19074 for a subtle place where this went wrong | otherwise = v ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -597,11 +597,21 @@ exprSummary env e = go env e [] go env (Tick _ e) as = go env e as go env (App f a) as | isValArg a = go env f (a:as) | otherwise = go env f as - go env (Let b e) as = go env' e as - where - env' = env `addNewInScopeIds` bindersOf b - go env (Var v) as + -- Look through let-expressions + go env (Let b e) as + | let env' = env `addNewInScopeIds` bindersOf b + = go env' e as + +{- + -- Look through single-branch case-expressions; like lets + go env (Case _ b _ alts) as + | [Alt _ bs e] <- alts + , let env' = env `addNewInScopeIds` (b:bs) + = go env' e as +-} + + go env (Var v) as = -- Simplify.Env.substId Looks up in substitution -- /and/ refines from the InScopeset case substId env v of ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1336,6 +1336,7 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- CPR'd workers getting inlined back into their wrappers, | idArity fun == 0 , Just rhs <- expandUnfolding_maybe unfolding +-- If `fun` is in the in-scope set then the free var of its RHS should be too , let in_scope' = extend_in_scope (exprFreeVars rhs) = go (Left in_scope') floats rhs cont ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -618,7 +618,13 @@ exprTree opts args expr -- When this scrutinee has structure, we expect to eliminate the case go_alts remaining_case_depth vs b alts) where - rcd1 = remaining_case_depth - 1 + -- Decremement remaining case depth when going inside + -- a case with more than one alternative. + -- Don't do so for single-alt cases, becuase they don't give rise + -- to exponential blow-up, and it's very common to have deep nests + -- of case x of (a,b) -> case a of I# a' -> ... + rcd1 | isSingleton alts = remaining_case_depth + | otherwise = remaining_case_depth - 1 alt_alt_tree :: Id -> Alt Var -> Maybe AltTree alt_alt_tree v (Alt con bs rhs) @@ -1054,7 +1060,8 @@ metAddAlt bOMB_OUT_SIZE (Just et1) (Just et2) else Just (ExprTree { et_wc_tot = t12 , et_size = n1 + n2 , et_cases = c1 `unionBags` c2 - , et_ret = ret1 + ret2 }) + , et_ret = ret1 + ret2 -- See Note [Result discount for case alternatives] + }) -- | The "expression tree"; an abstraction of the RHS of the function @@ -1069,11 +1076,13 @@ etCaseOf :: Size -> Id -> Id -> [AltTree] -> Maybe ExprTree -- is a variable) but charge for each alternative (included in `altTreesSize`) etCaseOf bOMB_OUT_SIZE scrut case_bndr alts | tot >= bOMB_OUT_SIZE = Nothing - | otherwise = Just (ExprTree { et_wc_tot = tot, et_size = 0, et_ret = 0 + | otherwise = Just (ExprTree { et_wc_tot = tot, et_ret = ret + , et_size = 0 , et_cases = unitBag case_tree }) where case_tree = CaseOf scrut case_bndr alts tot = altTreesSize alts + ret = altTreesDiscount alts altTreesSize :: [AltTree] -> Size -- Total worst-case size of a [AltTree], including the per-alternative cost of altSize @@ -1082,9 +1091,25 @@ altTreesSize alts = foldl' add_alt 0 alts add_alt n (AltTree _ _ (ExprTree { et_wc_tot = alt_tot })) = n + alt_tot + altSize +altTreesDiscount :: [AltTree] -> Discount +-- See Note [Result discount for case alternatives] +altTreesDiscount alts = foldl' add_alt 0 alts + where + add_alt n (AltTree _ _ (ExprTree { et_ret = ret })) = n + ret + etScrutOf :: Id -> Discount -> ExprTree etScrutOf v d = etZero { et_cases = unitBag (ScrutOf v d) } +{- Note [Result discount for case alternatives] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When adding the size of alternatives, we *add* the result discounts +too, rather than take the *maximum*. For a multi-branch case, this +gives a discount for each branch that returns a constructor, making us +keener to inline. I did try using 'max' instead, but it makes nofib +'rewrite' and 'puzzle' allocate significantly more, and didn't make +binary sizes shrink significantly either. +-} + {- ********************************************************************* * * From ExprTree to Size @@ -1128,6 +1153,7 @@ exprTreeSize !ic (ExprTree { et_size = size , et_cases = cases , et_ret = ret_discount }) = foldr ((+) . caseTreeSize (ic { ic_want_res = False })) + -- False: all result discount is at the top; ignore inner ones discounted_size cases where discounted_size | ic_want_res ic = size - ret_discount View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35e4e67fd287d7a42e204b97b6390b0b7098e70f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35e4e67fd287d7a42e204b97b6390b0b7098e70f You're receiving 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 Nov 2 18:31:47 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 02 Nov 2023 14:31:47 -0400 Subject: [Git][ghc/ghc][wip/T23576] Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6543eb13d85f2_27efe922aec3981872df@gitlab.mail> Andreas Klebinger pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC Commits: abe72e6f by Jaro Reinders at 2023-11-02T19:11:26+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 8 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Utils/Unique.hs - testsuite/tests/cmm/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -523,7 +523,6 @@ assignReg_I64Code (CmmLocal dst) valueTree = do assignReg_I64Code _ _ = panic "assignReg_I64Code(i386): invalid lvalue" - iselExpr64 :: HasDebugCallStack => CmmExpr -> NatM (RegCode64 InstrBlock) iselExpr64 (CmmLit (CmmInt i _)) = do Reg64 rhi rlo <- getNewReg64 @@ -550,7 +549,6 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do let Reg64 hi lo = localReg64 local_reg return (RegCode64 nilOL hi lo) --- we handle addition, but rather badly iselExpr64 (CmmMachOp (MO_Add _) [e1, CmmLit (CmmInt i _)]) = do RegCode64 code1 r1hi r1lo <- iselExpr64 e1 Reg64 rhi rlo <- getNewReg64 @@ -590,11 +588,31 @@ iselExpr64 (CmmMachOp (MO_Sub _) [e1,e2]) = do SBB II32 (OpReg r2hi) (OpReg rhi) ] return (RegCode64 code rhi rlo) -iselExpr64 (CmmMachOp (MO_UU_Conv _ W64) [expr]) = do +iselExpr64 (CmmMachOp (MO_UU_Conv W32 W64) [expr]) = do code <- getAnyReg expr Reg64 r_dst_hi r_dst_lo <- getNewReg64 return $ RegCode64 (code r_dst_lo `snocOL` - MOV II32 (OpImm (ImmInt 0)) (OpReg r_dst_hi)) + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi)) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W16 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II16 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W8 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II8 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) r_dst_hi r_dst_lo @@ -609,11 +627,208 @@ iselExpr64 (CmmMachOp (MO_SS_Conv W32 W64) [expr]) = do r_dst_hi r_dst_lo +iselExpr64 (CmmMachOp (MO_SS_Conv W16 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II16 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_SS_Conv W8 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II8 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_S_Neg _) [expr]) = do + RegCode64 code rhi rlo <- iselExpr64 expr + Reg64 rohi rolo <- getNewReg64 + let + ocode = code `appOL` + toOL [ MOV II32 (OpReg rlo) (OpReg rolo), + XOR II32 (OpReg rohi) (OpReg rohi), + NEGI II32 (OpReg rolo), + SBB II32 (OpReg rhi) (OpReg rohi) ] + return (RegCode64 ocode rohi rolo) + +-- To multiply two 64-bit numbers we use the following decomposition (in C notation): +-- +-- ((r1hi << 32) + r1lo) * ((r2hi << 32) + r2lo) +-- = ((r2lo * r1hi) << 32) +-- + ((r1lo * r2hi) << 32) +-- + r1lo * r2lo +-- +-- Note that @(r1hi * r2hi) << 64@ can be dropped because it overflows completely. + +iselExpr64 (CmmMachOp (MO_Mul _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + tmp <- getNewRegNat II32 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg eax), + MOV II32 (OpReg r2lo) (OpReg tmp), + MOV II32 (OpReg r1hi) (OpReg rhi), + IMUL II32 (OpReg tmp) (OpReg rhi), + MOV II32 (OpReg r2hi) (OpReg rlo), + IMUL II32 (OpReg eax) (OpReg rlo), + ADD II32 (OpReg rlo) (OpReg rhi), + MUL2 II32 (OpReg tmp), + ADD II32 (OpReg edx) (OpReg rhi), + MOV II32 (OpReg eax) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_S_MulMayOflo W64) [e1,e2]) = do + -- Performance sensitive users won't use 32 bit so let's keep it simple: + -- We always return a (usually false) positive. + Reg64 rhi rlo <- getNewReg64 + let code = toOL [ + MOV II32 (OpImm (ImmInt 1)) (OpReg rhi), + MOV II32 (OpImm (ImmInt 1)) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + + +-- To shift a 64-bit number to the left we use the SHLD and SHL instructions. +-- We use SHLD to shift the bits in @rhi@ to the left while copying +-- high bits from @rlo@ to fill the new space in the low bits of @rhi at . +-- That leaves @rlo@ unchanged, so we use SHL to shift the bits of @rlo@ left. +-- However, both these instructions only use the lowest 5 bits from %cl to do +-- their shifting. So if the sixth bit (0x32) is set then we additionally move +-- the contents of @rlo@ to @rhi@ and clear @rlo at . + +iselExpr64 (CmmMachOp (MO_Shl _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + code2 <- getAnyReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 ecx `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + SHLD II32 (OpReg ecx) (OpReg rlo) (OpReg rhi), + SHL II32 (OpReg ecx) (OpReg rlo), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rlo) (OpReg rhi), + XOR II32 (OpReg rlo) (OpReg rlo), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to above, however now we're shifting to the right +-- and we're doing a signed shift which means that @rhi@ needs +-- to be set to either 0 if @rhi@ is positive or 0xffffffff otherwise, +-- and if the sixth bit of %cl is set (so the shift amount is more than 32). +-- To accomplish that we shift @rhi@ by 31. + +iselExpr64 (CmmMachOp (MO_S_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SAR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + SAR II32 (OpImm (ImmInt 31)) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to the above. + +iselExpr64 (CmmMachOp (MO_U_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SHR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + XOR II32 (OpReg rhi) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_And _) [e1,e2]) = iselExpr64ParallelBin AND e1 e2 +iselExpr64 (CmmMachOp (MO_Or _) [e1,e2]) = iselExpr64ParallelBin OR e1 e2 +iselExpr64 (CmmMachOp (MO_Xor _) [e1,e2]) = iselExpr64ParallelBin XOR e1 e2 + +iselExpr64 (CmmMachOp (MO_Not _) [e1]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + NOT II32 (OpReg rlo), + NOT II32 (OpReg rhi) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmRegOff r i) = iselExpr64 (mangleIndexTree r i) + iselExpr64 expr = do platform <- getPlatform - pprPanic "iselExpr64(i386)" (pdoc platform expr) + pprPanic "iselExpr64(i386)" (pdoc platform expr $+$ text (show expr)) +iselExpr64ParallelBin :: (Format -> Operand -> Operand -> Instr) + -> CmmExpr -> CmmExpr -> NatM (RegCode64 (OrdList Instr)) +iselExpr64ParallelBin op e1 e2 = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + op II32 (OpReg r2lo) (OpReg rlo), + op II32 (OpReg r2hi) (OpReg rhi) + ] + return (RegCode64 code rhi rlo) -------------------------------------------------------------------------------- getRegister :: CmmExpr -> NatM Register @@ -675,6 +890,18 @@ getRegister' _ is32Bit (CmmMachOp (MO_SS_Conv W64 W32) [x]) RegCode64 code _rhi rlo <- iselExpr64 x return $ Fixed II32 rlo code +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W8) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II8 + return $ Fixed II8 ro (code `appOL` toOL [ MOVZxL II8 (OpReg rlo) (OpReg ro) ]) + +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W16) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II16 + return $ Fixed II16 ro (code `appOL` toOL [ MOVZxL II16 (OpReg rlo) (OpReg ro) ]) + getRegister' _ _ (CmmLit lit@(CmmFloat f w)) = float_const_sse2 where float_const_sse2 @@ -1657,6 +1884,27 @@ machOpToCond mo = case mo of MO_U_Le _ -> LEU _other -> pprPanic "machOpToCond" (pprMachOp mo) +{- Note [64-bit integer comparisons on 32-bit] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + When doing these comparisons there are 2 kinds of + comparisons. + + * Comparison for equality (or lack thereof) + + We use xor to check if high/low bits are + equal. Then combine the results using or. + + * Other comparisons: + + We first compare the low registers + and use a subtraction with borrow to compare the high registers. + + For signed numbers the condition is determined by + the sign and overflow flags agreeing or not + and for unsigned numbers the condition is the carry flag. + +-} -- @cond(Int|Flt)Code@: Turn a boolean expression into a condition, to be -- passed back up the tree. @@ -1667,6 +1915,68 @@ condIntCode cond x y = do platform <- getPlatform condIntCode' :: Platform -> Cond -> CmmExpr -> CmmExpr -> NatM CondCode +-- 64-bit integer comparisons on 32-bit +-- See Note [64-bit integer comparisons on 32-bit] +condIntCode' platform cond x y + | target32Bit platform && isWord64 (cmmExprType platform x) = do + + RegCode64 code1 r1hi r1lo <- iselExpr64 x + RegCode64 code2 r2hi r2lo <- iselExpr64 y + + -- we mustn't clobber r1/r2 so we use temporaries + tmp1 <- getNewRegNat II32 + tmp2 <- getNewRegNat II32 + + let (cond', cmpCode) = intComparison cond r1hi r1lo r2hi r2lo tmp1 tmp2 + return $ CondCode False cond' (code1 `appOL` code2 `appOL` cmpCode) + + where + intComparison cond r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = + case cond of + -- These don't occur as argument of condIntCode' + ALWAYS -> panic "impossible" + NEG -> panic "impossible" + POS -> panic "impossible" + CARRY -> panic "impossible" + OFLO -> panic "impossible" + PARITY -> panic "impossible" + NOTPARITY -> panic "impossible" + -- Special case #1 x == y and x != y + EQQ -> (EQQ, cmpExact) + NE -> (NE, cmpExact) + -- [x >= y] + GE -> (GE, cmpGE) + GEU -> (GEU, cmpGE) + -- [x > y] + GTT -> (LTT, cmpLE) + GU -> (LU, cmpLE) + -- [x <= y] + LE -> (GE, cmpLE) + LEU -> (GEU, cmpLE) + -- [x < y] + LTT -> (LTT, cmpGE) + LU -> (LU, cmpGE) + where + cmpExact :: OrdList Instr + cmpExact = + toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , MOV II32 (OpReg r1_lo) (OpReg tmp2) + , XOR II32 (OpReg r2_hi) (OpReg tmp1) + , XOR II32 (OpReg r2_lo) (OpReg tmp2) + , OR II32 (OpReg tmp1) (OpReg tmp2) + ] + cmpGE = toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , CMP II32 (OpReg r2_lo) (OpReg r1_lo) + , SBB II32 (OpReg r2_hi) (OpReg tmp1) + ] + cmpLE = toOL + [ MOV II32 (OpReg r2_hi) (OpReg tmp1) + , CMP II32 (OpReg r1_lo) (OpReg r2_lo) + , SBB II32 (OpReg r1_hi) (OpReg tmp1) + ] + -- memory vs immediate condIntCode' platform cond (CmmLoad x pk _) (CmmLit lit) | is32BitLit platform lit = do @@ -1881,36 +2191,6 @@ I386: First, we have to ensure that the condition codes are set according to the supplied comparison operation. -} -{- Note [64-bit integer comparisons on 32-bit] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - When doing these comparisons there are 2 kinds of - comparisons. - - * Comparison for equality (or lack thereof) - - We use xor to check if high/low bits are - equal. Then combine the results using or and - perform a single conditional jump based on the - result. - - * Other comparisons: - - We map all other comparisons to the >= operation. - Why? Because it's easy to encode it with a single - conditional jump. - - We do this by first computing [r1_lo - r2_lo] - and use the carry flag to compute - [r1_high - r2_high - CF]. - - At which point if r1 >= r2 then the result will be - positive. Otherwise negative so we can branch on this - condition. - --} - - genCondBranch :: BlockId -- the source of the jump -> BlockId -- the true branch target @@ -1926,67 +2206,6 @@ genCondBranch bid id false expr = do genCondBranch' :: Bool -> BlockId -> BlockId -> BlockId -> CmmExpr -> NatM InstrBlock --- 64-bit integer comparisons on 32-bit --- See Note [64-bit integer comparisons on 32-bit] -genCondBranch' is32Bit _bid true false (CmmMachOp mop [e1,e2]) - | is32Bit, Just W64 <- maybeIntComparison mop = do - - RegCode64 code1 r1hi r1lo <- iselExpr64 e1 - RegCode64 code2 r2hi r2lo <- iselExpr64 e2 - let cond = machOpToCond mop :: Cond - - -- we mustn't clobber r1/r2 so we use temporaries - tmp1 <- getNewRegNat II32 - tmp2 <- getNewRegNat II32 - - let cmpCode = intComparison cond true false r1hi r1lo r2hi r2lo tmp1 tmp2 - return $ code1 `appOL` code2 `appOL` cmpCode - - where - intComparison cond true false r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = - case cond of - -- Impossible results of machOpToCond - ALWAYS -> panic "impossible" - NEG -> panic "impossible" - POS -> panic "impossible" - CARRY -> panic "impossible" - OFLO -> panic "impossible" - PARITY -> panic "impossible" - NOTPARITY -> panic "impossible" - -- Special case #1 x == y and x != y - EQQ -> cmpExact - NE -> cmpExact - -- [x >= y] - GE -> cmpGE - GEU -> cmpGE - -- [x > y] <==> ![y >= x] - GTT -> intComparison GE false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - GU -> intComparison GEU false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x <= y] <==> [y >= x] - LE -> intComparison GE true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - LEU -> intComparison GEU true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x < y] <==> ![x >= x] - LTT -> intComparison GE false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - LU -> intComparison GEU false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - where - cmpExact :: OrdList Instr - cmpExact = - toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , MOV II32 (OpReg r1_lo) (OpReg tmp2) - , XOR II32 (OpReg r2_hi) (OpReg tmp1) - , XOR II32 (OpReg r2_lo) (OpReg tmp2) - , OR II32 (OpReg tmp1) (OpReg tmp2) - , JXX cond true - , JXX ALWAYS false - ] - cmpGE = toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , CMP II32 (OpReg r2_lo) (OpReg r1_lo) - , SBB II32 (OpReg r2_hi) (OpReg tmp1) - , JXX cond true - , JXX ALWAYS false ] - genCondBranch' _ bid id false bool = do CondCode is_float cond cond_code <- getCondCode bool use_sse2 <- sse2Enabled ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -249,6 +249,8 @@ data Instr | SHL Format Operand{-amount-} Operand | SAR Format Operand{-amount-} Operand | SHR Format Operand{-amount-} Operand + | SHRD Format Operand{-amount-} Operand Operand + | SHLD Format Operand{-amount-} Operand Operand | BT Format Imm Operand | NOP @@ -399,6 +401,8 @@ regUsageOfInstr platform instr SHL _ imm dst -> usageRM imm dst SAR _ imm dst -> usageRM imm dst SHR _ imm dst -> usageRM imm dst + SHLD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 + SHRD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 BT _ _ src -> mkRUR (use_R src []) PUSH _ op -> mkRUR (use_R op []) @@ -568,6 +572,8 @@ patchRegsOfInstr instr env SHL fmt imm dst -> patch1 (SHL fmt imm) dst SAR fmt imm dst -> patch1 (SAR fmt imm) dst SHR fmt imm dst -> patch1 (SHR fmt imm) dst + SHLD fmt imm dst1 dst2 -> patch2 (SHLD fmt imm) dst1 dst2 + SHRD fmt imm dst1 dst2 -> patch2 (SHRD fmt imm) dst1 dst2 BT fmt imm src -> patch1 (BT fmt imm) src TEST fmt src dst -> patch2 (TEST fmt) src dst CMP fmt src dst -> patch2 (CMP fmt) src dst ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -732,6 +732,12 @@ pprInstr platform i = case i of SHR format src dst -> pprShift (text "shr") format src dst + SHLD format src dst1 dst2 + -> pprShift2 (text "shld") format src dst1 dst2 + + SHRD format src dst1 dst2 + -> pprShift2 (text "shrd") format src dst1 dst2 + BT format imm src -> pprFormatImmOp (text "bt") format imm src @@ -1070,6 +1076,17 @@ pprInstr platform i = case i of pprOperand platform format dest ] + pprShift2 :: Line doc -> Format -> Operand -> Operand -> Operand -> doc + pprShift2 name format src dest1 dest2 + = line $ hcat [ + pprMnemonic name format, + pprOperand platform II8 src, -- src is 8-bit sized + comma, + pprOperand platform format dest1, + comma, + pprOperand platform format dest2 + ] + pprFormatOpOpCoerce :: Line doc -> Format -> Format -> Operand -> Operand -> doc pprFormatOpOpCoerce name format1 format2 op1 op2 ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -53,7 +53,8 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmDoBoundsCheck = gopt Opt_DoBoundsChecking dflags , stgToCmmDoTagCheck = gopt Opt_DoTagInferenceChecks dflags -- backend flags - , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 + , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 || platformArch platform == ArchX86 + , stgToCmmAllowBigQuot = not ncg || platformArch platform == ArchWasm32 , stgToCmmAllowQuotRemInstr = ncg && (x86ish || ppc) , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm ===================================== compiler/GHC/StgToCmm/Config.hs ===================================== @@ -65,6 +65,7 @@ data StgToCmmConfig = StgToCmmConfig , stgToCmmDoTagCheck :: !Bool -- ^ Verify tag inference predictions. ------------------------------ Backend Flags ---------------------------------- , stgToCmmAllowBigArith :: !Bool -- ^ Allowed to emit larger than native size arithmetic (only LLVM and C backends) + , stgToCmmAllowBigQuot :: !Bool -- ^ Allowed to emit larger than native size division operations , stgToCmmAllowQuotRemInstr :: !Bool -- ^ Allowed to generate QuotRem instructions , stgToCmmAllowQuotRem2 :: !Bool -- ^ Allowed to generate QuotRem , stgToCmmAllowExtendedAddSubInstrs :: !Bool -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc. ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1682,6 +1682,13 @@ emitPrimOp cfg primop = let stmt = mkAssign (CmmLocal res) (CmmMachOp mop args) emit stmt + isQuottishOp :: CallishMachOp -> Bool + isQuottishOp MO_I64_Quot = True + isQuottishOp MO_I64_Rem = True + isQuottishOp MO_W64_Quot = True + isQuottishOp MO_W64_Rem = True + isQuottishOp _ = False + opTranslate64 :: [CmmExpr] -> (Width -> MachOp) @@ -1690,7 +1697,8 @@ emitPrimOp cfg primop = opTranslate64 args mkMop callish = case platformWordSize platform of -- LLVM and C `can handle larger than native size arithmetic natively. - _ | stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + _ | not (isQuottishOp callish), stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + | isQuottishOp callish, stgToCmmAllowBigQuot cfg -> opTranslate args $ mkMop W64 PW4 -> opCallish args callish PW8 -> opTranslate args $ mkMop W64 ===================================== compiler/GHC/Utils/Unique.hs ===================================== @@ -2,12 +2,12 @@ {- Work around #23537 -On 32 bit systems, GHC's codegen around 64 bit numbers is not quite -complete. This led to panics mentioning missing cases in iselExpr64. -Now that GHC uses Word64 for its uniques, these panics have started -popping up whenever a unique is compared to many other uniques in one -function. As a workaround we use these two functions which are not -inlined on 32 bit systems, thus preventing the panics. +On 32 bit systems, GHC's codegen around 64 bit numbers used to be incomplete +before GHC 9.10. This led to panics mentioning missing cases in iselExpr64. +Now that GHC uses Word64 for its uniques, these panics have started popping up +whenever a unique is compared to many other uniques in one function. As a +workaround we use these two functions which are not inlined, on 32 bit systems +and if compiled with versions before GHC 9.9, thus preventing the panics. -} module GHC.Utils.Unique (sameUnique, anyOfUnique) where @@ -18,7 +18,7 @@ import GHC.Prelude.Basic (Bool, Eq((==)), Foldable(elem)) import GHC.Types.Unique (Unique, Uniquable (getUnique)) -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE sameUnique #-} #else {-# INLINE sameUnique #-} @@ -26,7 +26,7 @@ import GHC.Types.Unique (Unique, Uniquable (getUnique)) sameUnique :: Uniquable a => a -> a -> Bool sameUnique x y = getUnique x == getUnique y -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE anyOfUnique #-} #else {-# INLINE anyOfUnique #-} ===================================== testsuite/tests/cmm/should_run/all.T ===================================== @@ -27,7 +27,6 @@ test('ByteSwitch', test('T22871', [ extra_run_opts('"' + config.libdir + '"') , req_cmm - , when(arch('i386'), skip) # x86 NCG panics with "iselExpr64(i386)" ], multi_compile_and_run, ['T22871', [('T22871_cmm.cmm', '')], '']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abe72e6f0f769f97a8e4e89f7d0b2303a6c60286 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abe72e6f0f769f97a8e4e89f7d0b2303a6c60286 You're receiving 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 Nov 2 18:47:24 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 02 Nov 2023 14:47:24 -0400 Subject: [Git][ghc/ghc][wip/T23576] 114 commits: Ensure unconstrained instance dictionaries get IPE info Message-ID: <6543eebc2a612_27efe923132928190237@gitlab.mail> Andreas Klebinger pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC Commits: 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 1b4d458e by Jaro Reinders at 2023-11-02T19:33:23+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 4cc462d2 by Andreas Klebinger at 2023-11-02T19:33:23+01:00 docs - - - - - 28 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abe72e6f0f769f97a8e4e89f7d0b2303a6c60286...4cc462d2c05c10850d2e3ef4e57577e1afdfa4fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abe72e6f0f769f97a8e4e89f7d0b2303a6c60286...4cc462d2c05c10850d2e3ef4e57577e1afdfa4fb You're receiving 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 Nov 2 18:47:50 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 02 Nov 2023 14:47:50 -0400 Subject: [Git][ghc/ghc][wip/T23576] Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6543eed69c553_27efe92312ac141906d5@gitlab.mail> Andreas Klebinger pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC Commits: 1b0dfcbe by Jaro Reinders at 2023-11-02T19:36:25+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 9 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Utils/Unique.hs - docs/users_guide/9.6.1-notes.rst - testsuite/tests/cmm/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -523,7 +523,6 @@ assignReg_I64Code (CmmLocal dst) valueTree = do assignReg_I64Code _ _ = panic "assignReg_I64Code(i386): invalid lvalue" - iselExpr64 :: HasDebugCallStack => CmmExpr -> NatM (RegCode64 InstrBlock) iselExpr64 (CmmLit (CmmInt i _)) = do Reg64 rhi rlo <- getNewReg64 @@ -550,7 +549,6 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do let Reg64 hi lo = localReg64 local_reg return (RegCode64 nilOL hi lo) --- we handle addition, but rather badly iselExpr64 (CmmMachOp (MO_Add _) [e1, CmmLit (CmmInt i _)]) = do RegCode64 code1 r1hi r1lo <- iselExpr64 e1 Reg64 rhi rlo <- getNewReg64 @@ -590,11 +588,31 @@ iselExpr64 (CmmMachOp (MO_Sub _) [e1,e2]) = do SBB II32 (OpReg r2hi) (OpReg rhi) ] return (RegCode64 code rhi rlo) -iselExpr64 (CmmMachOp (MO_UU_Conv _ W64) [expr]) = do +iselExpr64 (CmmMachOp (MO_UU_Conv W32 W64) [expr]) = do code <- getAnyReg expr Reg64 r_dst_hi r_dst_lo <- getNewReg64 return $ RegCode64 (code r_dst_lo `snocOL` - MOV II32 (OpImm (ImmInt 0)) (OpReg r_dst_hi)) + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi)) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W16 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II16 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W8 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II8 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) r_dst_hi r_dst_lo @@ -609,11 +627,208 @@ iselExpr64 (CmmMachOp (MO_SS_Conv W32 W64) [expr]) = do r_dst_hi r_dst_lo +iselExpr64 (CmmMachOp (MO_SS_Conv W16 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II16 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_SS_Conv W8 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II8 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_S_Neg _) [expr]) = do + RegCode64 code rhi rlo <- iselExpr64 expr + Reg64 rohi rolo <- getNewReg64 + let + ocode = code `appOL` + toOL [ MOV II32 (OpReg rlo) (OpReg rolo), + XOR II32 (OpReg rohi) (OpReg rohi), + NEGI II32 (OpReg rolo), + SBB II32 (OpReg rhi) (OpReg rohi) ] + return (RegCode64 ocode rohi rolo) + +-- To multiply two 64-bit numbers we use the following decomposition (in C notation): +-- +-- ((r1hi << 32) + r1lo) * ((r2hi << 32) + r2lo) +-- = ((r2lo * r1hi) << 32) +-- + ((r1lo * r2hi) << 32) +-- + r1lo * r2lo +-- +-- Note that @(r1hi * r2hi) << 64@ can be dropped because it overflows completely. + +iselExpr64 (CmmMachOp (MO_Mul _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + tmp <- getNewRegNat II32 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg eax), + MOV II32 (OpReg r2lo) (OpReg tmp), + MOV II32 (OpReg r1hi) (OpReg rhi), + IMUL II32 (OpReg tmp) (OpReg rhi), + MOV II32 (OpReg r2hi) (OpReg rlo), + IMUL II32 (OpReg eax) (OpReg rlo), + ADD II32 (OpReg rlo) (OpReg rhi), + MUL2 II32 (OpReg tmp), + ADD II32 (OpReg edx) (OpReg rhi), + MOV II32 (OpReg eax) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_S_MulMayOflo W64) [e1,e2]) = do + -- Performance sensitive users won't use 32 bit so let's keep it simple: + -- We always return a (usually false) positive. + Reg64 rhi rlo <- getNewReg64 + let code = toOL [ + MOV II32 (OpImm (ImmInt 1)) (OpReg rhi), + MOV II32 (OpImm (ImmInt 1)) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + + +-- To shift a 64-bit number to the left we use the SHLD and SHL instructions. +-- We use SHLD to shift the bits in @rhi@ to the left while copying +-- high bits from @rlo@ to fill the new space in the low bits of @rhi at . +-- That leaves @rlo@ unchanged, so we use SHL to shift the bits of @rlo@ left. +-- However, both these instructions only use the lowest 5 bits from %cl to do +-- their shifting. So if the sixth bit (0x32) is set then we additionally move +-- the contents of @rlo@ to @rhi@ and clear @rlo at . + +iselExpr64 (CmmMachOp (MO_Shl _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + code2 <- getAnyReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 ecx `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + SHLD II32 (OpReg ecx) (OpReg rlo) (OpReg rhi), + SHL II32 (OpReg ecx) (OpReg rlo), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rlo) (OpReg rhi), + XOR II32 (OpReg rlo) (OpReg rlo), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to above, however now we're shifting to the right +-- and we're doing a signed shift which means that @rhi@ needs +-- to be set to either 0 if @rhi@ is positive or 0xffffffff otherwise, +-- and if the sixth bit of %cl is set (so the shift amount is more than 32). +-- To accomplish that we shift @rhi@ by 31. + +iselExpr64 (CmmMachOp (MO_S_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SAR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + SAR II32 (OpImm (ImmInt 31)) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to the above. + +iselExpr64 (CmmMachOp (MO_U_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SHR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + XOR II32 (OpReg rhi) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_And _) [e1,e2]) = iselExpr64ParallelBin AND e1 e2 +iselExpr64 (CmmMachOp (MO_Or _) [e1,e2]) = iselExpr64ParallelBin OR e1 e2 +iselExpr64 (CmmMachOp (MO_Xor _) [e1,e2]) = iselExpr64ParallelBin XOR e1 e2 + +iselExpr64 (CmmMachOp (MO_Not _) [e1]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + NOT II32 (OpReg rlo), + NOT II32 (OpReg rhi) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmRegOff r i) = iselExpr64 (mangleIndexTree r i) + iselExpr64 expr = do platform <- getPlatform - pprPanic "iselExpr64(i386)" (pdoc platform expr) + pprPanic "iselExpr64(i386)" (pdoc platform expr $+$ text (show expr)) +iselExpr64ParallelBin :: (Format -> Operand -> Operand -> Instr) + -> CmmExpr -> CmmExpr -> NatM (RegCode64 (OrdList Instr)) +iselExpr64ParallelBin op e1 e2 = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + op II32 (OpReg r2lo) (OpReg rlo), + op II32 (OpReg r2hi) (OpReg rhi) + ] + return (RegCode64 code rhi rlo) -------------------------------------------------------------------------------- getRegister :: CmmExpr -> NatM Register @@ -675,6 +890,18 @@ getRegister' _ is32Bit (CmmMachOp (MO_SS_Conv W64 W32) [x]) RegCode64 code _rhi rlo <- iselExpr64 x return $ Fixed II32 rlo code +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W8) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II8 + return $ Fixed II8 ro (code `appOL` toOL [ MOVZxL II8 (OpReg rlo) (OpReg ro) ]) + +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W16) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II16 + return $ Fixed II16 ro (code `appOL` toOL [ MOVZxL II16 (OpReg rlo) (OpReg ro) ]) + getRegister' _ _ (CmmLit lit@(CmmFloat f w)) = float_const_sse2 where float_const_sse2 @@ -1657,6 +1884,27 @@ machOpToCond mo = case mo of MO_U_Le _ -> LEU _other -> pprPanic "machOpToCond" (pprMachOp mo) +{- Note [64-bit integer comparisons on 32-bit] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + When doing these comparisons there are 2 kinds of + comparisons. + + * Comparison for equality (or lack thereof) + + We use xor to check if high/low bits are + equal. Then combine the results using or. + + * Other comparisons: + + We first compare the low registers + and use a subtraction with borrow to compare the high registers. + + For signed numbers the condition is determined by + the sign and overflow flags agreeing or not + and for unsigned numbers the condition is the carry flag. + +-} -- @cond(Int|Flt)Code@: Turn a boolean expression into a condition, to be -- passed back up the tree. @@ -1667,6 +1915,68 @@ condIntCode cond x y = do platform <- getPlatform condIntCode' :: Platform -> Cond -> CmmExpr -> CmmExpr -> NatM CondCode +-- 64-bit integer comparisons on 32-bit +-- See Note [64-bit integer comparisons on 32-bit] +condIntCode' platform cond x y + | target32Bit platform && isWord64 (cmmExprType platform x) = do + + RegCode64 code1 r1hi r1lo <- iselExpr64 x + RegCode64 code2 r2hi r2lo <- iselExpr64 y + + -- we mustn't clobber r1/r2 so we use temporaries + tmp1 <- getNewRegNat II32 + tmp2 <- getNewRegNat II32 + + let (cond', cmpCode) = intComparison cond r1hi r1lo r2hi r2lo tmp1 tmp2 + return $ CondCode False cond' (code1 `appOL` code2 `appOL` cmpCode) + + where + intComparison cond r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = + case cond of + -- These don't occur as argument of condIntCode' + ALWAYS -> panic "impossible" + NEG -> panic "impossible" + POS -> panic "impossible" + CARRY -> panic "impossible" + OFLO -> panic "impossible" + PARITY -> panic "impossible" + NOTPARITY -> panic "impossible" + -- Special case #1 x == y and x != y + EQQ -> (EQQ, cmpExact) + NE -> (NE, cmpExact) + -- [x >= y] + GE -> (GE, cmpGE) + GEU -> (GEU, cmpGE) + -- [x > y] + GTT -> (LTT, cmpLE) + GU -> (LU, cmpLE) + -- [x <= y] + LE -> (GE, cmpLE) + LEU -> (GEU, cmpLE) + -- [x < y] + LTT -> (LTT, cmpGE) + LU -> (LU, cmpGE) + where + cmpExact :: OrdList Instr + cmpExact = + toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , MOV II32 (OpReg r1_lo) (OpReg tmp2) + , XOR II32 (OpReg r2_hi) (OpReg tmp1) + , XOR II32 (OpReg r2_lo) (OpReg tmp2) + , OR II32 (OpReg tmp1) (OpReg tmp2) + ] + cmpGE = toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , CMP II32 (OpReg r2_lo) (OpReg r1_lo) + , SBB II32 (OpReg r2_hi) (OpReg tmp1) + ] + cmpLE = toOL + [ MOV II32 (OpReg r2_hi) (OpReg tmp1) + , CMP II32 (OpReg r1_lo) (OpReg r2_lo) + , SBB II32 (OpReg r1_hi) (OpReg tmp1) + ] + -- memory vs immediate condIntCode' platform cond (CmmLoad x pk _) (CmmLit lit) | is32BitLit platform lit = do @@ -1881,36 +2191,6 @@ I386: First, we have to ensure that the condition codes are set according to the supplied comparison operation. -} -{- Note [64-bit integer comparisons on 32-bit] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - When doing these comparisons there are 2 kinds of - comparisons. - - * Comparison for equality (or lack thereof) - - We use xor to check if high/low bits are - equal. Then combine the results using or and - perform a single conditional jump based on the - result. - - * Other comparisons: - - We map all other comparisons to the >= operation. - Why? Because it's easy to encode it with a single - conditional jump. - - We do this by first computing [r1_lo - r2_lo] - and use the carry flag to compute - [r1_high - r2_high - CF]. - - At which point if r1 >= r2 then the result will be - positive. Otherwise negative so we can branch on this - condition. - --} - - genCondBranch :: BlockId -- the source of the jump -> BlockId -- the true branch target @@ -1926,67 +2206,6 @@ genCondBranch bid id false expr = do genCondBranch' :: Bool -> BlockId -> BlockId -> BlockId -> CmmExpr -> NatM InstrBlock --- 64-bit integer comparisons on 32-bit --- See Note [64-bit integer comparisons on 32-bit] -genCondBranch' is32Bit _bid true false (CmmMachOp mop [e1,e2]) - | is32Bit, Just W64 <- maybeIntComparison mop = do - - RegCode64 code1 r1hi r1lo <- iselExpr64 e1 - RegCode64 code2 r2hi r2lo <- iselExpr64 e2 - let cond = machOpToCond mop :: Cond - - -- we mustn't clobber r1/r2 so we use temporaries - tmp1 <- getNewRegNat II32 - tmp2 <- getNewRegNat II32 - - let cmpCode = intComparison cond true false r1hi r1lo r2hi r2lo tmp1 tmp2 - return $ code1 `appOL` code2 `appOL` cmpCode - - where - intComparison cond true false r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = - case cond of - -- Impossible results of machOpToCond - ALWAYS -> panic "impossible" - NEG -> panic "impossible" - POS -> panic "impossible" - CARRY -> panic "impossible" - OFLO -> panic "impossible" - PARITY -> panic "impossible" - NOTPARITY -> panic "impossible" - -- Special case #1 x == y and x != y - EQQ -> cmpExact - NE -> cmpExact - -- [x >= y] - GE -> cmpGE - GEU -> cmpGE - -- [x > y] <==> ![y >= x] - GTT -> intComparison GE false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - GU -> intComparison GEU false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x <= y] <==> [y >= x] - LE -> intComparison GE true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - LEU -> intComparison GEU true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x < y] <==> ![x >= x] - LTT -> intComparison GE false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - LU -> intComparison GEU false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - where - cmpExact :: OrdList Instr - cmpExact = - toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , MOV II32 (OpReg r1_lo) (OpReg tmp2) - , XOR II32 (OpReg r2_hi) (OpReg tmp1) - , XOR II32 (OpReg r2_lo) (OpReg tmp2) - , OR II32 (OpReg tmp1) (OpReg tmp2) - , JXX cond true - , JXX ALWAYS false - ] - cmpGE = toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , CMP II32 (OpReg r2_lo) (OpReg r1_lo) - , SBB II32 (OpReg r2_hi) (OpReg tmp1) - , JXX cond true - , JXX ALWAYS false ] - genCondBranch' _ bid id false bool = do CondCode is_float cond cond_code <- getCondCode bool use_sse2 <- sse2Enabled ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -249,6 +249,8 @@ data Instr | SHL Format Operand{-amount-} Operand | SAR Format Operand{-amount-} Operand | SHR Format Operand{-amount-} Operand + | SHRD Format Operand{-amount-} Operand Operand + | SHLD Format Operand{-amount-} Operand Operand | BT Format Imm Operand | NOP @@ -399,6 +401,8 @@ regUsageOfInstr platform instr SHL _ imm dst -> usageRM imm dst SAR _ imm dst -> usageRM imm dst SHR _ imm dst -> usageRM imm dst + SHLD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 + SHRD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 BT _ _ src -> mkRUR (use_R src []) PUSH _ op -> mkRUR (use_R op []) @@ -568,6 +572,8 @@ patchRegsOfInstr instr env SHL fmt imm dst -> patch1 (SHL fmt imm) dst SAR fmt imm dst -> patch1 (SAR fmt imm) dst SHR fmt imm dst -> patch1 (SHR fmt imm) dst + SHLD fmt imm dst1 dst2 -> patch2 (SHLD fmt imm) dst1 dst2 + SHRD fmt imm dst1 dst2 -> patch2 (SHRD fmt imm) dst1 dst2 BT fmt imm src -> patch1 (BT fmt imm) src TEST fmt src dst -> patch2 (TEST fmt) src dst CMP fmt src dst -> patch2 (CMP fmt) src dst ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -732,6 +732,12 @@ pprInstr platform i = case i of SHR format src dst -> pprShift (text "shr") format src dst + SHLD format src dst1 dst2 + -> pprShift2 (text "shld") format src dst1 dst2 + + SHRD format src dst1 dst2 + -> pprShift2 (text "shrd") format src dst1 dst2 + BT format imm src -> pprFormatImmOp (text "bt") format imm src @@ -1070,6 +1076,17 @@ pprInstr platform i = case i of pprOperand platform format dest ] + pprShift2 :: Line doc -> Format -> Operand -> Operand -> Operand -> doc + pprShift2 name format src dest1 dest2 + = line $ hcat [ + pprMnemonic name format, + pprOperand platform II8 src, -- src is 8-bit sized + comma, + pprOperand platform format dest1, + comma, + pprOperand platform format dest2 + ] + pprFormatOpOpCoerce :: Line doc -> Format -> Format -> Operand -> Operand -> doc pprFormatOpOpCoerce name format1 format2 op1 op2 ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -53,7 +53,8 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmDoBoundsCheck = gopt Opt_DoBoundsChecking dflags , stgToCmmDoTagCheck = gopt Opt_DoTagInferenceChecks dflags -- backend flags - , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 + , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 || platformArch platform == ArchX86 + , stgToCmmAllowBigQuot = not ncg || platformArch platform == ArchWasm32 , stgToCmmAllowQuotRemInstr = ncg && (x86ish || ppc) , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm ===================================== compiler/GHC/StgToCmm/Config.hs ===================================== @@ -65,6 +65,7 @@ data StgToCmmConfig = StgToCmmConfig , stgToCmmDoTagCheck :: !Bool -- ^ Verify tag inference predictions. ------------------------------ Backend Flags ---------------------------------- , stgToCmmAllowBigArith :: !Bool -- ^ Allowed to emit larger than native size arithmetic (only LLVM and C backends) + , stgToCmmAllowBigQuot :: !Bool -- ^ Allowed to emit larger than native size division operations , stgToCmmAllowQuotRemInstr :: !Bool -- ^ Allowed to generate QuotRem instructions , stgToCmmAllowQuotRem2 :: !Bool -- ^ Allowed to generate QuotRem , stgToCmmAllowExtendedAddSubInstrs :: !Bool -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc. ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1682,6 +1682,13 @@ emitPrimOp cfg primop = let stmt = mkAssign (CmmLocal res) (CmmMachOp mop args) emit stmt + isQuottishOp :: CallishMachOp -> Bool + isQuottishOp MO_I64_Quot = True + isQuottishOp MO_I64_Rem = True + isQuottishOp MO_W64_Quot = True + isQuottishOp MO_W64_Rem = True + isQuottishOp _ = False + opTranslate64 :: [CmmExpr] -> (Width -> MachOp) @@ -1690,7 +1697,8 @@ emitPrimOp cfg primop = opTranslate64 args mkMop callish = case platformWordSize platform of -- LLVM and C `can handle larger than native size arithmetic natively. - _ | stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + _ | not (isQuottishOp callish), stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + | isQuottishOp callish, stgToCmmAllowBigQuot cfg -> opTranslate args $ mkMop W64 PW4 -> opCallish args callish PW8 -> opTranslate args $ mkMop W64 ===================================== compiler/GHC/Utils/Unique.hs ===================================== @@ -2,12 +2,12 @@ {- Work around #23537 -On 32 bit systems, GHC's codegen around 64 bit numbers is not quite -complete. This led to panics mentioning missing cases in iselExpr64. -Now that GHC uses Word64 for its uniques, these panics have started -popping up whenever a unique is compared to many other uniques in one -function. As a workaround we use these two functions which are not -inlined on 32 bit systems, thus preventing the panics. +On 32 bit systems, GHC's codegen around 64 bit numbers used to be incomplete +before GHC 9.10. This led to panics mentioning missing cases in iselExpr64. +Now that GHC uses Word64 for its uniques, these panics have started popping up +whenever a unique is compared to many other uniques in one function. As a +workaround we use these two functions which are not inlined, on 32 bit systems +and if compiled with versions before GHC 9.9, thus preventing the panics. -} module GHC.Utils.Unique (sameUnique, anyOfUnique) where @@ -18,7 +18,7 @@ import GHC.Prelude.Basic (Bool, Eq((==)), Foldable(elem)) import GHC.Types.Unique (Unique, Uniquable (getUnique)) -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE sameUnique #-} #else {-# INLINE sameUnique #-} @@ -26,7 +26,7 @@ import GHC.Types.Unique (Unique, Uniquable (getUnique)) sameUnique :: Uniquable a => a -> a -> Bool sameUnique x y = getUnique x == getUnique y -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE anyOfUnique #-} #else {-# INLINE anyOfUnique #-} ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -122,7 +122,7 @@ Compiler that targets ``wasm32-wasi`` and compiles Haskell code to self-contained WebAssembly modules that can be executed on a variety of different runtimes. There are a few caveats to be aware of: - + - To use the WebAssembly backend, one would need to follow the instructions on `ghc-wasm-meta `_. The WebAssembly @@ -149,6 +149,9 @@ Compiler - The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. +- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit + operations. This improves Int64/Word64 performance substantially on this platform. + GHCi ~~~~ ===================================== testsuite/tests/cmm/should_run/all.T ===================================== @@ -27,7 +27,6 @@ test('ByteSwitch', test('T22871', [ extra_run_opts('"' + config.libdir + '"') , req_cmm - , when(arch('i386'), skip) # x86 NCG panics with "iselExpr64(i386)" ], multi_compile_and_run, ['T22871', [('T22871_cmm.cmm', '')], '']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b0dfcbe14c5ec52d1eb71cbe43b21b52b4187e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b0dfcbe14c5ec52d1eb71cbe43b21b52b4187e4 You're receiving 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 Nov 2 19:21:48 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 02 Nov 2023 15:21:48 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-loca-a-function Message-ID: <6543f6cc8efcf_27efe923df14d41947a@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-loca-a-function at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-loca-a-function You're receiving 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 Nov 2 23:25:22 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 02 Nov 2023 19:25:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T14146 Message-ID: <65442fe264d24_27efe92984a67421038c@gitlab.mail> Simon Peyton Jones pushed new branch wip/T14146 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T14146 You're receiving 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 Nov 3 10:06:04 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 03 Nov 2023 06:06:04 -0400 Subject: [Git][ghc/ghc][wip/T23576] Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6544c60c336c_27efe9380376d02330ea@gitlab.mail> Andreas Klebinger pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC Commits: 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 9 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Utils/Unique.hs - docs/users_guide/9.6.1-notes.rst - testsuite/tests/cmm/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -523,7 +523,6 @@ assignReg_I64Code (CmmLocal dst) valueTree = do assignReg_I64Code _ _ = panic "assignReg_I64Code(i386): invalid lvalue" - iselExpr64 :: HasDebugCallStack => CmmExpr -> NatM (RegCode64 InstrBlock) iselExpr64 (CmmLit (CmmInt i _)) = do Reg64 rhi rlo <- getNewReg64 @@ -550,7 +549,6 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do let Reg64 hi lo = localReg64 local_reg return (RegCode64 nilOL hi lo) --- we handle addition, but rather badly iselExpr64 (CmmMachOp (MO_Add _) [e1, CmmLit (CmmInt i _)]) = do RegCode64 code1 r1hi r1lo <- iselExpr64 e1 Reg64 rhi rlo <- getNewReg64 @@ -590,11 +588,31 @@ iselExpr64 (CmmMachOp (MO_Sub _) [e1,e2]) = do SBB II32 (OpReg r2hi) (OpReg rhi) ] return (RegCode64 code rhi rlo) -iselExpr64 (CmmMachOp (MO_UU_Conv _ W64) [expr]) = do +iselExpr64 (CmmMachOp (MO_UU_Conv W32 W64) [expr]) = do code <- getAnyReg expr Reg64 r_dst_hi r_dst_lo <- getNewReg64 return $ RegCode64 (code r_dst_lo `snocOL` - MOV II32 (OpImm (ImmInt 0)) (OpReg r_dst_hi)) + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi)) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W16 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II16 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W8 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II8 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) r_dst_hi r_dst_lo @@ -609,11 +627,208 @@ iselExpr64 (CmmMachOp (MO_SS_Conv W32 W64) [expr]) = do r_dst_hi r_dst_lo +iselExpr64 (CmmMachOp (MO_SS_Conv W16 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II16 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_SS_Conv W8 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II8 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_S_Neg _) [expr]) = do + RegCode64 code rhi rlo <- iselExpr64 expr + Reg64 rohi rolo <- getNewReg64 + let + ocode = code `appOL` + toOL [ MOV II32 (OpReg rlo) (OpReg rolo), + XOR II32 (OpReg rohi) (OpReg rohi), + NEGI II32 (OpReg rolo), + SBB II32 (OpReg rhi) (OpReg rohi) ] + return (RegCode64 ocode rohi rolo) + +-- To multiply two 64-bit numbers we use the following decomposition (in C notation): +-- +-- ((r1hi << 32) + r1lo) * ((r2hi << 32) + r2lo) +-- = ((r2lo * r1hi) << 32) +-- + ((r1lo * r2hi) << 32) +-- + r1lo * r2lo +-- +-- Note that @(r1hi * r2hi) << 64@ can be dropped because it overflows completely. + +iselExpr64 (CmmMachOp (MO_Mul _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + tmp <- getNewRegNat II32 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg eax), + MOV II32 (OpReg r2lo) (OpReg tmp), + MOV II32 (OpReg r1hi) (OpReg rhi), + IMUL II32 (OpReg tmp) (OpReg rhi), + MOV II32 (OpReg r2hi) (OpReg rlo), + IMUL II32 (OpReg eax) (OpReg rlo), + ADD II32 (OpReg rlo) (OpReg rhi), + MUL2 II32 (OpReg tmp), + ADD II32 (OpReg edx) (OpReg rhi), + MOV II32 (OpReg eax) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_S_MulMayOflo W64) _) = do + -- Performance sensitive users won't use 32 bit so let's keep it simple: + -- We always return a (usually false) positive. + Reg64 rhi rlo <- getNewReg64 + let code = toOL [ + MOV II32 (OpImm (ImmInt 1)) (OpReg rhi), + MOV II32 (OpImm (ImmInt 1)) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + + +-- To shift a 64-bit number to the left we use the SHLD and SHL instructions. +-- We use SHLD to shift the bits in @rhi@ to the left while copying +-- high bits from @rlo@ to fill the new space in the low bits of @rhi at . +-- That leaves @rlo@ unchanged, so we use SHL to shift the bits of @rlo@ left. +-- However, both these instructions only use the lowest 5 bits from %cl to do +-- their shifting. So if the sixth bit (0x32) is set then we additionally move +-- the contents of @rlo@ to @rhi@ and clear @rlo at . + +iselExpr64 (CmmMachOp (MO_Shl _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + code2 <- getAnyReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 ecx `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + SHLD II32 (OpReg ecx) (OpReg rlo) (OpReg rhi), + SHL II32 (OpReg ecx) (OpReg rlo), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rlo) (OpReg rhi), + XOR II32 (OpReg rlo) (OpReg rlo), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to above, however now we're shifting to the right +-- and we're doing a signed shift which means that @rhi@ needs +-- to be set to either 0 if @rhi@ is positive or 0xffffffff otherwise, +-- and if the sixth bit of %cl is set (so the shift amount is more than 32). +-- To accomplish that we shift @rhi@ by 31. + +iselExpr64 (CmmMachOp (MO_S_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SAR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + SAR II32 (OpImm (ImmInt 31)) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to the above. + +iselExpr64 (CmmMachOp (MO_U_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SHR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + XOR II32 (OpReg rhi) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_And _) [e1,e2]) = iselExpr64ParallelBin AND e1 e2 +iselExpr64 (CmmMachOp (MO_Or _) [e1,e2]) = iselExpr64ParallelBin OR e1 e2 +iselExpr64 (CmmMachOp (MO_Xor _) [e1,e2]) = iselExpr64ParallelBin XOR e1 e2 + +iselExpr64 (CmmMachOp (MO_Not _) [e1]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + NOT II32 (OpReg rlo), + NOT II32 (OpReg rhi) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmRegOff r i) = iselExpr64 (mangleIndexTree r i) + iselExpr64 expr = do platform <- getPlatform - pprPanic "iselExpr64(i386)" (pdoc platform expr) + pprPanic "iselExpr64(i386)" (pdoc platform expr $+$ text (show expr)) +iselExpr64ParallelBin :: (Format -> Operand -> Operand -> Instr) + -> CmmExpr -> CmmExpr -> NatM (RegCode64 (OrdList Instr)) +iselExpr64ParallelBin op e1 e2 = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + op II32 (OpReg r2lo) (OpReg rlo), + op II32 (OpReg r2hi) (OpReg rhi) + ] + return (RegCode64 code rhi rlo) -------------------------------------------------------------------------------- getRegister :: CmmExpr -> NatM Register @@ -675,6 +890,18 @@ getRegister' _ is32Bit (CmmMachOp (MO_SS_Conv W64 W32) [x]) RegCode64 code _rhi rlo <- iselExpr64 x return $ Fixed II32 rlo code +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W8) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II8 + return $ Fixed II8 ro (code `appOL` toOL [ MOVZxL II8 (OpReg rlo) (OpReg ro) ]) + +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W16) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II16 + return $ Fixed II16 ro (code `appOL` toOL [ MOVZxL II16 (OpReg rlo) (OpReg ro) ]) + getRegister' _ _ (CmmLit lit@(CmmFloat f w)) = float_const_sse2 where float_const_sse2 @@ -1657,6 +1884,27 @@ machOpToCond mo = case mo of MO_U_Le _ -> LEU _other -> pprPanic "machOpToCond" (pprMachOp mo) +{- Note [64-bit integer comparisons on 32-bit] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + When doing these comparisons there are 2 kinds of + comparisons. + + * Comparison for equality (or lack thereof) + + We use xor to check if high/low bits are + equal. Then combine the results using or. + + * Other comparisons: + + We first compare the low registers + and use a subtraction with borrow to compare the high registers. + + For signed numbers the condition is determined by + the sign and overflow flags agreeing or not + and for unsigned numbers the condition is the carry flag. + +-} -- @cond(Int|Flt)Code@: Turn a boolean expression into a condition, to be -- passed back up the tree. @@ -1667,6 +1915,68 @@ condIntCode cond x y = do platform <- getPlatform condIntCode' :: Platform -> Cond -> CmmExpr -> CmmExpr -> NatM CondCode +-- 64-bit integer comparisons on 32-bit +-- See Note [64-bit integer comparisons on 32-bit] +condIntCode' platform cond x y + | target32Bit platform && isWord64 (cmmExprType platform x) = do + + RegCode64 code1 r1hi r1lo <- iselExpr64 x + RegCode64 code2 r2hi r2lo <- iselExpr64 y + + -- we mustn't clobber r1/r2 so we use temporaries + tmp1 <- getNewRegNat II32 + tmp2 <- getNewRegNat II32 + + let (cond', cmpCode) = intComparison cond r1hi r1lo r2hi r2lo tmp1 tmp2 + return $ CondCode False cond' (code1 `appOL` code2 `appOL` cmpCode) + + where + intComparison cond r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = + case cond of + -- These don't occur as argument of condIntCode' + ALWAYS -> panic "impossible" + NEG -> panic "impossible" + POS -> panic "impossible" + CARRY -> panic "impossible" + OFLO -> panic "impossible" + PARITY -> panic "impossible" + NOTPARITY -> panic "impossible" + -- Special case #1 x == y and x != y + EQQ -> (EQQ, cmpExact) + NE -> (NE, cmpExact) + -- [x >= y] + GE -> (GE, cmpGE) + GEU -> (GEU, cmpGE) + -- [x > y] + GTT -> (LTT, cmpLE) + GU -> (LU, cmpLE) + -- [x <= y] + LE -> (GE, cmpLE) + LEU -> (GEU, cmpLE) + -- [x < y] + LTT -> (LTT, cmpGE) + LU -> (LU, cmpGE) + where + cmpExact :: OrdList Instr + cmpExact = + toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , MOV II32 (OpReg r1_lo) (OpReg tmp2) + , XOR II32 (OpReg r2_hi) (OpReg tmp1) + , XOR II32 (OpReg r2_lo) (OpReg tmp2) + , OR II32 (OpReg tmp1) (OpReg tmp2) + ] + cmpGE = toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , CMP II32 (OpReg r2_lo) (OpReg r1_lo) + , SBB II32 (OpReg r2_hi) (OpReg tmp1) + ] + cmpLE = toOL + [ MOV II32 (OpReg r2_hi) (OpReg tmp1) + , CMP II32 (OpReg r1_lo) (OpReg r2_lo) + , SBB II32 (OpReg r1_hi) (OpReg tmp1) + ] + -- memory vs immediate condIntCode' platform cond (CmmLoad x pk _) (CmmLit lit) | is32BitLit platform lit = do @@ -1881,36 +2191,6 @@ I386: First, we have to ensure that the condition codes are set according to the supplied comparison operation. -} -{- Note [64-bit integer comparisons on 32-bit] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - When doing these comparisons there are 2 kinds of - comparisons. - - * Comparison for equality (or lack thereof) - - We use xor to check if high/low bits are - equal. Then combine the results using or and - perform a single conditional jump based on the - result. - - * Other comparisons: - - We map all other comparisons to the >= operation. - Why? Because it's easy to encode it with a single - conditional jump. - - We do this by first computing [r1_lo - r2_lo] - and use the carry flag to compute - [r1_high - r2_high - CF]. - - At which point if r1 >= r2 then the result will be - positive. Otherwise negative so we can branch on this - condition. - --} - - genCondBranch :: BlockId -- the source of the jump -> BlockId -- the true branch target @@ -1926,67 +2206,6 @@ genCondBranch bid id false expr = do genCondBranch' :: Bool -> BlockId -> BlockId -> BlockId -> CmmExpr -> NatM InstrBlock --- 64-bit integer comparisons on 32-bit --- See Note [64-bit integer comparisons on 32-bit] -genCondBranch' is32Bit _bid true false (CmmMachOp mop [e1,e2]) - | is32Bit, Just W64 <- maybeIntComparison mop = do - - RegCode64 code1 r1hi r1lo <- iselExpr64 e1 - RegCode64 code2 r2hi r2lo <- iselExpr64 e2 - let cond = machOpToCond mop :: Cond - - -- we mustn't clobber r1/r2 so we use temporaries - tmp1 <- getNewRegNat II32 - tmp2 <- getNewRegNat II32 - - let cmpCode = intComparison cond true false r1hi r1lo r2hi r2lo tmp1 tmp2 - return $ code1 `appOL` code2 `appOL` cmpCode - - where - intComparison cond true false r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = - case cond of - -- Impossible results of machOpToCond - ALWAYS -> panic "impossible" - NEG -> panic "impossible" - POS -> panic "impossible" - CARRY -> panic "impossible" - OFLO -> panic "impossible" - PARITY -> panic "impossible" - NOTPARITY -> panic "impossible" - -- Special case #1 x == y and x != y - EQQ -> cmpExact - NE -> cmpExact - -- [x >= y] - GE -> cmpGE - GEU -> cmpGE - -- [x > y] <==> ![y >= x] - GTT -> intComparison GE false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - GU -> intComparison GEU false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x <= y] <==> [y >= x] - LE -> intComparison GE true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - LEU -> intComparison GEU true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x < y] <==> ![x >= x] - LTT -> intComparison GE false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - LU -> intComparison GEU false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - where - cmpExact :: OrdList Instr - cmpExact = - toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , MOV II32 (OpReg r1_lo) (OpReg tmp2) - , XOR II32 (OpReg r2_hi) (OpReg tmp1) - , XOR II32 (OpReg r2_lo) (OpReg tmp2) - , OR II32 (OpReg tmp1) (OpReg tmp2) - , JXX cond true - , JXX ALWAYS false - ] - cmpGE = toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , CMP II32 (OpReg r2_lo) (OpReg r1_lo) - , SBB II32 (OpReg r2_hi) (OpReg tmp1) - , JXX cond true - , JXX ALWAYS false ] - genCondBranch' _ bid id false bool = do CondCode is_float cond cond_code <- getCondCode bool use_sse2 <- sse2Enabled ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -249,6 +249,8 @@ data Instr | SHL Format Operand{-amount-} Operand | SAR Format Operand{-amount-} Operand | SHR Format Operand{-amount-} Operand + | SHRD Format Operand{-amount-} Operand Operand + | SHLD Format Operand{-amount-} Operand Operand | BT Format Imm Operand | NOP @@ -399,6 +401,8 @@ regUsageOfInstr platform instr SHL _ imm dst -> usageRM imm dst SAR _ imm dst -> usageRM imm dst SHR _ imm dst -> usageRM imm dst + SHLD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 + SHRD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 BT _ _ src -> mkRUR (use_R src []) PUSH _ op -> mkRUR (use_R op []) @@ -568,6 +572,8 @@ patchRegsOfInstr instr env SHL fmt imm dst -> patch1 (SHL fmt imm) dst SAR fmt imm dst -> patch1 (SAR fmt imm) dst SHR fmt imm dst -> patch1 (SHR fmt imm) dst + SHLD fmt imm dst1 dst2 -> patch2 (SHLD fmt imm) dst1 dst2 + SHRD fmt imm dst1 dst2 -> patch2 (SHRD fmt imm) dst1 dst2 BT fmt imm src -> patch1 (BT fmt imm) src TEST fmt src dst -> patch2 (TEST fmt) src dst CMP fmt src dst -> patch2 (CMP fmt) src dst ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -732,6 +732,12 @@ pprInstr platform i = case i of SHR format src dst -> pprShift (text "shr") format src dst + SHLD format src dst1 dst2 + -> pprShift2 (text "shld") format src dst1 dst2 + + SHRD format src dst1 dst2 + -> pprShift2 (text "shrd") format src dst1 dst2 + BT format imm src -> pprFormatImmOp (text "bt") format imm src @@ -1070,6 +1076,17 @@ pprInstr platform i = case i of pprOperand platform format dest ] + pprShift2 :: Line doc -> Format -> Operand -> Operand -> Operand -> doc + pprShift2 name format src dest1 dest2 + = line $ hcat [ + pprMnemonic name format, + pprOperand platform II8 src, -- src is 8-bit sized + comma, + pprOperand platform format dest1, + comma, + pprOperand platform format dest2 + ] + pprFormatOpOpCoerce :: Line doc -> Format -> Format -> Operand -> Operand -> doc pprFormatOpOpCoerce name format1 format2 op1 op2 ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -53,7 +53,8 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmDoBoundsCheck = gopt Opt_DoBoundsChecking dflags , stgToCmmDoTagCheck = gopt Opt_DoTagInferenceChecks dflags -- backend flags - , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 + , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 || platformArch platform == ArchX86 + , stgToCmmAllowBigQuot = not ncg || platformArch platform == ArchWasm32 , stgToCmmAllowQuotRemInstr = ncg && (x86ish || ppc) , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm ===================================== compiler/GHC/StgToCmm/Config.hs ===================================== @@ -65,6 +65,7 @@ data StgToCmmConfig = StgToCmmConfig , stgToCmmDoTagCheck :: !Bool -- ^ Verify tag inference predictions. ------------------------------ Backend Flags ---------------------------------- , stgToCmmAllowBigArith :: !Bool -- ^ Allowed to emit larger than native size arithmetic (only LLVM and C backends) + , stgToCmmAllowBigQuot :: !Bool -- ^ Allowed to emit larger than native size division operations , stgToCmmAllowQuotRemInstr :: !Bool -- ^ Allowed to generate QuotRem instructions , stgToCmmAllowQuotRem2 :: !Bool -- ^ Allowed to generate QuotRem , stgToCmmAllowExtendedAddSubInstrs :: !Bool -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc. ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1682,6 +1682,13 @@ emitPrimOp cfg primop = let stmt = mkAssign (CmmLocal res) (CmmMachOp mop args) emit stmt + isQuottishOp :: CallishMachOp -> Bool + isQuottishOp MO_I64_Quot = True + isQuottishOp MO_I64_Rem = True + isQuottishOp MO_W64_Quot = True + isQuottishOp MO_W64_Rem = True + isQuottishOp _ = False + opTranslate64 :: [CmmExpr] -> (Width -> MachOp) @@ -1690,7 +1697,8 @@ emitPrimOp cfg primop = opTranslate64 args mkMop callish = case platformWordSize platform of -- LLVM and C `can handle larger than native size arithmetic natively. - _ | stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + _ | not (isQuottishOp callish), stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + | isQuottishOp callish, stgToCmmAllowBigQuot cfg -> opTranslate args $ mkMop W64 PW4 -> opCallish args callish PW8 -> opTranslate args $ mkMop W64 ===================================== compiler/GHC/Utils/Unique.hs ===================================== @@ -2,12 +2,12 @@ {- Work around #23537 -On 32 bit systems, GHC's codegen around 64 bit numbers is not quite -complete. This led to panics mentioning missing cases in iselExpr64. -Now that GHC uses Word64 for its uniques, these panics have started -popping up whenever a unique is compared to many other uniques in one -function. As a workaround we use these two functions which are not -inlined on 32 bit systems, thus preventing the panics. +On 32 bit systems, GHC's codegen around 64 bit numbers used to be incomplete +before GHC 9.10. This led to panics mentioning missing cases in iselExpr64. +Now that GHC uses Word64 for its uniques, these panics have started popping up +whenever a unique is compared to many other uniques in one function. As a +workaround we use these two functions which are not inlined, on 32 bit systems +and if compiled with versions before GHC 9.9, thus preventing the panics. -} module GHC.Utils.Unique (sameUnique, anyOfUnique) where @@ -18,7 +18,7 @@ import GHC.Prelude.Basic (Bool, Eq((==)), Foldable(elem)) import GHC.Types.Unique (Unique, Uniquable (getUnique)) -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE sameUnique #-} #else {-# INLINE sameUnique #-} @@ -26,7 +26,7 @@ import GHC.Types.Unique (Unique, Uniquable (getUnique)) sameUnique :: Uniquable a => a -> a -> Bool sameUnique x y = getUnique x == getUnique y -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE anyOfUnique #-} #else {-# INLINE anyOfUnique #-} ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -122,7 +122,7 @@ Compiler that targets ``wasm32-wasi`` and compiles Haskell code to self-contained WebAssembly modules that can be executed on a variety of different runtimes. There are a few caveats to be aware of: - + - To use the WebAssembly backend, one would need to follow the instructions on `ghc-wasm-meta `_. The WebAssembly @@ -149,6 +149,9 @@ Compiler - The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. +- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit + operations. This improves Int64/Word64 performance substantially on this platform. + GHCi ~~~~ ===================================== testsuite/tests/cmm/should_run/all.T ===================================== @@ -27,7 +27,6 @@ test('ByteSwitch', test('T22871', [ extra_run_opts('"' + config.libdir + '"') , req_cmm - , when(arch('i386'), skip) # x86 NCG panics with "iselExpr64(i386)" ], multi_compile_and_run, ['T22871', [('T22871_cmm.cmm', '')], '']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6755d833af8c21bbad6585144b10e20ac4a0a1ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6755d833af8c21bbad6585144b10e20ac4a0a1ab You're receiving 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 Nov 3 12:13:40 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 Nov 2023 08:13:40 -0400 Subject: [Git][ghc/ghc][wip/spj-unf-size] Fix a bad, subtle bug in exprIsConApp_maybe Message-ID: <6544e3f46ead9_27efe93b44b1b02686b@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 3934b269 by Simon Peyton Jones at 2023-11-03T12:12:08+00:00 Fix a bad, subtle bug in exprIsConApp_maybe In extend_in_scope We were simply overwriting useful bindings in the in-scope set, notably ones that had unfoldings. That could lead to repeated simplifier iterations. - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/SimpleOpt.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -920,14 +920,17 @@ substId (SimplEnv { seMode = mode, seInScope = in_scope, seIdSubst = ids }) v Nothing -> DoneId (refineFromInScope mode in_scope v) Just (DoneId v) -> DoneId (refineFromInScope mode in_scope v) Just res -> res -- DoneEx non-var, or ContEx + -- NB: in the DoneEx case we don't need to do refineFromInScope + -- because simplIdF just invokes simplExprF again, which will + -- take another look. - -- Get the most up-to-date thing from the in-scope set - -- Even though it isn't in the substitution, it may be in - -- the in-scope set with better IdInfo. - -- - -- See also Note [In-scope set as a substitution] in GHC.Core.Opt.Simplify. refineFromInScope :: HasDebugCallStack => SimplMode -> InScopeSet -> Var -> Var +-- refineFromInScope: get the most up-to-date thing from the in-scope set +-- Even though it isn't in the substitution, it may be in +-- the in-scope set with better IdInfo. +-- +-- See also Note [In-scope set as a substitution] in GHC.Core.Opt.Simplify. refineFromInScope mode in_scope v | isLocalId v = case lookupInScope in_scope v of Just v' -> v' ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -419,7 +419,7 @@ simplAuxBind env bndr new_rhs -- The cases would be inlined unconditionally by completeBind: -- but it seems not uncommon, and avoids faff to do it here -- This is safe because it's only used for auxiliary bindings, which - -- have no NOLINE pragmas, nor RULEs + -- have no NOINLINE pragmas, nor RULEs | exprIsTrivial new_rhs -- Short-cut for let x = y in ... = return ( emptyFloats env , case new_rhs of @@ -3296,6 +3296,22 @@ simplAlt env scrut' _ case_bndr' cont' (Alt (DataAlt con) vs rhs) ; rhs' <- simplExprC env'' rhs cont' ; return (Alt (DataAlt con) vs' rhs') } + +{- -------- Debugging only ------------- + +ppr_in_scope :: SimplEnv -> SDoc +-- Show only in-scope thing with unfoldings +ppr_in_scope env + = text "InScope(unf)" <+> braces (nonDetStrictFoldVarSet do_one empty (getInScopeVars (seInScope env))) + where + do_one v d | isId v + , Just e <- maybeUnfoldingTemplate (idUnfolding v) + = (ppr v <+> equals <+> my_ppr e) $$ d + | otherwise = d + my_ppr (Lam {}) = text "" + my_ppr e = ppr e +---------------------------------------- -} + {- Note [Adding evaluatedness info to pattern-bound variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ addEvals records the evaluated-ness of the bound variables of @@ -3522,7 +3538,7 @@ knownCon env scrut dc_floats dc dc_ty_args dc_args bndr bs rhs cont -- Nevertheless we must keep it if the case-binder is alive, -- because it may be used in the con_app. See Note [knownCon occ info] ; (floats1, env2) <- simplAuxBind env' b' arg -- arg satisfies let-can-float invariant - ; (floats2, env3) <- bind_args env2 bs' args + ; (floats2, env3) <- bind_args env2 bs' args ; return (floats1 `addFloats` floats2, env3) } bind_args _ _ _ = ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1220,9 +1220,17 @@ data ConCont = CC [CoreExpr] Coercion -- -- We also return the incoming InScopeSet, augmented with -- the binders from any [FloatBind] that we return -exprIsConApp_maybe :: HasDebugCallStack - => InScopeEnv -> CoreExpr - -> Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr]) +exprIsConApp_maybe + :: HasDebugCallStack + => InScopeEnv -- Includes an InScopeSet + -> CoreExpr + -> Maybe ( InScopeSet -- Extends input InScopeSet with the + -- binders of the [FloatingBind] + , [FloatBind] + , DataCon + , [Type] -- Existential type args + , [CoreExpr] -- Arguments satisfy let-can-float invariant + ) exprIsConApp_maybe ise@(ISE in_scope id_unf) expr = go (Left in_scope) [] expr (CC [] (mkRepReflCo (exprType expr))) where @@ -1263,10 +1271,9 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- simplifier produces rhs[exp/a], changing semantics if exp is not ok-for-spec -- Good: returning (Mk#, [x]) with a float of case exp of x { DEFAULT -> [] } -- simplifier produces case exp of a { DEFAULT -> exp[x/a] } - = let arg' = subst_expr subst arg - bndr = uniqAway (subst_in_scope subst) (mkWildValBinder ManyTy arg_type) - float = FloatCase arg' bndr DEFAULT [] - subst' = subst_extend_in_scope subst bndr + = let arg' = subst_expr subst arg + (bndr,subst') = fresh_id subst arg_type + float = FloatCase arg' bndr DEFAULT [] in go subst' (float:floats) fun (CC (Var bndr : args) co) | otherwise = go subst floats fun (CC (subst_expr subst arg : args) co) @@ -1320,8 +1327,8 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- Look through dictionary functions; see Note [Unfolding DFuns] | DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args = dfun_args } <- unfolding , bndrs `equalLength` args -- See Note [DFun arity check] - , let in_scope' = extend_in_scope (exprsFreeVars dfun_args) - subst = mkOpenSubst in_scope' (bndrs `zip` args) + , let -- in_scope' = extend_in_scope (exprsFreeVars dfun_args) + subst = mkOpenSubst in_scope (bndrs `zip` args) -- We extend the in-scope set here to silence warnings from -- substExpr when it finds not-in-scope Ids in dfun_args. -- simplOptExpr initialises the in-scope set with exprFreeVars, @@ -1337,8 +1344,8 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr | idArity fun == 0 , Just rhs <- expandUnfolding_maybe unfolding -- If `fun` is in the in-scope set then the free var of its RHS should be too - , let in_scope' = extend_in_scope (exprFreeVars rhs) - = go (Left in_scope') floats rhs cont +-- , let in_scope' = extend_in_scope (exprFreeVars rhs) + = go (Left in_scope) floats rhs cont -- See Note [exprIsConApp_maybe on literal strings] | (fun `hasKey` unpackCStringIdKey) || @@ -1349,11 +1356,13 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr dealWithStringLiteral fun str co where unfolding = id_unf fun +{- extend_in_scope unf_fvs | isLocalId fun = in_scope `extendInScopeSetSet` unf_fvs | otherwise = in_scope -- A GlobalId has no (LocalId) free variables; and the -- in-scope set tracks only LocalIds +-} go _ _ _ _ = Nothing @@ -1369,11 +1378,15 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- Operations on the (Either InScopeSet GHC.Core.Subst) -- The Left case is wildly dominant - subst_in_scope (Left in_scope) = in_scope - subst_in_scope (Right s) = getSubstInScope s + fresh_id :: Either InScopeSet Subst -> Type -> (Id, Either InScopeSet Subst) + fresh_id (Left in_scope) ty + | let new_id = mk_new_id in_scope ty + = (new_id, Left (in_scope `extendInScopeSet` new_id)) + fresh_id (Right subst) ty + | let new_id = mk_new_id (getSubstInScope subst) ty + = (new_id, Right (subst `extendSubstInScope` new_id)) - subst_extend_in_scope (Left in_scope) v = Left (in_scope `extendInScopeSet` v) - subst_extend_in_scope (Right s) v = Right (s `extendSubstInScope` v) + mk_new_id in_scope ty = uniqAway in_scope (mkWildValBinder ManyTy ty) subst_co (Left {}) co = co subst_co (Right s) co = GHC.Core.Subst.substCo s co View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3934b2690da34782c435b083b81ac61d4d5cc3eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3934b2690da34782c435b083b81ac61d4d5cc3eb You're receiving 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 Nov 3 14:08:46 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 Nov 2023 10:08:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: EPA: Use full range for Anchor Message-ID: <6544feee936cc_27efe93de41f8c301523@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - d1f0555f by Vladislav Zavialov at 2023-11-03T10:07:57-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 27 changed files: - .gitlab-ci.yml - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/ThToHs.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/Utils/Unique.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/required_type_arguments.rst - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/plan-9_4_1.json - hadrian/bootstrap/plan-9_4_2.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbad13e90733dd0f3a254b7606e5e2b13ac7f2b6...d1f0555f54fdf9ea18ce221a0369318ab9fbce6c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbad13e90733dd0f3a254b7606e5e2b13ac7f2b6...d1f0555f54fdf9ea18ce221a0369318ab9fbce6c You're receiving 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 Nov 3 14:23:07 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 03 Nov 2023 10:23:07 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/git_marker Message-ID: <6545024b3e238_27efe93e79e1c030215b@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/git_marker at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/git_marker You're receiving 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 Nov 3 17:25:38 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Fri, 03 Nov 2023 13:25:38 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Fix float -> int conversion (width) Message-ID: <65452d12af3fb_27efe9425b2f38325655@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 15809eba by Sven Tennie at 2023-11-03T18:24:58+01:00 Fix float -> int conversion (width) - - - - - 1 changed file: - compiler/GHC/CmmToAsm/RV64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -692,9 +692,9 @@ pprInstr platform instr = case instr of line (pprOp platform o1 <> text "->" <> pprOp platform o2) FCVTZS o1@(OpReg W32 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.w.s") o1 o2 - FCVTZS o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.w.s") o1 o2 + FCVTZS o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.w.d") o1 o2 FCVTZS o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.l.s") o1 o2 - FCVTZS o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.l.s") o1 o2 + FCVTZS o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.l.d") o1 o2 FCVTZS o1 o2 -> pprPanic "RV64.pprInstr - impossible float to integer conversion" $ line (pprOp platform o1 <> text "->" <> pprOp platform o2) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15809ebaa682fce112d9f09f61cbf615838186fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15809ebaa682fce112d9f09f61cbf615838186fa You're receiving 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 Nov 3 17:51:58 2023 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Fri, 03 Nov 2023 13:51:58 -0400 Subject: [Git][ghc/ghc][wip/wasm32-native-tests] 14 commits: docs: fix ScopedTypeVariables example (#24101) Message-ID: <6545333e7ad68_27efe9431587fc3261b1@gitlab.mail> Cheng Shao pushed to branch wip/wasm32-native-tests at Glasgow Haskell Compiler / GHC Commits: 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 87c0b0f2 by Cheng Shao at 2023-11-03T17:51:47+00:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - 717b5695 by Cheng Shao at 2023-11-03T17:51:47+00:00 testsuite: fix optasm tests for wasm32 - - - - - 0a4f49ba by Matthew Pickering at 2023-11-03T17:51:47+00:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - 29 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.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/Errors/Types/PromotionErr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/scoped_type_variables.rst - docs/users_guide/using-warnings.rst - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/plan-9_4_1.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b68f13e03ab928ec8ff7bc653126033ddf13268d...0a4f49baa3e3728b17e7193536020cd1cc3107ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b68f13e03ab928ec8ff7bc653126033ddf13268d...0a4f49baa3e3728b17e7193536020cd1cc3107ec You're receiving 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 Nov 3 17:57:30 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Fri, 03 Nov 2023 13:57:30 -0400 Subject: [Git][ghc/ghc][wip/az/epa-loca-a-function] EPA: make locA a function, not a field name Message-ID: <6545348a15f3e_27efe9437ef3a43265ef@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-loca-a-function at Glasgow Haskell Compiler / GHC Commits: 1a40f287 by Alan Zimmerman at 2023-11-03T17:56:51+00:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 5 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a40f287a9bd9a474af5eb3feaa405ce0e353662 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a40f287a9bd9a474af5eb3feaa405ce0e353662 You're receiving 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 Nov 3 18:08:52 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 Nov 2023 14:08:52 -0400 Subject: [Git][ghc/ghc][master] Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6545373464d88_27efe943ad2af8333774@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 9 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Utils/Unique.hs - docs/users_guide/9.6.1-notes.rst - testsuite/tests/cmm/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -523,7 +523,6 @@ assignReg_I64Code (CmmLocal dst) valueTree = do assignReg_I64Code _ _ = panic "assignReg_I64Code(i386): invalid lvalue" - iselExpr64 :: HasDebugCallStack => CmmExpr -> NatM (RegCode64 InstrBlock) iselExpr64 (CmmLit (CmmInt i _)) = do Reg64 rhi rlo <- getNewReg64 @@ -550,7 +549,6 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do let Reg64 hi lo = localReg64 local_reg return (RegCode64 nilOL hi lo) --- we handle addition, but rather badly iselExpr64 (CmmMachOp (MO_Add _) [e1, CmmLit (CmmInt i _)]) = do RegCode64 code1 r1hi r1lo <- iselExpr64 e1 Reg64 rhi rlo <- getNewReg64 @@ -590,11 +588,31 @@ iselExpr64 (CmmMachOp (MO_Sub _) [e1,e2]) = do SBB II32 (OpReg r2hi) (OpReg rhi) ] return (RegCode64 code rhi rlo) -iselExpr64 (CmmMachOp (MO_UU_Conv _ W64) [expr]) = do +iselExpr64 (CmmMachOp (MO_UU_Conv W32 W64) [expr]) = do code <- getAnyReg expr Reg64 r_dst_hi r_dst_lo <- getNewReg64 return $ RegCode64 (code r_dst_lo `snocOL` - MOV II32 (OpImm (ImmInt 0)) (OpReg r_dst_hi)) + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi)) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W16 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II16 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_UU_Conv W8 W64) [expr]) = do + (rsrc, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVZxL II8 (OpReg rsrc) (OpReg r_dst_lo), + XOR II32 (OpReg r_dst_hi) (OpReg r_dst_hi) + ]) r_dst_hi r_dst_lo @@ -609,11 +627,208 @@ iselExpr64 (CmmMachOp (MO_SS_Conv W32 W64) [expr]) = do r_dst_hi r_dst_lo +iselExpr64 (CmmMachOp (MO_SS_Conv W16 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II16 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_SS_Conv W8 W64) [expr]) = do + (r, code) <- getByteReg expr + Reg64 r_dst_hi r_dst_lo <- getNewReg64 + return $ RegCode64 (code `appOL` toOL [ + MOVSxL II8 (OpReg r) (OpReg eax), + CLTD II32, + MOV II32 (OpReg eax) (OpReg r_dst_lo), + MOV II32 (OpReg edx) (OpReg r_dst_hi)]) + r_dst_hi + r_dst_lo + +iselExpr64 (CmmMachOp (MO_S_Neg _) [expr]) = do + RegCode64 code rhi rlo <- iselExpr64 expr + Reg64 rohi rolo <- getNewReg64 + let + ocode = code `appOL` + toOL [ MOV II32 (OpReg rlo) (OpReg rolo), + XOR II32 (OpReg rohi) (OpReg rohi), + NEGI II32 (OpReg rolo), + SBB II32 (OpReg rhi) (OpReg rohi) ] + return (RegCode64 ocode rohi rolo) + +-- To multiply two 64-bit numbers we use the following decomposition (in C notation): +-- +-- ((r1hi << 32) + r1lo) * ((r2hi << 32) + r2lo) +-- = ((r2lo * r1hi) << 32) +-- + ((r1lo * r2hi) << 32) +-- + r1lo * r2lo +-- +-- Note that @(r1hi * r2hi) << 64@ can be dropped because it overflows completely. + +iselExpr64 (CmmMachOp (MO_Mul _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + tmp <- getNewRegNat II32 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg eax), + MOV II32 (OpReg r2lo) (OpReg tmp), + MOV II32 (OpReg r1hi) (OpReg rhi), + IMUL II32 (OpReg tmp) (OpReg rhi), + MOV II32 (OpReg r2hi) (OpReg rlo), + IMUL II32 (OpReg eax) (OpReg rlo), + ADD II32 (OpReg rlo) (OpReg rhi), + MUL2 II32 (OpReg tmp), + ADD II32 (OpReg edx) (OpReg rhi), + MOV II32 (OpReg eax) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_S_MulMayOflo W64) _) = do + -- Performance sensitive users won't use 32 bit so let's keep it simple: + -- We always return a (usually false) positive. + Reg64 rhi rlo <- getNewReg64 + let code = toOL [ + MOV II32 (OpImm (ImmInt 1)) (OpReg rhi), + MOV II32 (OpImm (ImmInt 1)) (OpReg rlo) + ] + return (RegCode64 code rhi rlo) + + +-- To shift a 64-bit number to the left we use the SHLD and SHL instructions. +-- We use SHLD to shift the bits in @rhi@ to the left while copying +-- high bits from @rlo@ to fill the new space in the low bits of @rhi at . +-- That leaves @rlo@ unchanged, so we use SHL to shift the bits of @rlo@ left. +-- However, both these instructions only use the lowest 5 bits from %cl to do +-- their shifting. So if the sixth bit (0x32) is set then we additionally move +-- the contents of @rlo@ to @rhi@ and clear @rlo at . + +iselExpr64 (CmmMachOp (MO_Shl _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + code2 <- getAnyReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 ecx `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + SHLD II32 (OpReg ecx) (OpReg rlo) (OpReg rhi), + SHL II32 (OpReg ecx) (OpReg rlo), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rlo) (OpReg rhi), + XOR II32 (OpReg rlo) (OpReg rlo), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to above, however now we're shifting to the right +-- and we're doing a signed shift which means that @rhi@ needs +-- to be set to either 0 if @rhi@ is positive or 0xffffffff otherwise, +-- and if the sixth bit of %cl is set (so the shift amount is more than 32). +-- To accomplish that we shift @rhi@ by 31. + +iselExpr64 (CmmMachOp (MO_S_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SAR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + SAR II32 (OpImm (ImmInt 31)) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +-- Similar to the above. + +iselExpr64 (CmmMachOp (MO_U_Shr _) [e1,e2]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + (r2, code2) <- getSomeReg e2 + Reg64 rhi rlo <- getNewReg64 + lbl1 <- newBlockId + lbl2 <- newBlockId + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + MOV II32 (OpReg r2) (OpReg ecx), + SHRD II32 (OpReg ecx) (OpReg rhi) (OpReg rlo), + SHR II32 (OpReg ecx) (OpReg rhi), + TEST II32 (OpImm (ImmInt 32)) (OpReg ecx), + JXX EQQ lbl2, + JXX ALWAYS lbl1, + NEWBLOCK lbl1, + MOV II32 (OpReg rhi) (OpReg rlo), + XOR II32 (OpReg rhi) (OpReg rhi), + JXX ALWAYS lbl2, + NEWBLOCK lbl2 + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmMachOp (MO_And _) [e1,e2]) = iselExpr64ParallelBin AND e1 e2 +iselExpr64 (CmmMachOp (MO_Or _) [e1,e2]) = iselExpr64ParallelBin OR e1 e2 +iselExpr64 (CmmMachOp (MO_Xor _) [e1,e2]) = iselExpr64ParallelBin XOR e1 e2 + +iselExpr64 (CmmMachOp (MO_Not _) [e1]) = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + NOT II32 (OpReg rlo), + NOT II32 (OpReg rhi) + ] + return (RegCode64 code rhi rlo) + +iselExpr64 (CmmRegOff r i) = iselExpr64 (mangleIndexTree r i) + iselExpr64 expr = do platform <- getPlatform - pprPanic "iselExpr64(i386)" (pdoc platform expr) + pprPanic "iselExpr64(i386)" (pdoc platform expr $+$ text (show expr)) +iselExpr64ParallelBin :: (Format -> Operand -> Operand -> Instr) + -> CmmExpr -> CmmExpr -> NatM (RegCode64 (OrdList Instr)) +iselExpr64ParallelBin op e1 e2 = do + RegCode64 code1 r1hi r1lo <- iselExpr64 e1 + RegCode64 code2 r2hi r2lo <- iselExpr64 e2 + Reg64 rhi rlo <- getNewReg64 + let + code = code1 `appOL` + code2 `appOL` + toOL [ MOV II32 (OpReg r1lo) (OpReg rlo), + MOV II32 (OpReg r1hi) (OpReg rhi), + op II32 (OpReg r2lo) (OpReg rlo), + op II32 (OpReg r2hi) (OpReg rhi) + ] + return (RegCode64 code rhi rlo) -------------------------------------------------------------------------------- getRegister :: CmmExpr -> NatM Register @@ -675,6 +890,18 @@ getRegister' _ is32Bit (CmmMachOp (MO_SS_Conv W64 W32) [x]) RegCode64 code _rhi rlo <- iselExpr64 x return $ Fixed II32 rlo code +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W8) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II8 + return $ Fixed II8 ro (code `appOL` toOL [ MOVZxL II8 (OpReg rlo) (OpReg ro) ]) + +getRegister' _ is32Bit (CmmMachOp (MO_UU_Conv W64 W16) [x]) + | is32Bit = do + RegCode64 code _rhi rlo <- iselExpr64 x + ro <- getNewRegNat II16 + return $ Fixed II16 ro (code `appOL` toOL [ MOVZxL II16 (OpReg rlo) (OpReg ro) ]) + getRegister' _ _ (CmmLit lit@(CmmFloat f w)) = float_const_sse2 where float_const_sse2 @@ -1657,6 +1884,27 @@ machOpToCond mo = case mo of MO_U_Le _ -> LEU _other -> pprPanic "machOpToCond" (pprMachOp mo) +{- Note [64-bit integer comparisons on 32-bit] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + When doing these comparisons there are 2 kinds of + comparisons. + + * Comparison for equality (or lack thereof) + + We use xor to check if high/low bits are + equal. Then combine the results using or. + + * Other comparisons: + + We first compare the low registers + and use a subtraction with borrow to compare the high registers. + + For signed numbers the condition is determined by + the sign and overflow flags agreeing or not + and for unsigned numbers the condition is the carry flag. + +-} -- @cond(Int|Flt)Code@: Turn a boolean expression into a condition, to be -- passed back up the tree. @@ -1667,6 +1915,68 @@ condIntCode cond x y = do platform <- getPlatform condIntCode' :: Platform -> Cond -> CmmExpr -> CmmExpr -> NatM CondCode +-- 64-bit integer comparisons on 32-bit +-- See Note [64-bit integer comparisons on 32-bit] +condIntCode' platform cond x y + | target32Bit platform && isWord64 (cmmExprType platform x) = do + + RegCode64 code1 r1hi r1lo <- iselExpr64 x + RegCode64 code2 r2hi r2lo <- iselExpr64 y + + -- we mustn't clobber r1/r2 so we use temporaries + tmp1 <- getNewRegNat II32 + tmp2 <- getNewRegNat II32 + + let (cond', cmpCode) = intComparison cond r1hi r1lo r2hi r2lo tmp1 tmp2 + return $ CondCode False cond' (code1 `appOL` code2 `appOL` cmpCode) + + where + intComparison cond r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = + case cond of + -- These don't occur as argument of condIntCode' + ALWAYS -> panic "impossible" + NEG -> panic "impossible" + POS -> panic "impossible" + CARRY -> panic "impossible" + OFLO -> panic "impossible" + PARITY -> panic "impossible" + NOTPARITY -> panic "impossible" + -- Special case #1 x == y and x != y + EQQ -> (EQQ, cmpExact) + NE -> (NE, cmpExact) + -- [x >= y] + GE -> (GE, cmpGE) + GEU -> (GEU, cmpGE) + -- [x > y] + GTT -> (LTT, cmpLE) + GU -> (LU, cmpLE) + -- [x <= y] + LE -> (GE, cmpLE) + LEU -> (GEU, cmpLE) + -- [x < y] + LTT -> (LTT, cmpGE) + LU -> (LU, cmpGE) + where + cmpExact :: OrdList Instr + cmpExact = + toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , MOV II32 (OpReg r1_lo) (OpReg tmp2) + , XOR II32 (OpReg r2_hi) (OpReg tmp1) + , XOR II32 (OpReg r2_lo) (OpReg tmp2) + , OR II32 (OpReg tmp1) (OpReg tmp2) + ] + cmpGE = toOL + [ MOV II32 (OpReg r1_hi) (OpReg tmp1) + , CMP II32 (OpReg r2_lo) (OpReg r1_lo) + , SBB II32 (OpReg r2_hi) (OpReg tmp1) + ] + cmpLE = toOL + [ MOV II32 (OpReg r2_hi) (OpReg tmp1) + , CMP II32 (OpReg r1_lo) (OpReg r2_lo) + , SBB II32 (OpReg r1_hi) (OpReg tmp1) + ] + -- memory vs immediate condIntCode' platform cond (CmmLoad x pk _) (CmmLit lit) | is32BitLit platform lit = do @@ -1881,36 +2191,6 @@ I386: First, we have to ensure that the condition codes are set according to the supplied comparison operation. -} -{- Note [64-bit integer comparisons on 32-bit] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - When doing these comparisons there are 2 kinds of - comparisons. - - * Comparison for equality (or lack thereof) - - We use xor to check if high/low bits are - equal. Then combine the results using or and - perform a single conditional jump based on the - result. - - * Other comparisons: - - We map all other comparisons to the >= operation. - Why? Because it's easy to encode it with a single - conditional jump. - - We do this by first computing [r1_lo - r2_lo] - and use the carry flag to compute - [r1_high - r2_high - CF]. - - At which point if r1 >= r2 then the result will be - positive. Otherwise negative so we can branch on this - condition. - --} - - genCondBranch :: BlockId -- the source of the jump -> BlockId -- the true branch target @@ -1926,67 +2206,6 @@ genCondBranch bid id false expr = do genCondBranch' :: Bool -> BlockId -> BlockId -> BlockId -> CmmExpr -> NatM InstrBlock --- 64-bit integer comparisons on 32-bit --- See Note [64-bit integer comparisons on 32-bit] -genCondBranch' is32Bit _bid true false (CmmMachOp mop [e1,e2]) - | is32Bit, Just W64 <- maybeIntComparison mop = do - - RegCode64 code1 r1hi r1lo <- iselExpr64 e1 - RegCode64 code2 r2hi r2lo <- iselExpr64 e2 - let cond = machOpToCond mop :: Cond - - -- we mustn't clobber r1/r2 so we use temporaries - tmp1 <- getNewRegNat II32 - tmp2 <- getNewRegNat II32 - - let cmpCode = intComparison cond true false r1hi r1lo r2hi r2lo tmp1 tmp2 - return $ code1 `appOL` code2 `appOL` cmpCode - - where - intComparison cond true false r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 = - case cond of - -- Impossible results of machOpToCond - ALWAYS -> panic "impossible" - NEG -> panic "impossible" - POS -> panic "impossible" - CARRY -> panic "impossible" - OFLO -> panic "impossible" - PARITY -> panic "impossible" - NOTPARITY -> panic "impossible" - -- Special case #1 x == y and x != y - EQQ -> cmpExact - NE -> cmpExact - -- [x >= y] - GE -> cmpGE - GEU -> cmpGE - -- [x > y] <==> ![y >= x] - GTT -> intComparison GE false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - GU -> intComparison GEU false true r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x <= y] <==> [y >= x] - LE -> intComparison GE true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - LEU -> intComparison GEU true false r2_hi r2_lo r1_hi r1_lo tmp1 tmp2 - -- [x < y] <==> ![x >= x] - LTT -> intComparison GE false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - LU -> intComparison GEU false true r1_hi r1_lo r2_hi r2_lo tmp1 tmp2 - where - cmpExact :: OrdList Instr - cmpExact = - toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , MOV II32 (OpReg r1_lo) (OpReg tmp2) - , XOR II32 (OpReg r2_hi) (OpReg tmp1) - , XOR II32 (OpReg r2_lo) (OpReg tmp2) - , OR II32 (OpReg tmp1) (OpReg tmp2) - , JXX cond true - , JXX ALWAYS false - ] - cmpGE = toOL - [ MOV II32 (OpReg r1_hi) (OpReg tmp1) - , CMP II32 (OpReg r2_lo) (OpReg r1_lo) - , SBB II32 (OpReg r2_hi) (OpReg tmp1) - , JXX cond true - , JXX ALWAYS false ] - genCondBranch' _ bid id false bool = do CondCode is_float cond cond_code <- getCondCode bool use_sse2 <- sse2Enabled ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -249,6 +249,8 @@ data Instr | SHL Format Operand{-amount-} Operand | SAR Format Operand{-amount-} Operand | SHR Format Operand{-amount-} Operand + | SHRD Format Operand{-amount-} Operand Operand + | SHLD Format Operand{-amount-} Operand Operand | BT Format Imm Operand | NOP @@ -399,6 +401,8 @@ regUsageOfInstr platform instr SHL _ imm dst -> usageRM imm dst SAR _ imm dst -> usageRM imm dst SHR _ imm dst -> usageRM imm dst + SHLD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 + SHRD _ imm dst1 dst2 -> usageRMM imm dst1 dst2 BT _ _ src -> mkRUR (use_R src []) PUSH _ op -> mkRUR (use_R op []) @@ -568,6 +572,8 @@ patchRegsOfInstr instr env SHL fmt imm dst -> patch1 (SHL fmt imm) dst SAR fmt imm dst -> patch1 (SAR fmt imm) dst SHR fmt imm dst -> patch1 (SHR fmt imm) dst + SHLD fmt imm dst1 dst2 -> patch2 (SHLD fmt imm) dst1 dst2 + SHRD fmt imm dst1 dst2 -> patch2 (SHRD fmt imm) dst1 dst2 BT fmt imm src -> patch1 (BT fmt imm) src TEST fmt src dst -> patch2 (TEST fmt) src dst CMP fmt src dst -> patch2 (CMP fmt) src dst ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -732,6 +732,12 @@ pprInstr platform i = case i of SHR format src dst -> pprShift (text "shr") format src dst + SHLD format src dst1 dst2 + -> pprShift2 (text "shld") format src dst1 dst2 + + SHRD format src dst1 dst2 + -> pprShift2 (text "shrd") format src dst1 dst2 + BT format imm src -> pprFormatImmOp (text "bt") format imm src @@ -1070,6 +1076,17 @@ pprInstr platform i = case i of pprOperand platform format dest ] + pprShift2 :: Line doc -> Format -> Operand -> Operand -> Operand -> doc + pprShift2 name format src dest1 dest2 + = line $ hcat [ + pprMnemonic name format, + pprOperand platform II8 src, -- src is 8-bit sized + comma, + pprOperand platform format dest1, + comma, + pprOperand platform format dest2 + ] + pprFormatOpOpCoerce :: Line doc -> Format -> Format -> Operand -> Operand -> doc pprFormatOpOpCoerce name format1 format2 op1 op2 ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -53,7 +53,8 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmDoBoundsCheck = gopt Opt_DoBoundsChecking dflags , stgToCmmDoTagCheck = gopt Opt_DoTagInferenceChecks dflags -- backend flags - , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 + , stgToCmmAllowBigArith = not ncg || platformArch platform == ArchWasm32 || platformArch platform == ArchX86 + , stgToCmmAllowBigQuot = not ncg || platformArch platform == ArchWasm32 , stgToCmmAllowQuotRemInstr = ncg && (x86ish || ppc) , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm ===================================== compiler/GHC/StgToCmm/Config.hs ===================================== @@ -65,6 +65,7 @@ data StgToCmmConfig = StgToCmmConfig , stgToCmmDoTagCheck :: !Bool -- ^ Verify tag inference predictions. ------------------------------ Backend Flags ---------------------------------- , stgToCmmAllowBigArith :: !Bool -- ^ Allowed to emit larger than native size arithmetic (only LLVM and C backends) + , stgToCmmAllowBigQuot :: !Bool -- ^ Allowed to emit larger than native size division operations , stgToCmmAllowQuotRemInstr :: !Bool -- ^ Allowed to generate QuotRem instructions , stgToCmmAllowQuotRem2 :: !Bool -- ^ Allowed to generate QuotRem , stgToCmmAllowExtendedAddSubInstrs :: !Bool -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc. ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1682,6 +1682,13 @@ emitPrimOp cfg primop = let stmt = mkAssign (CmmLocal res) (CmmMachOp mop args) emit stmt + isQuottishOp :: CallishMachOp -> Bool + isQuottishOp MO_I64_Quot = True + isQuottishOp MO_I64_Rem = True + isQuottishOp MO_W64_Quot = True + isQuottishOp MO_W64_Rem = True + isQuottishOp _ = False + opTranslate64 :: [CmmExpr] -> (Width -> MachOp) @@ -1690,7 +1697,8 @@ emitPrimOp cfg primop = opTranslate64 args mkMop callish = case platformWordSize platform of -- LLVM and C `can handle larger than native size arithmetic natively. - _ | stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + _ | not (isQuottishOp callish), stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64 + | isQuottishOp callish, stgToCmmAllowBigQuot cfg -> opTranslate args $ mkMop W64 PW4 -> opCallish args callish PW8 -> opTranslate args $ mkMop W64 ===================================== compiler/GHC/Utils/Unique.hs ===================================== @@ -2,12 +2,12 @@ {- Work around #23537 -On 32 bit systems, GHC's codegen around 64 bit numbers is not quite -complete. This led to panics mentioning missing cases in iselExpr64. -Now that GHC uses Word64 for its uniques, these panics have started -popping up whenever a unique is compared to many other uniques in one -function. As a workaround we use these two functions which are not -inlined on 32 bit systems, thus preventing the panics. +On 32 bit systems, GHC's codegen around 64 bit numbers used to be incomplete +before GHC 9.10. This led to panics mentioning missing cases in iselExpr64. +Now that GHC uses Word64 for its uniques, these panics have started popping up +whenever a unique is compared to many other uniques in one function. As a +workaround we use these two functions which are not inlined, on 32 bit systems +and if compiled with versions before GHC 9.9, thus preventing the panics. -} module GHC.Utils.Unique (sameUnique, anyOfUnique) where @@ -18,7 +18,7 @@ import GHC.Prelude.Basic (Bool, Eq((==)), Foldable(elem)) import GHC.Types.Unique (Unique, Uniquable (getUnique)) -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE sameUnique #-} #else {-# INLINE sameUnique #-} @@ -26,7 +26,7 @@ import GHC.Types.Unique (Unique, Uniquable (getUnique)) sameUnique :: Uniquable a => a -> a -> Bool sameUnique x y = getUnique x == getUnique y -#if WORD_SIZE_IN_BITS == 32 +#if WORD_SIZE_IN_BITS == 32 && !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0) {-# NOINLINE anyOfUnique #-} #else {-# INLINE anyOfUnique #-} ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -122,7 +122,7 @@ Compiler that targets ``wasm32-wasi`` and compiles Haskell code to self-contained WebAssembly modules that can be executed on a variety of different runtimes. There are a few caveats to be aware of: - + - To use the WebAssembly backend, one would need to follow the instructions on `ghc-wasm-meta `_. The WebAssembly @@ -149,6 +149,9 @@ Compiler - The :ghc-flag:`-Wstar-is-type` warning is now enabled by default. +- The 32bit x86 NCG backend will now generate inline assembly for most common 64bit + operations. This improves Int64/Word64 performance substantially on this platform. + GHCi ~~~~ ===================================== testsuite/tests/cmm/should_run/all.T ===================================== @@ -27,7 +27,6 @@ test('ByteSwitch', test('T22871', [ extra_run_opts('"' + config.libdir + '"') , req_cmm - , when(arch('i386'), skip) # x86 NCG panics with "iselExpr64(i386)" ], multi_compile_and_run, ['T22871', [('T22871_cmm.cmm', '')], '']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6755d833af8c21bbad6585144b10e20ac4a0a1ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6755d833af8c21bbad6585144b10e20ac4a0a1ab You're receiving 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 Nov 3 18:09:37 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 Nov 2023 14:09:37 -0400 Subject: [Git][ghc/ghc][master] T2T in Expressions (#23738) Message-ID: <654537619860e_27efe943c8196c3374ec@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 27 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - docs/users_guide/exts/required_type_arguments.rst - testsuite/tests/diagnostic-codes/codes.stdout - testsuite/tests/vdq-rta/should_compile/T22326_idv.hs - + testsuite/tests/vdq-rta/should_compile/T23738_basic.hs - + testsuite/tests/vdq-rta/should_compile/T23738_nested.hs - + testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs - + testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs - + testsuite/tests/vdq-rta/should_compile/T23738_th.hs - + testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs - + testsuite/tests/vdq-rta/should_compile/T23738_wild.hs - testsuite/tests/vdq-rta/should_compile/all.T - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr - testsuite/tests/vdq-rta/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -208,8 +208,6 @@ data EpAnnUnboundVar = EpAnnUnboundVar , hsUnboundHole :: EpaLocation } deriving Data -type instance XVar (GhcPass _) = NoExtField - -- Record selectors at parse time are HsVar; they convert to HsRecSel -- on renaming. type instance XRecSel GhcPs = DataConCantHappen @@ -430,6 +428,13 @@ tupArgPresent :: HsTupArg (GhcPass p) -> Bool tupArgPresent (Present {}) = True tupArgPresent (Missing {}) = False +tupArgPresent_maybe :: HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p)) +tupArgPresent_maybe (Present _ e) = Just e +tupArgPresent_maybe (Missing {}) = Nothing + +tupArgsPresent_maybe :: [HsTupArg (GhcPass p)] -> Maybe [LHsExpr (GhcPass p)] +tupArgsPresent_maybe = traverse tupArgPresent_maybe + {- ********************************************************************* * * ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -277,6 +277,14 @@ instance Diagnostic TcRnMessage where sole_msg = vcat [ text "except as the sole constraint" , nest 2 (text "e.g., deriving instance _ => Eq (Foo a)") ] + TcRnIllegalNamedWildcardInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal named wildcard in a required type argument:") + 2 (quotes (ppr rdr)) + TcRnIllegalImplicitTyVarInTypeArgument rdr + -> mkSimpleDecorated $ + hang (text "Illegal implicitly quantified type variable in a required type argument:") + 2 (quotes (ppr rdr)) TcRnDuplicateFieldName fld_part dups -> mkSimpleDecorated $ hsep [ text "Duplicate field name" @@ -1253,9 +1261,7 @@ instance Diagnostic TcRnMessage where text "A type pattern must be checked against a visible forall." TcRnIllformedTypeArgument e -> mkSimpleDecorated $ - hang (text "Ill-formed type argument:") 2 (ppr e) $$ - text "Expected a type expression introduced with the" - <+> quotes (text "type") <+> text "keyword." + hang (text "Ill-formed type argument:") 2 (ppr e) TcRnIllegalTypeExpr -> mkSimpleDecorated $ text "Illegal type expression." $$ @@ -1956,6 +1962,10 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnIllegalWildcardInType{} -> ErrorWithoutFlag + TcRnIllegalNamedWildcardInTypeArgument{} + -> ErrorWithoutFlag + TcRnIllegalImplicitTyVarInTypeArgument{} + -> ErrorWithoutFlag TcRnDuplicateFieldName{} -> ErrorWithoutFlag TcRnIllegalViewPattern{} @@ -2576,6 +2586,10 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.RecordWildCards] TcRnIllegalWildcardInType{} -> noHints + TcRnIllegalNamedWildcardInTypeArgument{} + -> [SuggestAnonymousWildcard] + TcRnIllegalImplicitTyVarInTypeArgument tv + -> [SuggestExplicitQuantification tv] TcRnDuplicateFieldName{} -> noHints TcRnIllegalViewPattern{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -712,6 +712,37 @@ data TcRnMessage where -> !BadAnonWildcardContext -> TcRnMessage + {-| TcRnIllegalNamedWildcardInTypeArgument is an error that occurs + when a named wildcard is used in a required type argument. + + Example: + + vfun :: forall (a :: k) -> () + x = vfun _nwc + -- ^^^^ + -- named wildcards not allowed in type arguments + + Test cases: + T23738_fail_wild + -} + TcRnIllegalNamedWildcardInTypeArgument + :: RdrName + -> TcRnMessage + + {- TcRnIllegalImplicitTyVarInTypeArgument is an error raised + when a type variable is implicitly quantified in a required type argument. + + Example: + vfun :: forall (a :: k) -> () + x = vfun (Nothing :: Maybe a) + -- ^^^ + -- implicit quantification not allowed in type arguments + + -} + TcRnIllegalImplicitTyVarInTypeArgument + :: RdrName + -> TcRnMessage + {-| TcRnDuplicateFieldName is an error that occurs whenever there are duplicate field names in a single record. @@ -4131,16 +4162,12 @@ data TcRnMessage where that specifies a required type argument (instantiates a visible forall) does not have a form that can be interpreted as a type argument. - At the moment, only expressions constructed using the @type@ keyword - are considered well-formed, but this restriction will be relaxed - when part 2 of GHC Proposal #281 is implemented. - Example: vfun :: forall (a :: k) -> () - x = vfun Int - -- ^^^ - -- expected `type Int` instead of `Int` + x = vfun (\_ -> _) + -- ^^^^^^^^^ + -- lambdas not allowed in type arguments Test cases: T22326_fail_raw_arg ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -23,6 +23,7 @@ import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcPolyExpr ) import GHC.Types.Var import GHC.Builtin.Types ( multiplicityTy ) import GHC.Tc.Gen.Head +import Language.Haskell.Syntax.Basic import GHC.Hs import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad @@ -51,8 +52,10 @@ import GHC.Builtin.Names import GHC.Driver.DynFlags import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Var.Env ( emptyTidyEnv, mkInScopeSet ) +import GHC.Types.SourceText import GHC.Data.Maybe import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable @@ -806,10 +809,210 @@ tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism ch -> LHsExpr GhcRn -- Argument type -> TcM (TcType, TcType) tcVDQ conc_tvs (tvb, inner_ty) arg - = do { hs_ty <- case stripParensLHsExpr arg of - L _ (HsEmbTy _ _ hs_ty) -> return hs_ty - e -> failWith $ TcRnIllformedTypeArgument e - ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_ty } + = do { hs_wc_ty <- expr_to_type arg + ; tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_wc_ty } + +-- Convert a HsExpr into the equivalent HsType. +-- See [RequiredTypeArguments and the T2T mapping] +expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) +expr_to_type earg = + case stripParensLHsExpr earg of + L _ (HsEmbTy _ _ hs_ty) -> + -- The entire type argument is guarded with the `type` herald, + -- e.g. `vfun (type (Maybe Int))`. This special case supports + -- named wildcards. See Note [Wildcards in the T2T translation] + return hs_ty + e -> + -- The type argument is not guarded with the `type` herald, or perhaps + -- only parts of it are, e.g. `vfun (Maybe Int)` or `vfun (Maybe (type Int))`. + -- Apply a recursive T2T transformation. + HsWC [] <$> go e + where + go :: LHsExpr GhcRn -> TcM (LHsType GhcRn) + go (L _ (HsEmbTy _ _ t)) = + -- HsEmbTy means there is an explicit `type` herald, e.g. vfun :: forall a -> blah + -- and the call vfun (type Int) + -- or vfun (Int -> type Int) + -- The T2T transformation can simply discard the herald and use the embedded type. + unwrap_wc t + go (L l (HsVar _ lname)) = + -- as per #281: variables and constructors (regardless of their namespace) + -- are mapped directly, without modification. + return (L l (HsTyVar noAnn NotPromoted lname)) + go (L l (HsApp _ lhs rhs)) = + do { lhs' <- go lhs + ; rhs' <- go rhs + ; return (L l (HsAppTy noExtField lhs' rhs')) } + go (L l (HsAppType _ lhs at rhs)) = + do { lhs' <- go lhs + ; rhs' <- unwrap_wc rhs + ; return (L l (HsAppKindTy noExtField lhs' at rhs')) } + go (L l e@(OpApp _ lhs op rhs)) = + do { lhs' <- go lhs + ; op' <- go op + ; rhs' <- go rhs + ; op_id <- unwrap_op_tv op' + ; return (L l (HsOpTy noAnn NotPromoted lhs' op_id rhs')) } + where + unwrap_op_tv (L _ (HsTyVar _ _ op_id)) = return op_id + unwrap_op_tv _ = failWith $ TcRnIllformedTypeArgument (L l e) + go (L l e@(HsOverLit _ lit)) = + do { tylit <- case ol_val lit of + HsIntegral n -> return $ HsNumTy NoSourceText (il_value n) + HsIsString _ s -> return $ HsStrTy NoSourceText s + HsFractional _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l e@(HsLit _ lit)) = + do { tylit <- case lit of + HsChar _ c -> return $ HsCharTy NoSourceText c + HsString _ s -> return $ HsStrTy NoSourceText s + _ -> failWith $ TcRnIllformedTypeArgument (L l e) + ; return (L l (HsTyLit noExtField tylit)) } + go (L l (ExplicitTuple _ tup_args boxity)) + -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be promoted + | isBoxed boxity + , Just es <- tupArgsPresent_maybe tup_args + = do { ts <- traverse go es + ; return (L l (HsExplicitTupleTy noExtField ts)) } + go (L l (ExplicitList _ es)) = + do { ts <- traverse go es + ; return (L l (HsExplicitListTy noExtField NotPromoted ts)) } + go (L l (ExprWithTySig _ e sig_ty)) = + do { t <- go e + ; sig_ki <- (unwrap_sig <=< unwrap_wc) sig_ty + ; return (L l (HsKindSig noAnn t sig_ki)) } + where + unwrap_sig :: LHsSigType GhcRn -> TcM (LHsType GhcRn) + unwrap_sig (L _ (HsSig _ HsOuterImplicit{hso_ximplicit=bndrs} body)) + | null bndrs = return body + | otherwise = illegal_implicit_tvs bndrs + unwrap_sig (L l (HsSig _ HsOuterExplicit{hso_bndrs=bndrs} body)) = + return $ L l (HsForAllTy noExtField (HsForAllInvis noAnn bndrs) body) + go (L l (HsPar _ _ e _)) = + do { t <- go e + ; return (L l (HsParTy noAnn t)) } + go (L l (HsUntypedSplice splice_result splice)) + | HsUntypedSpliceTop finalizers e <- splice_result + = do { t <- go (L l e) + ; let splice_result' = HsUntypedSpliceTop finalizers t + ; return (L l (HsSpliceTy splice_result' splice)) } + go (L l (HsUnboundVar _ rdr)) + | isUnderscore occ = return (L l (HsWildCardTy noExtField)) + | startsWithUnderscore occ = + -- See Note [Wildcards in the T2T translation] + do { wildcards_enabled <- xoptM LangExt.NamedWildCards + ; if wildcards_enabled + then illegal_wc rdr + else not_in_scope } + | otherwise = not_in_scope + where occ = occName rdr + not_in_scope = failWith $ mkTcRnNotInScope rdr NotInScope + go (L l (XExpr (HsExpanded orig _))) = + -- Use the original, user-written expression (before expansion). + -- Example. Say we have vfun :: forall a -> blah + -- and the call vfun (Maybe [1,2,3]) + -- expanded to vfun (Maybe (fromListN 3 [1,2,3])) + -- (This happens when OverloadedLists is enabled). + -- The expanded expression can't be promoted, as there is no type-level + -- equivalent of fromListN, so we must use the original. + go (L l orig) + go e = failWith $ TcRnIllformedTypeArgument e + + unwrap_wc :: HsWildCardBndrs GhcRn t -> TcM t + unwrap_wc (HsWC wcs t) + = do { mapM_ (illegal_wc . nameRdrName) wcs + ; return t } + + illegal_wc :: RdrName -> TcM t + illegal_wc rdr = failWith $ TcRnIllegalNamedWildcardInTypeArgument rdr + + illegal_implicit_tvs :: [Name] -> TcM t + illegal_implicit_tvs tvs + = do { mapM_ (addErr . TcRnIllegalImplicitTyVarInTypeArgument . nameRdrName) tvs + ; failM } + +{- Note [RequiredTypeArguments and the T2T mapping] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The "T2T-Mapping" section of GHC Proposal #281 introduces a term-to-type transformation +that comes into play when we typecheck function applications to required type arguments. +Say we have a function that expects a required type argument, vfun :: forall a -> ... +then it is possible to call it as follows: + + vfun (Maybe Int) + +The Maybe Int argument is parsed and renamed as a term. There is no syntactic marker +to tell GHC that it is actually a type argument. We only discover this by the time +we get to type checking, where we know that f's type has a visible forall at the front, +so we are expecting a type argument. More precisely, this happens in tcVDQ in GHC/Tc/Gen/App.hs: + + tcVDQ :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] + -> (ForAllTyBinder, TcType) -- Function type + -> LHsExpr GhcRn -- Argument type + -> TcM (TcType, TcType) + +What we want is a type to instantiate the forall-bound variable. But what we have is an HsExpr, +and we need to convert it to an HsType in order to reuse the same code paths as we use for +checking f @ty (see tc_inst_forall_arg). + + f (Maybe Int) + -- ^^^^^^^^^ + -- parsed and renamed as: HsApp (HsVar "Maybe") (HsVar "Int") :: HsExpr GhcRn + -- must be converted to: HsTyApp (HsTyVar "Maybe") (HsTyVar "Int") :: HsType GhcRn + +We do this using a helper function: + + expr_to_type :: LHsExpr GhcRn -> TcM (LHsWcType GhcRn) + +This conversion is in the TcM monad because +* It can fail, if the expression is not convertible to a type. + vfun [x | x <- xs] Can't convert list comprehension to a type + vfun (\x -> x) Can't convert a lambda to a type +* It needs to check for LangExt.NamedWildCards to generate an appropriate + error message for HsUnboundVar. + vfun _a Not in scope: ‘_a’ + (NamedWildCards disabled) + vfun _a Illegal named wildcard in a required type argument: ‘_a’ + (NamedWildCards enabled) + +Note [Wildcards in the T2T translation] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose f1 :: forall a b. blah + f2 :: forall a b -> blah + +Consider the terms + f1 @_ @(Either _ _) + f2 (type _) (type (Either _ _)) +Those `_` wildcards are type wildcards, each standing for a monotype. +All good. + +Now consider this, with -XNamedWildCards: + f1 @_a @(Either _a _a) + f2 (type _a) (type (Either _a _a)) +Those `_a` are "named wildcards", specified by the user manual like this: "All +occurrences of the same named wildcard within one type signature will unify to +the same type". Note "within one signature". So each type argument is considered +separately, and the examples mean the same as: + f1 @_a1 @(Either _a2 _a2) + f2 (type _a1) (type (Either _a2 _a2)) +The repeated `_a2` ensures that the two arguments of `Either` are the same type; +but there is no connection with `_a1`. (NB: `_a1` and `_a2` only scope within +their respective type, no further.) + +Now, consider the T2T translation for + f2 _ (Either _ _) +This is fine: the term wildcard `_` is translated to a type wildcard, so we get +the same as if we had written + f2 (type _) (type (Either _ _)) + +But what about /named/ wildcards? + f2 _a (Either _a _a) +Now we are in difficulties. The renamer looks for a /term/ variable `_a` in scope, +and won't find one. Even if it did, the three `_a`'s would not be renamed separately +as above. + +Conclusion: we treat a named wildcard in the T2T translation as an error. If you +want that, use a `(type ty)` argument instead. +-} tc_inst_forall_arg :: ConcreteTyVars -- See Note [Representation-polymorphism checking built-ins] -> (ForAllTyBinder, TcType) -- Function type @@ -890,7 +1093,7 @@ At a call site we may have calls looking like this fs True -- Specified: type argument omitted fs @Bool True -- Specified: type argument supplied fr (type Bool) True -- Required: type argument is compulsory, `type` qualifier used - fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted (NB: not implemented) + fr Bool True -- Required: type argument is compulsory, `type` qualifier omitted At definition sites we may have type /patterns/ to abstract over type variables fi x = rhs -- Inferred: no type pattern @@ -953,8 +1156,8 @@ Syntax of applications in HsExpr Why the difference? Because we /also/ need to express these /nested/ uses of `type`: - g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) - g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t (NB. not implemented) + g (Maybe (type Int)) -- valid for g :: forall (a :: Type) -> t + g (Either (type Int) (type Bool)) -- valid for g :: forall (a :: Type) -> t This nesting makes `type` rather different from `@`. Remember, the HsEmbTy mainly just switches namespace, and is subject to the term-to-type transformation. @@ -993,7 +1196,7 @@ rnExpr delegates renaming of type arguments to rnHsWcType if possible: f (type t) -- HsApp and HsEmbTy, t is renamed with rnHsWcType But what about: - f t -- HsApp, no HsEmbTy (NB. not implemented) + f t -- HsApp, no HsEmbTy We simply rename `t` as a term using a recursive call to rnExpr; in particular, the type of `f` does not affect name resolution (Lexical Scoping Principle). We will later convert `t` from a `HsExpr` to a `Type`, see "Typechecking type @@ -1057,7 +1260,7 @@ This is done by tcVTA (if Specified) and tcVDQ (if Required). tcVDQ unwraps the HsEmbTy and uses the type contained within it. Crucially, in tcVDQ we know that we are expecting a type argument. This means that we can support - f (Maybe Int) -- HsApp, no HsEmbTy (NB. not implemented) + f (Maybe Int) -- HsApp, no HsEmbTy The type argument (Maybe Int) is represented as an HsExpr, but tcVDQ can easily convert it to HsType. This conversion is called the "T2T-Mapping" in GHC Proposal #281. ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -369,6 +369,8 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnIllegalFieldPunning" = 44287 GhcDiagnosticCode "TcRnIllegalWildcardsInRecord" = 37132 GhcDiagnosticCode "TcRnIllegalWildcardInType" = 65507 + GhcDiagnosticCode "TcRnIllegalNamedWildcardInTypeArgument" = 93411 + GhcDiagnosticCode "TcRnIllegalImplicitTyVarInTypeArgument" = 80557 GhcDiagnosticCode "TcRnDuplicateFieldName" = 85524 GhcDiagnosticCode "TcRnIllegalViewPattern" = 22406 GhcDiagnosticCode "TcRnCharLiteralOutOfRange" = 17268 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -474,6 +474,12 @@ data GhcHint -} | SuggestBindTyVarOnLhs RdrName + {-| Suggest using an anonymous wildcard instead of a named wildcard -} + | SuggestAnonymousWildcard + + {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} + | SuggestExplicitQuantification RdrName + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -266,6 +266,11 @@ instance Outputable GhcHint where ppr_r = quotes $ ppr r SuggestBindTyVarOnLhs tv -> text "Bind" <+> quotes (ppr tv) <+> text "on the LHS of the type declaration" + SuggestAnonymousWildcard + -> text "Use an anonymous wildcard" <+> quotes (text "_") + SuggestExplicitQuantification tv + -> hsep [ text "Use an explicit", quotes (text "forall") + , text "to quantify over", quotes (ppr tv) ] perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -80,7 +80,7 @@ module GHC.Types.Name.Occurrence ( isVarOcc, isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc, isFieldOcc, fieldOcc_maybe, - parenSymOcc, startsWithUnderscore, + parenSymOcc, startsWithUnderscore, isUnderscore, isTcClsNameSpace, isTvNameSpace, isDataConNameSpace, isVarNameSpace, isValNameSpace, isFieldNameSpace, isTermVarOrFieldNameSpace, @@ -912,6 +912,9 @@ startsWithUnderscore occ = case unpackFS (occNameFS occ) of '_':_ -> True _ -> False +isUnderscore :: OccName -> Bool +isUnderscore occ = occNameFS occ == fsLit "_" + {- ************************************************************************ * * ===================================== docs/users_guide/exts/required_type_arguments.rst ===================================== @@ -107,7 +107,5 @@ indistinguishble from ordinary function arguments:: n = id_vdq Integer 42 In this example we pass ``Integer`` as opposed to ``(type Integer)``. -**This is not currently implemented**, but it demonstrates how -:extension:`RequiredTypeArguments` is not tied to the ``type`` syntax. -For this reason, using the ``type`` syntax requires enabling the -:extension:`ExplicitNamespaces` extension separately. \ No newline at end of file +This means that :extension:`RequiredTypeArguments` is not tied to the ``type`` +syntax, which belongs to :extension:`ExplicitNamespaces`. \ No newline at end of file ===================================== testsuite/tests/diagnostic-codes/codes.stdout ===================================== @@ -65,7 +65,6 @@ [GHC-85337] is untested (constructor = TcRnSpecialiseNotVisible) [GHC-91382] is untested (constructor = TcRnIllegalKindSignature) [GHC-72520] is untested (constructor = TcRnIgnoreSpecialisePragmaOnDefMethod) -[GHC-10969] is untested (constructor = TcRnTyThingUsedWrong) [GHC-61072] is untested (constructor = TcRnGADTDataContext) [GHC-16409] is untested (constructor = TcRnMultipleConForNewtype) [GHC-54478] is untested (constructor = TcRnRedundantSourceImport) ===================================== testsuite/tests/vdq-rta/should_compile/T22326_idv.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RequiredTypeArguments #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE NamedWildCards #-} module T22326_idv where @@ -38,4 +39,8 @@ idv_wild (type _) x = x -- Usage (using a wildcard) rBool' = idv (type _) True -rChar' = idv (type _) 'x' \ No newline at end of file +rChar' = idv (type _) 'x' + +-- Usage (using named wildcards) +rMaybeX = idv (type (Maybe _a)) Nothing +rEitherCharChar = idv (type (Either _a _a)) (Left 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_basic.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Overloaded string literals checked in T23738_overlit. +{-# LANGUAGE NoOverloadedStrings #-} + +module T23738_basic where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2])) + {- term syntax: -} (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_nested.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_nested where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + (type (Either Int Bool)) + (Either (type Int) (type Bool)) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +-- Non-overloaded string literals checked in T23738_basic. +{-# LANGUAGE OverloadedStrings #-} + +-- Non-overloaded lists are checked in T23738_basic. +{-# LANGUAGE OverloadedLists #-} + +module T23738_overlit where + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type '("Hello", [1, 2, 3])) + {- term syntax: -} ("Hello", [1, 2, 3]) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_sigforall where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +r1 :: () +r1 = + checkEq + {- type syntax: -} (type (Left :: forall a b. a -> Either a b)) + {- term syntax: -} (Left :: forall a b. a -> Either a b) + +r2 :: () +r2 = + checkEq + {- type syntax: -} (type (Left :: forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall a. forall b. a -> Either a b) + +r3 :: () +r3 = + checkEq + {- type syntax: -} (type (Left :: forall. forall a. forall b. a -> Either a b)) + {- term syntax: -} (Left :: forall. forall a. forall b. a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_th.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TemplateHaskell #-} + +module T23738_th where + +type (:+:) = Either + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: () +result = + checkEq + {- type syntax: -} (type $[t| '(Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, '[] @Bool, '[10], [1, 2]) |]) + {- term syntax: -} $[e| (Maybe Int, String :+: Int, 10, "Hello", 'x' :: Char, [] @Bool, [10], [1, 2]) |] \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} + +module T23738_tyvar where + +import Data.Kind (Type) + +checkEq :: forall a b -> (a ~ b) => () +checkEq (type _) (type _) = () + +result :: forall k. forall (f :: k -> Type) (t :: k) -> () +result (type f) (type t) = + checkEq + {- type syntax: -} (type (f t)) + {- term syntax: -} (f t) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/T23738_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool = idv _ True +rChar = idv _ 'x' + +rMaybeBool = idv (Maybe _) (Just True) +rMaybeChar = idv (Maybe _) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_compile/all.T ===================================== @@ -10,6 +10,13 @@ test('T22326_sig', normal, compile, ['']) test('T17792_vdq', normal, compile, ['']) test('T14158_vdq', normal, compile, ['']) test('WithSpineVDQ_LintErr', normal, compile, ['']) +test('T23738_basic', normal, compile, ['']) +test('T23738_tyvar', normal, compile, ['']) +test('T23738_overlit', normal, compile, ['']) +test('T23738_nested', normal, compile, ['']) +test('T23738_wild', normal, compile, ['']) +test('T23738_sigforall', normal, compile, ['']) test('T22326_th_dump1', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques']) -test('T22326_th_pprint1', req_th, compile, ['']) \ No newline at end of file +test('T22326_th_pprint1', req_th, compile, ['']) +test('T23738_th', req_th, compile, ['']) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr ===================================== @@ -1,6 +1,5 @@ T22326_fail_raw_arg.hs:9:5: error: [GHC-29092] • Ill-formed type argument: \ _ -> _ - Expected a type expression introduced with the ‘type’ keyword. • In the expression: f (\ _ -> _) In an equation for ‘x’: x = f (\ _ -> _) ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE DataKinds #-} + +module T23738_fail_implicit_tv where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +rNothing = vfun (Nothing :: Maybe a) +rLeft = vfun (Left :: a -> Either a b) \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr ===================================== @@ -0,0 +1,21 @@ + +T23738_fail_implicit_tv.hs:10:12: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Nothing :: Maybe a) + In an equation for ‘rNothing’: rNothing = vfun (Nothing :: Maybe a) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘b’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘b’ + +T23738_fail_implicit_tv.hs:11:9: error: [GHC-80557] + • Illegal implicitly quantified type variable in a required type argument: + ‘a’ + • In the expression: vfun (Left :: a -> Either a b) + In an equation for ‘rLeft’: rLeft = vfun (Left :: a -> Either a b) + Suggested fix: Use an explicit ‘forall’ to quantify over ‘a’ ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE TypeAbstractions #-} + +module T23738_fail_var where + +vfun :: forall (a :: k) -> () +vfun (type _) = () + +f :: Int -> () +f a = vfun a \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_var.stderr ===================================== @@ -0,0 +1,6 @@ + +T23738_fail_var.hs:11:12: error: [GHC-10969] + • Local identifier ‘a’ used as a type + • In the type ‘a’ + In the expression: vfun a + In an equation for ‘f’: f a = vfun a ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE RequiredTypeArguments #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE NamedWildCards #-} + +module T23738_fail_wild where + +idv :: forall a -> a -> a +idv (type t) (x :: t) = x + +rBool' = idv _w True +rChar' = idv _w 'x' + +rMaybeBool' = idv (Maybe _w) (Just True) +rMaybeChar' = idv (Maybe _w) (Just 'x') \ No newline at end of file ===================================== testsuite/tests/vdq-rta/should_fail/T23738_fail_wild.stderr ===================================== @@ -0,0 +1,26 @@ + +T23738_fail_wild.hs:10:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w True + In an equation for ‘rBool'’: rBool' = idv _w True + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:11:10: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv _w 'x' + In an equation for ‘rChar'’: rChar' = idv _w 'x' + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:13:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just True) + In an equation for ‘rMaybeBool'’: + rMaybeBool' = idv (Maybe _w) (Just True) + Suggested fix: Use an anonymous wildcard ‘_’ + +T23738_fail_wild.hs:14:15: error: [GHC-93411] + • Illegal named wildcard in a required type argument: ‘_w’ + • In the expression: idv (Maybe _w) (Just 'x') + In an equation for ‘rMaybeChar'’: + rMaybeChar' = idv (Maybe _w) (Just 'x') + Suggested fix: Use an anonymous wildcard ‘_’ ===================================== testsuite/tests/vdq-rta/should_fail/all.T ===================================== @@ -11,4 +11,7 @@ test('T22326_fail_caseof', normal, compile_fail, ['']) test('T22326_fail_ado', normal, compile_fail, ['']) test('T22326_fail_n_args', normal, compile_fail, ['']) test('T22326_fail_patsyn', normal, compile_fail, ['']) -test('T22326_fail_match', normal, compile_fail, ['']) \ No newline at end of file +test('T22326_fail_match', normal, compile_fail, ['']) +test('T23738_fail_wild', normal, compile_fail, ['']) +test('T23738_fail_implicit_tv', normal, compile_fail, ['']) +test('T23738_fail_var', normal, compile_fail, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0dfb1fa799af254c8a1e1045fc3996af2d57a613 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0dfb1fa799af254c8a1e1045fc3996af2d57a613 You're receiving 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 Nov 3 18:39:47 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 Nov 2023 14:39:47 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: T2T in Expressions (#23738) Message-ID: <65453e732a908_27efe944d7cc6c33917@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 7933733a by Duncan Coutts at 2023-11-03T14:39:39-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 01e2ac50 by Simon Peyton Jones at 2023-11-03T14:39:39-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 30 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - docs/users_guide/exts/required_type_arguments.rst - testsuite/tests/diagnostic-codes/codes.stdout - + testsuite/tests/rts/IOManager.hsc - + testsuite/tests/rts/IOManager.stdout - testsuite/tests/rts/Makefile - testsuite/tests/rts/all.T - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/vdq-rta/should_compile/T22326_idv.hs - + testsuite/tests/vdq-rta/should_compile/T23738_basic.hs - + testsuite/tests/vdq-rta/should_compile/T23738_nested.hs - + testsuite/tests/vdq-rta/should_compile/T23738_overlit.hs - + testsuite/tests/vdq-rta/should_compile/T23738_sigforall.hs - + testsuite/tests/vdq-rta/should_compile/T23738_th.hs - + testsuite/tests/vdq-rta/should_compile/T23738_tyvar.hs - + testsuite/tests/vdq-rta/should_compile/T23738_wild.hs - testsuite/tests/vdq-rta/should_compile/all.T - testsuite/tests/vdq-rta/should_fail/T22326_fail_raw_arg.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.hs - + testsuite/tests/vdq-rta/should_fail/T23738_fail_implicit_tv.stderr - + testsuite/tests/vdq-rta/should_fail/T23738_fail_var.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1f0555f54fdf9ea18ce221a0369318ab9fbce6c...01e2ac506be836c39d46ff578e606e95c57f5159 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1f0555f54fdf9ea18ce221a0369318ab9fbce6c...01e2ac506be836c39d46ff578e606e95c57f5159 You're receiving 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 Nov 3 21:25:00 2023 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Fri, 03 Nov 2023 17:25:00 -0400 Subject: [Git][ghc/ghc][wip/wasm32-native-tests] 5 commits: Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6545652cef22f_27efe948d0804835308d@gitlab.mail> Cheng Shao pushed to branch wip/wasm32-native-tests at Glasgow Haskell Compiler / GHC Commits: 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - eb06be9a by Cheng Shao at 2023-11-03T21:24:46+00:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - f7104d19 by Cheng Shao at 2023-11-03T21:24:46+00:00 testsuite: fix optasm tests for wasm32 - - - - - 73bb1d99 by Matthew Pickering at 2023-11-03T21:24:52+00:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.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/Utils/Unique.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/required_type_arguments.rst - hadrian/src/Settings/Builders/RunTest.hs - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/cmm/should_run/all.T - testsuite/tests/diagnostic-codes/codes.stdout - testsuite/tests/regalloc/all.T - testsuite/tests/rts/T5644/all.T - testsuite/tests/rts/all.T - testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr - testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout - testsuite/tests/simplCore/prog003/test.T - testsuite/tests/simplCore/should_run/all.T - testsuite/tests/vdq-rta/should_compile/T22326_idv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a4f49baa3e3728b17e7193536020cd1cc3107ec...73bb1d999667d7060553bdc9572e535699c1c1df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a4f49baa3e3728b17e7193536020cd1cc3107ec...73bb1d999667d7060553bdc9572e535699c1c1df You're receiving 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 Nov 3 23:50:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 03 Nov 2023 19:50:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Add a test for I/O managers Message-ID: <65458752243fe_27efe94c2e218c368513@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 30c77cce by Duncan Coutts at 2023-11-03T19:50:14-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - e3e165ec by Alan Zimmerman at 2023-11-03T19:50:15-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - dfdc1d8e by Simon Peyton Jones at 2023-11-03T19:50:15-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 12 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/rts/IOManager.hsc - + testsuite/tests/rts/IOManager.stdout - testsuite/tests/rts/Makefile - testsuite/tests/rts/all.T - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/rts/IOManager.hsc ===================================== @@ -0,0 +1,1089 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE NamedFieldPuns #-} + +module Main (main) where + +-- When building within the GHC testsuite, we do not have access to the +-- async package, so we use a bundled version. The cut down version is +-- included at the end of this file. +#define USE_ASYNC_BUNDLED 1 + +import qualified Data.Map as Map +import Control.Monad +import Control.Concurrent +#ifndef USE_ASYNC_BUNDLED +import Control.Concurrent.Async +#endif +import Control.Concurrent.STM +import Control.Exception +import GHC.IO.Exception (ioe_errno) +import System.Timeout + +import Foreign +import Foreign.C +import System.Posix.Types (Fd(Fd)) + +import Prelude hiding (read) + +#include +#include + +{- +The purpose of these tests is to try to get some decent test coverage of the +GHC I/O managers. Most of the time the I/O manager only has to deal with one +thread blocking on a file descriptor at once, but it's important to also cover +the more complex cases: + + * Multiple file descriptors + * Multiple threads blocking on reading/writing + * Multiple threads blocking on reading and writing on the same file descriptor + * Killing threads blocking on reading/writing, while there are still other + remaining threads. + +We start with some simple scenarios and work up towards the complex scenarios. + +To do this we use anonymous unix domain sockets, created using socketpair(). +We cannot use ordinary pipes because they are unidirectional, with a write-only +file descriptor for one end and a read-only file descriptor for the other end: +which makes it impossible to have threads waiting for reading and writing on +the same file descriptor. + +Unfortunately this makes these tests Unix-only for now, due to the use of +socketpair(). In principle it's possible on Win32 to create a bidirectional +non-blocking pipe by using the named pipe API with a unique name (since this is +what the Win32 CreatePipe() API does internally, but uses blocking mode). Thus +this test could in principle be extended to work on Windows. + +For blocking on reading we need socket buffers to be empty, while for blocking +on writing we need socket buffers to be full. The empty case is nice and simple +but the full case is surprisingly asymmetric. + +The most complex scenario looks like this: a sequence of sockets, with +Haskell threads copying bytes between them. Data is injected at one end by a +special sender thread and collected at the other end of the pipeline by a +special receiver thread. Each socket has two directions, in one direction we +arrange for the socket buffers to be usually empty, so threads are typically +blocked on reading, while in the other direction we arrange for the buffers to +be usually full so that threads are typically blocked on writing. Between each +pair of sockets we use one or more Haskell threads that just copy a byte from +source socket to destination socket. This simple copying behaviour works with +both full and empty buffers, the difference is just whether the copying threads +are usually blocked on the reading or writing side. We use different numbers of +threads to get coverage of the 1 and many cases. + + ╍╍╍╍╍╍╍╍▶ data flow direction ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ + ┇ + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┇ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ▼ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ in ┃ out ┃ ┃ in ┃ out ┃ ┃ in ┃ out ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ out ┃ in ┃ ┃ out ┃ in ┃ ┃ out ┃ in ◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┇ + ┇ + ◀╍╍╍╍╍╍╍╍╍ data flow direction ◀╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ + +The simpler scenarios are all subsets of this complex one. + +These scenarios make use of two protocols: the "empty buffer" protocol and the +"full buffer" protocol. See 'EmptyBufPtcl' and 'FullBufPtcl' below for details. +-} + +main :: IO () +main = do + putStrLn "I/O manager tests" + sequence_ + [ do putStrLn (show n ++ ". " ++ show scenario) + runScenario scenario + | (n, scenario) <- zip [1 :: Int ..] scenarios ] + +data Scenario = + Scenario { + mode :: Mode, + nsockets :: Int, + nthreads :: Int, + cancelio :: Bool, + size :: Int + } + deriving Show + +data Mode = EmptyBufs + | FullBufs + | EmptyFullBufs + deriving Show + +scenarios :: [Scenario] +scenarios = + [ Scenario { mode, nsockets, nthreads, cancelio = False, size } + | mode <- [EmptyBufs, FullBufs, EmptyFullBufs] + , (nsockets, nthreads, size) <- + [ (1,0,10) + , (1,0,100) + , (2,1,100) + , (2,3,100) + , (3,5,1000) + ] + ] + ++ [ Scenario { mode, nsockets, nthreads, cancelio = True, size } + | (mode, nsockets, nthreads, size) <- + [ (EmptyBufs, 2,3,100) + , (FullBufs, 2,3,100) + , (EmptyFullBufs, 2,3,100) + , (EmptyFullBufs, 3,5,1000) + , (EmptyFullBufs, 7,10,5000) + ] + ] + +runScenario :: Scenario -> IO () +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyBuffersSimple size + +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyBuffers size nsockets nthreads + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets = 1, size } = + scenarioFullBuffersSimple size + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyFullBuffersSimple size + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioEmptyBuffersCancel size nthreads + +runScenario Scenario { mode = FullBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioFullBuffersCancel size nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = True, + nsockets, nthreads, size } = + scenarioEmptyFullBuffersCancel size nsockets nthreads + +{- +Scenario: empty socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ + ┏━━▼━━┳━━┿━━┓ +empty buffer ┃ s1a ┃ s1b ┃ + ┣━━━━━╋━━━━━┫ +unused buffer ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersSimple :: Int -> IO () +scenarioEmptyBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (receiverEmpty sync s1b) + let expected = input + checkExpected id expected actual + + +{- +Scenario: empty socket buffers, n sockets, n-1 copy hops, m copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ + n sockets in total, n-1 hops +-} +scenarioEmptyBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverEmpty sync snb) + let expected = input + checkExpected id expected actual + + +{- +Scenario: full socket buffers, 1 socket, 0 copy hops + ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ + │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersSimple :: Int -> IO () +scenarioFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s1b input) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: full socket buffers, n sockets, n-1 copy hops x m copy threads + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┗━━━━━━━━━━━━━━━━┛ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffers :: Int -> Int -> Int -> IO () +scenarioFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + sync <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderFull sync snb input) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty and full socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ + │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b◀──╂ ┃ + ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersSimple :: Int -> IO () +scenarioEmptyFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull s1b s1b) + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: empty & full socket buffers, 3 sockets, 2x2 copy hops x 5 copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ s2a ┃ s2b ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ + ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersCancel :: Int -> Int -> IO () +scenarioEmptyBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (copyBetweenFdsNChaosMonkey ReadFirst m schedule s1b s2a) + *> Concurrently (receiverEmpty sync s2b) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: full buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┗━━━━━━━━━━━━━━━━┛ + ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersCancel :: Int -> Int -> IO () +scenarioFullBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + mapM_ zeroFillFdBuffer [s1b, s2b] + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s2b input) + *> Concurrently (copyBetweenFdsNChaosMonkey WriteFirst m schedule s2a s1b) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty & full buffers, n sockets, 2(n-1) copy hops x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersCancel :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffersCancel sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedules1 = map chaosMonkeySchedule [1..] + schedules2 = map chaosMonkeySchedule [2..] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey ReadFirst m schedule sib si'a + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules1 + ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey WriteFirst m schedule si'a sib + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules2 + ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +checkExpected :: (Eq a, Show a) => ([Word8] -> a) -> [Word8] -> [Word8] -> IO () +checkExpected normalise expected actual + | expected_normalised == actual_normalised = return () + | otherwise = do + putStrLn "---------" + putStrLn $ "expected output differs:" + putStrLn $ "expected: " ++ show expected_normalised + putStrLn $ "actual: " ++ show actual_normalised + putStrLn "---------" + where + expected_normalised = normalise expected + actual_normalised = normalise actual + +listToBag :: Ord a => [a] -> Map.Map a Int +listToBag = Map.fromListWith (+) . map (\k -> (k,1)) + + +-- | The \"empty buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /reading/, i.e. the socket buffers are usually empty. +-- +-- We do this by synchronising between the sending and receiving ends so that +-- we only send one byte at a time, and the sender waits for the receiver to +-- get it. +-- +-- To do this we use a simple TVar Bool shared between the sender and receiver. +-- The sender sends a byte and then waits for the tvar to be set to true by +-- the receiver, at which point it resets the tvar to false and continues. +-- +-- This is usually used in a loop. +-- +newtype EmptyBufPtcl = EmptyBufPtcl (TVar Bool) + +newEmptyBufPtcl :: IO EmptyBufPtcl +newEmptyBufPtcl = EmptyBufPtcl <$> newTVarIO False + +sendEmptyBufPtcl :: EmptyBufPtcl -> Fd -> Word8 -> IO () +sendEmptyBufPtcl (EmptyBufPtcl sync) fd x = do + writeByteBlocking fd x + atomically $ do + continue <- readTVar sync + check continue + writeTVar sync False + +recvEmptyBufPtcl :: EmptyBufPtcl -> Fd -> IO (Maybe Word8) +recvEmptyBufPtcl (EmptyBufPtcl sync) fd = do + res <- readByteBlocking fd + atomically $ writeTVar sync True + return res + +-- | The \"full buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /writing/, i.e. the socket buffers are usually full. +-- +-- Sending through a full socket buffer is surprisingly tricky in practice +-- however. Suppose we have a thread blocked on writing into a socket (because +-- the socket) buffer is full. One might expect that if another thread reads +-- some data from the socket that this would unblock the writing thread. On +-- Linux at least, this is not necessarily the case. One may have to remove +-- much more data before the writer is unblocked. +-- +-- (It probably behaves this way because the Linux kernel implementation of +-- local socket tracks packets written, and each packet has some overhead. So +-- there has to be enough space to fit a whole packet.) +-- +-- So what we do is this: +-- +-- Write side: +-- * try to write a byte +-- * if it succeeds, repeat +-- * else it returns EAGAIN +-- * sync to release reader +-- * block on readiness for writing +-- * sync to stop reader +-- * repeat +-- +-- Read side: +-- * sync wait to be released +-- * read a byte (not expected to block) +-- * wait for either sync to stop or timeout +-- * either way, repeat +-- +-- The point is this: the writer will block on writing but while it is blocked it +-- will allow the read side to read a byte and then wait a bit. This might be +-- enough to free up space and allow the writer to complete (in which case the +-- reader will not read more bytes) but if it's not enough then the reader will +-- eventually stop waiting and read again. Eventually it must be enough to free -- up space. +-- +-- This protocol /should/ work across many hops, where the intermediate hops +-- just do simple blocking read\/write of bytes. So this should just be needed +-- at the far ends of the hops. +-- +data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait milliseconds + +newFullBufPtcl :: Int -> IO FullBufPtcl +newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitms + where + waitms = nhops * 100 --100ms per hop + +sendFullBufPtcl :: FullBufPtcl -> Fd -> Word8 -> IO () +sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do + res <- writeByteNonBlocking fd x + case res of + Just () -> + traceIO ("sendFullBufPtcl: wrote byte '" ++ show x + ++ "' on fd " ++ show fd) + Nothing -> do + atomically $ writeTVar sync True + traceIO ("sendFullBufPtcl: waiting to write byte '" ++ show x + ++ "' on fd " ++ show fd) + threadWaitWrite fd + atomically $ writeTVar sync False + -- go round again + sendFullBufPtcl ptcl fd x + +finishSendFullBufPtcl :: FullBufPtcl -> IO () +finishSendFullBufPtcl (FullBufPtcl sync _waitms) = + atomically $ writeTVar sync True -- release reader to finish + +recvFullBufPtcl :: FullBufPtcl -> Fd -> IO (Maybe Word8) +recvFullBufPtcl (FullBufPtcl sync waitms) fd = do + atomically $ readTVar sync >>= check + res <- readByteNonBlocking fd + case res of + Nothing -> fail "recvFullBufPtcl: unexpected blocking" + Just Nothing -> return Nothing + Just (Just x) -> do + traceIO ("recvFullBufPtcl: read byte '" ++ show x + ++ "' on fd " ++ show fd ++ ", now waiting") + _ <- timeout waitms $ atomically $ readTVar sync >>= check . not + return (Just x) + + +senderEmpty :: EmptyBufPtcl -> Fd -> [Word8] -> IO () +senderEmpty ptcl fd xs = do + mapM_ (sendEmptyBufPtcl ptcl fd) xs + shutdown fd SHUT_WR + +receiverEmpty :: EmptyBufPtcl -> Fd -> IO [Word8] +receiverEmpty ptcl fd = + untilM (recvEmptyBufPtcl ptcl fd) + + +senderFull :: FullBufPtcl -> Fd -> [Word8] -> IO () +senderFull ptcl fd xs = do + mapM_ (sendFullBufPtcl ptcl fd) xs + finishSendFullBufPtcl ptcl + shutdown fd SHUT_WR + +receiverFull :: FullBufPtcl -> Fd -> IO [Word8] +receiverFull ptcl fd = + untilM (recvFullBufPtcl ptcl fd) + + +untilM :: Monad m => m (Maybe x) -> m [x] +untilM action = + go [] + where + go xs = do + mx <- action + case mx of + Nothing -> return (reverse xs) + Just x -> go (x:xs) + + +reflectorEmptyToFull :: EmptyBufPtcl -> FullBufPtcl -> Fd -> Fd -> IO () +reflectorEmptyToFull ptclEmpty ptclFull fdFrom fdTo = do + copyloop + finishSendFullBufPtcl ptclFull + shutdown fdTo SHUT_WR + where + copyloop = do + mx <- recvEmptyBufPtcl ptclEmpty fdFrom + case mx of + Nothing -> return () + Just x -> do sendFullBufPtcl ptclFull fdTo x + copyloop + + +data ReadOrWriteFirst = ReadFirst | WriteFirst + deriving (Eq) + +-- | Use N threads concurrently to copy bytes. Each thread copies bytes, +-- one-by-one, from one Fd to another, either starting with a +-- read or a write (of 0). +-- +-- Returns the bytes copied, one sublist per thread. Note that the split +-- between threads will be non-deterministic. +-- +-- Once all bytes are copied (indicated by EOF on the source), the destination +-- Fd is shutdown for writing. This allows the other end of the destination Fd +-- will be receive an EOF. The destination Fd is only shutdown once all +-- threads are complete. +-- +copyBetweenFdsN :: ReadOrWriteFirst -> Int -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsN rw n fdFrom fdTo = do + result <- + runConcurrently $ + sequenceA + [ Concurrently (copyBetweenFds rw fdFrom fdTo) + | _i <- [0..n-1] ] + shutdown fdTo SHUT_WR + return result + + +copyBetweenFds :: ReadOrWriteFirst -> Fd -> Fd -> IO [Word8] +copyBetweenFds rw fdFrom fdTo = + case rw of + ReadFirst -> goRead [] + WriteFirst -> goWrite [] 0 + where + goRead acc = do + res <- readByteBlocking fdFrom + case res of + Nothing -> return (reverse acc) + Just byte -> goWrite acc byte + + goWrite acc byte = do + writeByteBlocking fdTo byte + goRead (byte:acc) + +-- | It turns out that chaos monkeys are more predictable than you might think. +-- +-- Each schedule entry (i,j) says: on transferring byte i, interrupt thread j. +-- +type ChaosMonkeySchedule = [(Int, Int)] + +chaosMonkeySchedule :: Int -> ChaosMonkeySchedule +chaosMonkeySchedule seed = + go (Prng seed) 0 + where + go prng i = + let (prng', a) = random prng + (prng'', j) = random prng' + i' = i + 1 + a `mod` 3 -- so 1,2,3 + in (i', j) : go prng'' i' + + +newtype Prng = Prng Int deriving Show + +random :: Prng -> (Prng, Int) +random (Prng n) = + let !n' = n * 1103515245 + 12345 + !x = (n' `div` 65536) `mod` 32768 + in (Prng n', x) + +-- | Like copyBetweenFdsN but with scheduled interruption of blocking I\/O +-- operations by asynchronous exceptions to cancel the I\/O. +-- +-- Each copying thread will catch the async exception and repeat. The sending +-- of the async exceptions is done based on a pre-defined schedule, based on +-- the n'th byte read by each thread. +-- +copyBetweenFdsNChaosMonkey :: ReadOrWriteFirst -> Int + -> ChaosMonkeySchedule + -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsNChaosMonkey rw n schedule fdFrom fdTo = + mask_ $ do + sync <- newTVarIO False + bracket (replicateM n (async (copyBetweenFds' sync))) + (mapM_ cancel) $ \copyThreads -> + withAsync (chaosMonkey sync copyThreads schedule) $ \monkeyThread -> do + _ <- waitAny copyThreads + results <- mapM wait copyThreads + cancel monkeyThread + shutdown fdTo SHUT_WR + return results + where + chaosMonkey :: TVar Bool -> [Async a] -> ChaosMonkeySchedule -> IO () + chaosMonkey sync threads = go 0 + where + go _ [] = return () + go !b sched@((i,_j):_) | b < i = do + awaitPulse sync + go (b+1) sched + go !b ((i,j):sched') | b == i = do + let tn = j `mod` n + tid = asyncThreadId (threads !! tn) + traceIO $ "interrupting thread number " ++ show tn ++ ", " ++ show tid + throwTo tid Interrupted + go b sched' + go !b ((_i,_j):sched') | otherwise = + go b sched' + + awaitPulse sync = atomically $ do + check =<< readTVar sync + writeTVar sync False + pulse sync = atomically $ writeTVar sync True + + copyBetweenFds' sync = + case rw of + ReadFirst -> goRead sync [] + WriteFirst -> goWrite sync [] 0 + + goRead sync acc = do + res <- try $ readByteBlocking fdFrom + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "read interrupted on " ++ show tid + goRead sync acc + Right Nothing -> return (reverse acc) + Right (Just byte) -> do + when (rw == WriteFirst) (pulse sync) + goWrite sync acc byte + + goWrite sync acc byte = do + res <- try $ writeByteBlocking fdTo byte + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "write interrupted on " ++ show tid + goWrite sync acc byte + Right () -> do + when (rw == ReadFirst) (pulse sync) + goRead sync (byte:acc) + +data Interrupted = Interrupted deriving Show +instance Exception Interrupted + +readByteBlocking :: Fd -> IO (Maybe Word8) +readByteBlocking fd = + allocaBytes 1 $ \bufptr -> + readLoop bufptr + where + readLoop bufptr = do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitRead fd + readLoop bufptr + | otherwise -> throwIO err + Right 1 -> Just <$> peek bufptr + Right 0 -> return Nothing + Right _ -> fail "impossible" + +readByteNonBlocking :: Fd -> IO (Maybe (Maybe Word8)) +readByteNonBlocking fd = + allocaBytes 1 $ \bufptr -> do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> Just . Just <$> peek bufptr + Right 0 -> return (Just Nothing) + Right _ -> fail "impossible" + +writeByteBlocking :: Fd -> Word8 -> IO () +writeByteBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + writeLoop bufptr + where + writeLoop bufptr = do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitWrite fd + writeLoop bufptr + | otherwise -> throwIO err + Right 1 -> return () + Right _ -> fail "impossible" + +writeByteNonBlocking :: Fd -> Word8 -> IO (Maybe ()) +writeByteNonBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> return (Just ()) + Right _ -> fail "impossible" + +read :: Fd -> Ptr Word8 -> CSize -> IO CLong +read fd buf count = + throwErrnoIfMinus1 "read" $ do + r <- c_read fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("read " ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + +write :: Fd -> Ptr Word8 -> CSize -> IO CLong +write fd buf count = + throwErrnoIfMinus1 "write" $ do + r <- c_write fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("write" ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + + +-- Ensure the fd's write buffer is full of zeros. +-- +-- The Fd must be in non-blocking mode. +-- +-- Uses 1 byte writes, which on Linux at least, fills up the buffer quickly. +-- Presumably this is due to the overhead of tracking as packets. +-- +zeroFillFdBuffer :: Fd -> IO () +zeroFillFdBuffer fd = + allocaBytes 1 $ \bufptr -> poke bufptr 0 >> go bufptr 0 + where + go :: Ptr Word8 -> Int -> IO () + go !bufptr !count = do + res <- c_write fd bufptr 1 + errno <- getErrno + case () of + _ | res == 1 -> + go bufptr (count + 1) + + | res < 0 && (errno == eAGAIN || errno == eWOULDBLOCK) -> + return () + + _ -> throwErrno "zeroFillFdBuffer" + + +-- We have to use a local socket rather than a pipe, because we need a +-- bi-directional pipe, and Posix (specially Linux) pipes are unidirectional. +-- It needs to be bidirectional so that we have multiple threads ending up +-- blocked reading and writing on the same socket, to test the IO manager +-- handles this case correctly. +-- +-- Also set the buffer size to be as small as possible (1 page). +-- +localSocketPair :: IO (Fd, Fd) +localSocketPair = + allocaArray 2 $ \sv -> do + let sockdomain = #{const AF_LOCAL} + socktype = #{const SOCK_STREAM} + sockproto = 0 + throwErrnoIfMinus1_ "socketpair" $ + c_socketpair sockdomain socktype sockproto sv + [a,b] <- peekArray 2 sv + forM_ [Fd a, Fd b] $ \fd@(Fd fdcint) -> do + c_fcntl_write fdcint #{const F_SETFL} #{const O_NONBLOCK} + let bufsize = 1024 + setsockopt fd #{const SOL_SOCKET} #{const SO_SNDBUF} bufsize + setsockopt fd #{const SOL_SOCKET} #{const SO_RCVBUF} bufsize + return (Fd a, Fd b) + +withLocalSocketPair :: (Fd -> Fd -> IO a) -> IO a +withLocalSocketPair action = + bracket + localSocketPair + (\(a, b) -> close a >> close b) + (uncurry action) + +withLocalSocketPairs :: Int -> ([(Fd, Fd)] -> IO a) -> IO a +withLocalSocketPairs n = + bracket + (replicateM n localSocketPair) + (mapM_ (\(a, b) -> close a >> close b)) + +setsockopt :: Fd -> CInt -> CInt -> CInt -> IO () +setsockopt fd level option value = + with value $ \p -> + throwErrnoIfMinus1_ "setsockopt" $ + c_setsockopt fd level option p (fromIntegral (sizeOf value)) + +close :: Fd -> IO () +close fd = + throwErrnoIfMinus1_ "close" $ + c_close fd + +data ShutdownDir = SHUT_RD | SHUT_WR | SHUT_RDWR + +shutdown :: Fd -> ShutdownDir -> IO () +shutdown fd dir = + throwErrnoIfMinus1_ "shutdown" $ + c_shutdown fd how + where + how :: CInt + how = case dir of + SHUT_RD -> #{const SHUT_RD} + SHUT_WR -> #{const SHUT_WR} + SHUT_RDWR -> #{const SHUT_RDWR} + +-- int socketpair(int domain, int type, int protocol, int sv[2]); +foreign import ccall "sys/socket.h socketpair" + c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt + +foreign import ccall "sys/socket.h setsockopt" + c_setsockopt :: Fd -> CInt -> CInt -> Ptr CInt -> CInt -> IO CInt + +foreign import capi unsafe "HsBase.h fcntl" + c_fcntl_write :: CInt -> CInt -> CLong -> IO CInt + +foreign import ccall unsafe "unistd.h write" + c_write :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h read" + c_read :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h close" + c_close :: Fd -> IO CInt + +foreign import ccall unsafe "sys/socket.h shutdown" + c_shutdown :: Fd -> CInt -> IO CInt + +traceIO :: String -> IO () +traceIO _ = return () +--traceIO = BSC.putStrLn . BSC.pack + + +#ifdef USE_ASYNC_BUNDLED + +------------------------------------------------------------------------------- +-- Mini async library +-- + +data Async a = Async + { asyncThreadId :: !ThreadId + , _asyncWait :: STM (Either SomeException a) + } + +async :: IO a -> IO (Async a) +async = \action -> do + var <- newEmptyTMVarIO + t <- forkFinally action (\r -> atomically $ putTMVar var r) + return (Async t (readTMVar var)) + +withAsync :: IO a -> (Async a -> IO b) -> IO b +withAsync action inner = + mask $ \restore -> do + a <- async (restore action) + restore (inner a) `finally` uninterruptibleCancel a + +cancel :: Async a -> IO () +cancel a@(Async t _) = throwTo t AsyncCancelled <* waitCatch a + +uninterruptibleCancel :: Async a -> IO () +uninterruptibleCancel = uninterruptibleMask_ . cancel + +data AsyncCancelled = AsyncCancelled + deriving Show + +instance Exception AsyncCancelled where + fromException = asyncExceptionFromException + toException = asyncExceptionToException + +wait :: Async a -> IO a +wait = atomically . waitSTM + +waitSTM :: Async a -> STM a +waitSTM a = do + r <- waitCatchSTM a + either throwSTM return r + +waitCatch :: Async a -> IO (Either SomeException a) +waitCatch = atomically . waitCatchSTM + +waitCatchSTM :: Async a -> STM (Either SomeException a) +waitCatchSTM (Async _ w) = w + +waitBoth :: Async a -> Async b -> IO (a,b) +waitBoth left right = atomically (waitBothSTM left right) + +waitBothSTM :: Async a -> Async b -> STM (a,b) +waitBothSTM left right = do + a <- waitSTM left `orElse` (waitSTM right >> retry) + b <- waitSTM right + return (a,b) + +waitAny :: [Async a] -> IO (Async a, a) +waitAny = atomically . waitAnySTM + +waitAnySTM :: [Async a] -> STM (Async a, a) +waitAnySTM = foldr orElse retry . map (\a -> waitSTM a >>= \r -> return (a, r)) + +newtype Concurrently a = Concurrently { runConcurrently :: IO a } + +instance Functor Concurrently where + fmap f (Concurrently a) = Concurrently $ f <$> a + +instance Applicative Concurrently where + pure = Concurrently . return + Concurrently fs <*> Concurrently as = + Concurrently $ (\(f, a) -> f a) <$> concurrently fs as + +concurrently :: IO a -> IO b -> IO (a,b) +concurrently left right = + withAsync left $ \a -> + withAsync right $ \b -> + waitBoth a b + +#endif + ===================================== testsuite/tests/rts/IOManager.stdout ===================================== @@ -0,0 +1,21 @@ +I/O manager tests +1. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +2. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +3. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +4. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +5. Scenario {mode = EmptyBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +6. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +7. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +8. Scenario {mode = FullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +9. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +10. Scenario {mode = FullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +11. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +12. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +13. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +14. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +15. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +16. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +17. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +18. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +19. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = True, size = 1000} +20. Scenario {mode = EmptyFullBufs, nsockets = 7, nthreads = 10, cancelio = True, size = 5000} ===================================== testsuite/tests/rts/Makefile ===================================== @@ -157,3 +157,8 @@ T23142: grep -m1 -c "CATCH_STM_FRAME" T23142.log grep -m1 -c "MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log grep -m1 -c "SMALL_MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log + +HSC2HS_OPTS = --cc="$(TEST_CC)" $(addprefix --cflag=,$(TEST_CC_OPTS)) --ld=$(TEST_CC) $(addprefix --lflag=,$(TEST_CC_OPTS)) + +IOManager.hs: IOManager.hsc + '$(HSC2HS)' $(HSC2HS_OPTS) $< ===================================== testsuite/tests/rts/all.T ===================================== @@ -604,3 +604,7 @@ test('T23221', test('T23142', [unless(debug_rts(), skip), req_interp], makefile_test, ['T23142']) test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) + +test('IOManager', [js_skip, when(opsys('mingw32'), skip), + pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], + compile_and_run, ['']) ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/01e2ac506be836c39d46ff578e606e95c57f5159...dfdc1d8e01d6dd97f501543d367feda970c7bc4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/01e2ac506be836c39d46ff578e606e95c57f5159...dfdc1d8e01d6dd97f501543d367feda970c7bc4b You're receiving 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 Nov 4 00:39:09 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 03 Nov 2023 20:39:09 -0400 Subject: [Git][ghc/ghc][wip/spj-unf-size] Minor refactoring... Message-ID: <654592ad40029_27efe94d56ab24375662@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 55dc1a59 by Simon Peyton Jones at 2023-11-04T00:38:11+00:00 Minor refactoring... Plus: don't be so eager to inline when argument is a non-value, but has some struture. We want *some* incentive though. - - - - - 3 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -1416,6 +1416,8 @@ data CaseTree -- nothing relies on non-empty-ness | ScrutOf Id Discount -- If this Id is bound to a value, apply this discount + -- All size info is accounted for elsewhere; + -- ScrutOf just records a discount data AltTree = AltTree AltCon [Id] -- Term variables only ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -631,8 +631,8 @@ exprSummary env e = go env e [] where env' = modifyInScope env b -- Tricky corner here - go _ _ _ = ArgIsNot [] -- Some structure; not all boring - -- Example of improvement: base/tests/T9848 + go _ _ _ = ArgNonTriv -- Some structure; not all boring + -- Example of improvement: base/tests/T9848 go_var :: SimplEnv -> Id -> [CoreExpr] -- Value args only @@ -642,7 +642,7 @@ exprSummary env e = go env e [] = ArgIsCon (DataAlt con) (map (exprSummary env) val_args) | DFunUnfolding {} <- unfolding - = ArgIsNot [] -- Says "this is a data con" without saying which + = ArgNonTriv -- Says "this is a data con" without saying which -- Will also return this for ($df d1 .. dn) | Just rhs <- expandUnfolding_maybe unfolding @@ -655,9 +655,9 @@ exprSummary env e = go env e [] = ArgIsLam | not (null val_args) - = ArgIsNot [] -- Use ArgIsNot [] for args with some structure e.g. (f xs) - -- This makes the call not totally-boring, and hence makes - -- INLINE things inline (which they won't if all args are boring) + = ArgNonTriv -- Use ArgNonTriv args with some structure e.g. (f xs) + -- This makes the call not totally-boring, and hence makes + -- INLINE things inline (which they won't if all args are boring) | otherwise = ArgNoInfo ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -67,6 +67,11 @@ import qualified Data.ByteString as BS {- Note [Overview of inlining heuristics] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +These inlining heurstics all concern callSiteInline; that is, the +decision about whether or not to inline a let-binding. It does not +concern inlining used-once things, or things with a trivial RHS, which +kills the let-binding altogether. + Key examples ------------ Example 1: @@ -79,7 +84,7 @@ Example 1: Even though f's entire RHS is big, it collapses to something small when applied to A. We'd like to spot this. -Example 1: +Example 2: let f x = case x of (p,q) -> case p of @@ -105,9 +110,35 @@ when `y` is a free variable. This kind of thing can occur a lot with join points. +Example 4: result discounts: + + let f x = case x of + A -> (e1,e2) + B -> (e3,e4) + C -> e5 + in \y -> ...case f y of { (a,b) -> blah } + +Here there is nothing interesting about f's /argument/, but: + * Many of f's cases return a data constructur (True or False) + * The call of `f` scrutinises its result + +If we inline `f`, the 'case' will cancel with pair constrution, we should be keener +to inline `f` than if it was called in a boring context. We say that `f` has a +/result discount/ meaning that we should apply a discount if `f` is called in +a case context. + +Example 5: totally boring + + let f x = not (g x x) + in ....(\y. f y)... + +Here,there is /nothing/ interesting about either the arguments or the result +coninuation of the call (f y). There is no point in inlining, even if f's RHS +is small, as it is here. + Design overview --------------- -The question is whethe or not to inline f = rhs. +The question is whether or not to inline f = rhs. The key idea is to abstract `rhs` to an ExprTree, which gives a measure of size, but records structure for case-expressions. @@ -149,7 +180,7 @@ data UnfoldingOpts = UnfoldingOpts , unfoldingVeryAggressive :: !Bool -- ^ Force inlining in many more cases - , unfoldingCaseThreshold :: !Size + , unfoldingCaseThreshold :: !Int -- ^ Don't consider depth up to x , unfoldingCaseScaling :: !Int @@ -467,6 +498,11 @@ uncondInline rhs arity size {- Note [Constructing an ExprTree] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We construct an ExprTree as an abstaction or "digest" of the body +of a function f = \x1...xn. body + +The arguments are x1..xn; we apply `exprTree` to the `body`. + We maintain: * avs: argument variables, or variables bound by a case on an argument variable. @@ -527,7 +563,7 @@ exprTree opts args expr et_add_alt = metAddAlt bOMB_OUT_SIZE go :: Int -> ETVars -> CoreExpr -> Maybe ExprTree - -- rcd is the /unused/ case depth; decreases toward zero + -- rcd is the /remaining/ case depth; decreases toward zero -- (avs,lvs): see Note [Constructing an ExprTree] go rcd vs (Cast e _) = go rcd vs e go rcd vs (Tick _ e) = go rcd vs e @@ -640,7 +676,8 @@ exprTree opts args expr -- Don't record a CaseOf go_case rcd vs scrut b alts -- alts is non-empty - = caseSize scrut alts `metAddN` -- A bit odd that this is only in one branch + = caseSize scrut alts `metAddN` -- A bit odd that this `caseSize` business is only + -- applied in this equation, not in the previous ones go rcd vs scrut `et_add` go_alts (rcd-1) vs b alts @@ -783,7 +820,7 @@ funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree -- Size for function calls that are not constructors or primops -- Note [Function applications] funSize opts (avs,_) fun n_val_args voids - | fun `hasKey` buildIdKey = etZero -- Wwant to inline applications of build/augment + | fun `hasKey` buildIdKey = etZero -- We want to inline applications of build/augment | fun `hasKey` augmentIdKey = etZero -- so we give size zero to the whole call | otherwise = ExprTree { et_wc_tot = size, et_size = size , et_cases = cases @@ -1124,10 +1161,14 @@ data InlineContext -- so apply result discount } -data ArgSummary = ArgNoInfo - | ArgIsCon AltCon [ArgSummary] -- Value args only - | ArgIsNot [AltCon] - | ArgIsLam +data ArgSummary + = ArgNoInfo + | ArgIsCon AltCon [ArgSummary] -- Arg is a data-con application; + -- the [ArgSummary] is for value args only + | ArgIsNot [AltCon] -- Arg is a value, not headed by these construtors + | ArgIsLam -- Arg is a lambda + | ArgNonTriv -- The arg has some struture, but is not a value + -- e.g. it might be a call (f x) hasArgInfo :: ArgSummary -> Bool hasArgInfo ArgNoInfo = False @@ -1136,6 +1177,7 @@ hasArgInfo _ = True instance Outputable ArgSummary where ppr ArgNoInfo = text "ArgNoInfo" ppr ArgIsLam = text "ArgIsLam" + ppr ArgNonTriv = text "ArgNonTriv" ppr (ArgIsCon c as) = ppr c <> ppr as ppr (ArgIsNot cs) = text "ArgIsNot" <> ppr cs @@ -1163,14 +1205,18 @@ caseTreeSize :: InlineContext -> CaseTree -> Size caseTreeSize ic (ScrutOf bndr disc) = case lookupBndr ic bndr of ArgNoInfo -> 0 - ArgIsNot {} -> -disc -- E.g. bndr is a DFun application + ArgNonTriv -> -10 -- E.g. bndr is a DFun application -- T8732 need to inline mapM_ + + -- Apply full discount for values ArgIsLam -> -disc -- Apply discount + ArgIsNot {} -> -disc ArgIsCon {} -> -disc -- Apply discount caseTreeSize ic (CaseOf scrut_var case_bndr alts) = case lookupBndr ic scrut_var of - ArgNoInfo -> altsSize ic case_bndr alts + case_size + ArgNoInfo -> altsSize ic case_bndr alts + case_size + ArgNonTriv -> altsSize ic case_bndr alts + case_size ArgIsNot cons -> altsSize ic case_bndr (trim_alts cons alts) -- The case-expression may not disappear, but it scrutinises View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/55dc1a5972a40610c416a428805b5294b3160f71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/55dc1a5972a40610c416a428805b5294b3160f71 You're receiving 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 Nov 4 04:51:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 00:51:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: EPA: make locA a function, not a field name Message-ID: <6545cdbac9d54_27efe95360383c3964bd@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 76522425 by Alan Zimmerman at 2023-11-04T00:50:57-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - c57d602f by Simon Peyton Jones at 2023-11-04T00:50:57-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 8 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfdc1d8e01d6dd97f501543d367feda970c7bc4b...c57d602fc10e218d8397035c2dd42989f0155c8b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfdc1d8e01d6dd97f501543d367feda970c7bc4b...c57d602fc10e218d8397035c2dd42989f0155c8b You're receiving 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 Nov 4 08:12:02 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 04 Nov 2023 04:12:02 -0400 Subject: [Git][ghc/ghc][wip/int-index/t2t-expr-no-puns] 22 commits: js: add JStg IR, remove unsaturated constructor Message-ID: <6545fcd2be190_27efe9589620f041059b@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/t2t-expr-no-puns at Glasgow Haskell Compiler / GHC Commits: e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - 875ea289 by Vladislav Zavialov at 2023-11-04T10:53:50+03:00 Reject puns in T2T - - - - - 28 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - + compiler/GHC/JS/Ident.hs - + compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs - compiler/GHC/JS/Make.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/JS/Syntax.hs - compiler/GHC/JS/Transform.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e7d596d307821460c1a7a7ff22ac880a23724ec...875ea289ef515056b7e826105f6b181ea6c93cab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e7d596d307821460c1a7a7ff22ac880a23724ec...875ea289ef515056b7e826105f6b181ea6c93cab You're receiving 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 Nov 4 08:31:25 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 04:31:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: EPA: make locA a function, not a field name Message-ID: <6546015cee83a_27efe958e3e51041677@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8e84ca5e by Alan Zimmerman at 2023-11-04T04:31:15-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - e229eed0 by Simon Peyton Jones at 2023-11-04T04:31:15-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 8 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c57d602fc10e218d8397035c2dd42989f0155c8b...e229eed04dbb7208ebd1781a69adf6933d5b92c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c57d602fc10e218d8397035c2dd42989f0155c8b...e229eed04dbb7208ebd1781a69adf6933d5b92c0 You're receiving 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 Nov 4 12:01:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 08:01:54 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: EPA: make locA a function, not a field name Message-ID: <654632b29e5c2_27efe95db01dd4439753@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 52ab903b by Alan Zimmerman at 2023-11-04T08:01:31-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 6334b1f5 by Simon Peyton Jones at 2023-11-04T08:01:32-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 8 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e229eed04dbb7208ebd1781a69adf6933d5b92c0...6334b1f53080be6ea7dabc1a346a564db012d884 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e229eed04dbb7208ebd1781a69adf6933d5b92c0...6334b1f53080be6ea7dabc1a346a564db012d884 You're receiving 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 Nov 4 15:02:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 11:02:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: EPA: make locA a function, not a field name Message-ID: <65465d067dc22_27efe96201743c462913@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f481eec2 by Alan Zimmerman at 2023-11-04T11:02:08-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 8f612639 by Simon Peyton Jones at 2023-11-04T11:02:08-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - faee12cc by Andreas Klebinger at 2023-11-04T11:02:09-04:00 Remove an accidental git conflict marker from a comment. - - - - - 9 changed files: - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6334b1f53080be6ea7dabc1a346a564db012d884...faee12ccb684e6434c6d991bf1f8b7f1031912e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6334b1f53080be6ea7dabc1a346a564db012d884...faee12ccb684e6434c6d991bf1f8b7f1031912e9 You're receiving 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 Nov 4 15:04:42 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 04 Nov 2023 11:04:42 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/supersven/AArch64_delete_LDATA Message-ID: <65465d8a8a106_27efe96214995446795b@gitlab.mail> Sven Tennie pushed new branch wip/supersven/AArch64_delete_LDATA at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/supersven/AArch64_delete_LDATA You're receiving 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 Nov 4 15:58:44 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 04 Nov 2023 11:58:44 -0400 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] 2 commits: MO_FS_Conv: Truncate register after conversion Message-ID: <65466a34b8d54_27efe9639bc46447648b@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 8b4f5ae9 by Sven Tennie at 2023-11-04T16:37:54+01:00 MO_FS_Conv: Truncate register after conversion Otherwise, sign-extension bits may stay around. - - - - - d4c45787 by Sven Tennie at 2023-11-04T16:39:38+01:00 Fix float operation attributes This is its own little hell... - - - - - 2 changed files: - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/CodeGen.hs ===================================== @@ -616,8 +616,10 @@ getRegister' config plat expr = -- W32 is the smallest width to convert to. Decrease width afterwards. annExpr expr (FCVTZS (OpReg W32 dst) (OpReg from reg)) `appOL` signExtendAdjustPrecission W32 to dst dst) -- (float convert (-> zero) signed) - MO_FS_Conv from to -> pure $ Any (intFormat to) (\dst -> code `snocOL` annExpr expr (FCVTZS (OpReg to dst) (OpReg from reg))) -- (float convert (-> zero) signed) - + MO_FS_Conv from to -> pure $ Any (intFormat to) (\dst -> + code `snocOL` + annExpr expr (FCVTZS (OpReg to dst) (OpReg from reg)) `appOL` -- (float convert (-> zero) signed) + truncateReg from to dst) MO_UU_Conv from to | from <= to -> pure $ Any (intFormat to) (\dst -> code `snocOL` annExpr e (MOV (OpReg to dst) (OpReg from reg)) ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -579,7 +579,7 @@ pprInstr platform instr = case instr of CSET o l r c -> case c of EQ | isIntOp l && isIntOp r -> lines_ [ subFor l r , text "\tseqz" <+> pprOp platform o <> comma <+> pprOp platform o] - EQ | isFloatOp l && isFloatOp r -> line $ binOp "\tfeq.s" + EQ | isFloatOp l && isFloatOp r -> line $ binOp ("\tfeq." ++ floatOpPrecision platform l r) NE | isIntOp l && isIntOp r -> lines_ [ subFor l r , text "\tsnez" <+> pprOp platform o <> comma <+> pprOp platform o] -- feq.s a0,fa0,fa1 @@ -597,10 +597,10 @@ pprInstr platform instr = case instr of UGE -> lines_ [ sltuFor l r <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform r , text "\txori" <+> pprOp platform o <> comma <+> pprOp platform o <> comma <+> text "1" ] UGT -> lines_ [ sltuFor l r <+> pprOp platform o <> comma <+> pprOp platform r <> comma <+> pprOp platform l ] - OLT | isFloatOp l && isFloatOp r -> line $ binOp "\tflt.s" - OLE | isFloatOp l && isFloatOp r -> line $ binOp "\tfle.s" - OGT | isFloatOp l && isFloatOp r -> line $ binOp "\tfgt.s" - OGE | isFloatOp l && isFloatOp r -> line $ binOp "\tfge.s" + OLT | isFloatOp l && isFloatOp r -> line $ binOp ("\tflt." ++ floatOpPrecision platform l r) + OLE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfle." ++ floatOpPrecision platform l r) + OGT | isFloatOp l && isFloatOp r -> line $ binOp ("\tfgt." ++ floatOpPrecision platform l r) + OGE | isFloatOp l && isFloatOp r -> line $ binOp ("\tfge." ++ floatOpPrecision platform l r) x -> pprPanic "RV64.ppr: unhandled CSET conditional" (text (show x) <+> pprOp platform o <> comma <+> pprOp platform r <> comma <+> pprOp platform l) where subFor l r | (OpImm _) <- r = text "\taddi" <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform (negOp r) @@ -612,6 +612,7 @@ pprInstr platform instr = case instr of sltuFor l r| (OpImm _) <- r = text "\tsltui" | (OpImm _) <- l = panic "PV64.ppr: Cannot SLTU IMM _" | otherwise = text "\tsltu" + binOp :: (IsLine doc) => String -> doc binOp op = text op <+> pprOp platform o <> comma <+> pprOp platform l <> comma <+> pprOp platform r CBZ o (TBlock bid) -> line $ text "\tbeq x0, " <+> pprOp platform o <> comma <+> pprAsmLabel platform (mkLocalBlockLabel (getUnique bid)) @@ -686,8 +687,8 @@ pprInstr platform instr = case instr of FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1@(OpReg W32 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.s.w") o1 o2 SCVTF o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.w") o1 o2 - SCVTF o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.s.l") o1 o2 - SCVTF o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.l") o1 o2 + SCVTF o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.d.l") o1 o2 + SCVTF o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.d.l") o1 o2 SCVTF o1 o2 -> pprPanic "RV64.pprInstr - impossible integer to float conversion" $ line (pprOp platform o1 <> text "->" <> pprOp platform o2) @@ -711,6 +712,11 @@ pprInstr platform instr = case instr of pprDmbType DmbWrite = text "w" pprDmbType DmbReadWrite = text "rw" +floatOpPrecision :: Platform -> Operand -> Operand -> String +floatOpPrecision p l r | isFloatOp l && isFloatOp r && isSingleOp l && isSingleOp r = "s" -- single precision +floatOpPrecision p l r | isFloatOp l && isFloatOp r && isDoubleOp l && isDoubleOp r = "d" -- double precision +floatOpPrecision p l r = pprPanic "Cannot determine floating point precission" (text "op1" <+> pprOp p l <+> text "op2" <+> pprOp p r) + pprBcond :: IsLine doc => Cond -> doc pprBcond c = text "b." <> pprCond c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15809ebaa682fce112d9f09f61cbf615838186fa...d4c45787c83f7d262c2432587af8998bd3452cec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15809ebaa682fce112d9f09f61cbf615838186fa...d4c45787c83f7d262c2432587af8998bd3452cec You're receiving 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 Nov 4 18:02:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 14:02:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: EPA: make locA a function, not a field name Message-ID: <65468742bfa0c_27efe9666646244926e1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 548e0e29 by Alan Zimmerman at 2023-11-04T14:02:29-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 610ab4d5 by Simon Peyton Jones at 2023-11-04T14:02:30-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - be8f4b7e by Andreas Klebinger at 2023-11-04T14:02:30-04:00 Remove an accidental git conflict marker from a comment. - - - - - 9 changed files: - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/faee12ccb684e6434c6d991bf1f8b7f1031912e9...be8f4b7e2b5de4d086c21daeedf8d61dd002316e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/faee12ccb684e6434c6d991bf1f8b7f1031912e9...be8f4b7e2b5de4d086c21daeedf8d61dd002316e You're receiving 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 Nov 4 21:33:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 17:33:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: compiler: fix eager blackhole symbol in wasm32 NCG Message-ID: <6546b8925cfb5_27efe96b67a9ec51224b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: eb06be9a by Cheng Shao at 2023-11-03T21:24:46+00:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - f7104d19 by Cheng Shao at 2023-11-03T21:24:46+00:00 testsuite: fix optasm tests for wasm32 - - - - - 73bb1d99 by Matthew Pickering at 2023-11-03T21:24:52+00:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - 6665fff4 by Alan Zimmerman at 2023-11-04T17:32:54-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - c97fe1df by Simon Peyton Jones at 2023-11-04T17:32:54-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - c7304e98 by Andreas Klebinger at 2023-11-04T17:32:54-04:00 Remove an accidental git conflict marker from a comment. - - - - - 19 changed files: - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - hadrian/src/Settings/Builders/RunTest.hs - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/parser/should_compile/T23315/T23315.stderr - testsuite/tests/regalloc/all.T - testsuite/tests/rts/T5644/all.T - testsuite/tests/rts/all.T - testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr - testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout - testsuite/tests/simplCore/prog003/test.T - testsuite/tests/simplCore/should_run/all.T - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -883,7 +883,7 @@ lower_CmmReg lbl (CmmGlobal (GlobalRegUse greg reg_use_ty)) = do pure $ SomeWasmExpr ty_word $ WasmExpr $ - WasmSymConst "stg_EAGER_BLACKHOLE_info" + WasmSymConst "__stg_EAGER_BLACKHOLE_info" GCEnter1 -> do onFuncSym "__stg_gc_enter_1" [] [ty_word_cmm] pure $ SomeWasmExpr ty_word $ WasmExpr $ WasmSymConst "__stg_gc_enter_1" ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -118,7 +118,7 @@ inTreeCompilerArgs stg = do os <- queryHostTarget queryOS arch <- queryTargetTarget queryArch - let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64"] + let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32"] let withNativeCodeGen | unregisterised = False | arch `elem` codegen_arches = True ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,10 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -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('cmm_sink_sp', [ only_ways(['optasm']), + when(arch('wasm32'), fragile(24152)), + 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/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/regalloc/all.T ===================================== @@ -1,6 +1,8 @@ test('regalloc_unit_tests', [ when(unregisterised(), skip), extra_files(['no_spills.cmm']), when(not have_ncg(), skip), + # no regalloc business on wasm32 + when(arch('wasm32'), expect_fail), [ignore_stderr, only_ways(['normal'])], extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) ===================================== testsuite/tests/rts/T5644/all.T ===================================== @@ -1,8 +1,9 @@ test('T5644', [extra_files(['Conf.hs', 'ManyQueue.hs', 'Util.hs', 'heap-overflow.hs']), - + only_ways(['optasm','threaded1','threaded2']), extra_run_opts('+RTS -M20m -RTS'), - exit_code(251) # RTS exit code for "out of memory" + exit_code(251), # RTS exit code for "out of memory" + when(arch('wasm32'), [ignore_stderr, exit_code(1)]) ], multimod_compile_and_run, ['heap-overflow.hs','-O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -44,6 +44,8 @@ test('derefnull', when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), when(arch('javascript'), [ignore_stderr, exit_code(1)]), + # On wasm32, 0x0 is a valid linear memory address + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(0)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the @@ -82,6 +84,8 @@ test('divbyzero', when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), + # wasmtime returns sigabrt error code upon wasm traps + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(134)]), # since these test are supposed to crash the # profile report will be empty always. # so disable the check for profiling ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr ===================================== ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout ===================================== ===================================== testsuite/tests/simplCore/prog003/test.T ===================================== @@ -1,3 +1,3 @@ -test('simplCore.oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), +test('simplCore-oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), only_ways(['optasm'])], multimod_compile_and_run, ['OneShot2', '-v0']) ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -19,7 +19,8 @@ test('simplrun007', normal, compile_and_run, ['']) test('simplrun008', normal, compile_and_run, ['']) test('simplrun009', normal, compile_and_run, ['']) test('simplrun010', [extra_run_opts('24 16 8 +RTS -M10m -RTS'), - exit_code(251)] + exit_code(251), + when(arch('wasm32'), [ignore_stderr, exit_code(1)])] , compile_and_run, ['']) test('simplrun011', normal, compile_and_run, ['-fno-worker-wrapper']) ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/be8f4b7e2b5de4d086c21daeedf8d61dd002316e...c7304e989d27dd47634866ecf7226cfa2e6a9bb6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/be8f4b7e2b5de4d086c21daeedf8d61dd002316e...c7304e989d27dd47634866ecf7226cfa2e6a9bb6 You're receiving 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 Nov 4 22:48:10 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 04 Nov 2023 18:48:10 -0400 Subject: [Git][ghc/ghc][wip/int-index/term-capture] 302 commits: Don't attempt pattern synonym error recovery Message-ID: <6546ca2a335ea_27efe96d1bb814521270@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/term-capture at Glasgow Haskell Compiler / GHC Commits: e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04: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. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04: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. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - fdf3b2d9 by Vladislav Zavialov at 2023-11-05T01:47:02+03:00 WIP: Term variable capture - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df277cca7318f918481559abe51881140d96fb59...fdf3b2d90c2a2f945517832e64c9b1b6e3e340e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df277cca7318f918481559abe51881140d96fb59...fdf3b2d90c2a2f945517832e64c9b1b6e3e340e1 You're receiving 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 Nov 5 01:04:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 04 Nov 2023 21:04:00 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Add a test for I/O managers Message-ID: <6546ea0059c74_27efe9701c7cc4536940@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 849797ba by Duncan Coutts at 2023-11-04T21:03:33-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 6038e531 by Cheng Shao at 2023-11-04T21:03:33-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - 002a78d2 by Cheng Shao at 2023-11-04T21:03:33-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - f3e480bd by Cheng Shao at 2023-11-04T21:03:34-04:00 testsuite: fix optasm tests for wasm32 - - - - - b531928a by Matthew Pickering at 2023-11-04T21:03:34-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - 5639f1f5 by Alan Zimmerman at 2023-11-04T21:03:34-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 092bd496 by Simon Peyton Jones at 2023-11-04T21:03:34-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 5a735c06 by Andreas Klebinger at 2023-11-04T21:03:35-04:00 Remove an accidental git conflict marker from a comment. - - - - - 22 changed files: - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - hadrian/src/Settings/Builders/RunTest.hs - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/parser/should_compile/T23315/T23315.stderr - testsuite/tests/regalloc/all.T - + testsuite/tests/rts/IOManager.hsc - + testsuite/tests/rts/IOManager.stdout - testsuite/tests/rts/Makefile - testsuite/tests/rts/T5644/all.T - testsuite/tests/rts/all.T - testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr - testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout - testsuite/tests/simplCore/prog003/test.T - testsuite/tests/simplCore/should_run/all.T - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -883,7 +883,7 @@ lower_CmmReg lbl (CmmGlobal (GlobalRegUse greg reg_use_ty)) = do pure $ SomeWasmExpr ty_word $ WasmExpr $ - WasmSymConst "stg_EAGER_BLACKHOLE_info" + WasmSymConst "__stg_EAGER_BLACKHOLE_info" GCEnter1 -> do onFuncSym "__stg_gc_enter_1" [] [ty_word_cmm] pure $ SomeWasmExpr ty_word $ WasmExpr $ WasmSymConst "__stg_gc_enter_1" ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -118,7 +118,7 @@ inTreeCompilerArgs stg = do os <- queryHostTarget queryOS arch <- queryTargetTarget queryArch - let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64"] + let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32"] let withNativeCodeGen | unregisterised = False | arch `elem` codegen_arches = True ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,10 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -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('cmm_sink_sp', [ only_ways(['optasm']), + when(arch('wasm32'), fragile(24152)), + 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/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/regalloc/all.T ===================================== @@ -1,6 +1,8 @@ test('regalloc_unit_tests', [ when(unregisterised(), skip), extra_files(['no_spills.cmm']), when(not have_ncg(), skip), + # no regalloc business on wasm32 + when(arch('wasm32'), expect_fail), [ignore_stderr, only_ways(['normal'])], extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) ===================================== testsuite/tests/rts/IOManager.hsc ===================================== @@ -0,0 +1,1089 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE NamedFieldPuns #-} + +module Main (main) where + +-- When building within the GHC testsuite, we do not have access to the +-- async package, so we use a bundled version. The cut down version is +-- included at the end of this file. +#define USE_ASYNC_BUNDLED 1 + +import qualified Data.Map as Map +import Control.Monad +import Control.Concurrent +#ifndef USE_ASYNC_BUNDLED +import Control.Concurrent.Async +#endif +import Control.Concurrent.STM +import Control.Exception +import GHC.IO.Exception (ioe_errno) +import System.Timeout + +import Foreign +import Foreign.C +import System.Posix.Types (Fd(Fd)) + +import Prelude hiding (read) + +#include +#include + +{- +The purpose of these tests is to try to get some decent test coverage of the +GHC I/O managers. Most of the time the I/O manager only has to deal with one +thread blocking on a file descriptor at once, but it's important to also cover +the more complex cases: + + * Multiple file descriptors + * Multiple threads blocking on reading/writing + * Multiple threads blocking on reading and writing on the same file descriptor + * Killing threads blocking on reading/writing, while there are still other + remaining threads. + +We start with some simple scenarios and work up towards the complex scenarios. + +To do this we use anonymous unix domain sockets, created using socketpair(). +We cannot use ordinary pipes because they are unidirectional, with a write-only +file descriptor for one end and a read-only file descriptor for the other end: +which makes it impossible to have threads waiting for reading and writing on +the same file descriptor. + +Unfortunately this makes these tests Unix-only for now, due to the use of +socketpair(). In principle it's possible on Win32 to create a bidirectional +non-blocking pipe by using the named pipe API with a unique name (since this is +what the Win32 CreatePipe() API does internally, but uses blocking mode). Thus +this test could in principle be extended to work on Windows. + +For blocking on reading we need socket buffers to be empty, while for blocking +on writing we need socket buffers to be full. The empty case is nice and simple +but the full case is surprisingly asymmetric. + +The most complex scenario looks like this: a sequence of sockets, with +Haskell threads copying bytes between them. Data is injected at one end by a +special sender thread and collected at the other end of the pipeline by a +special receiver thread. Each socket has two directions, in one direction we +arrange for the socket buffers to be usually empty, so threads are typically +blocked on reading, while in the other direction we arrange for the buffers to +be usually full so that threads are typically blocked on writing. Between each +pair of sockets we use one or more Haskell threads that just copy a byte from +source socket to destination socket. This simple copying behaviour works with +both full and empty buffers, the difference is just whether the copying threads +are usually blocked on the reading or writing side. We use different numbers of +threads to get coverage of the 1 and many cases. + + ╍╍╍╍╍╍╍╍▶ data flow direction ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ + ┇ + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┇ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ▼ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ in ┃ out ┃ ┃ in ┃ out ┃ ┃ in ┃ out ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ out ┃ in ┃ ┃ out ┃ in ┃ ┃ out ┃ in ◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┇ + ┇ + ◀╍╍╍╍╍╍╍╍╍ data flow direction ◀╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ + +The simpler scenarios are all subsets of this complex one. + +These scenarios make use of two protocols: the "empty buffer" protocol and the +"full buffer" protocol. See 'EmptyBufPtcl' and 'FullBufPtcl' below for details. +-} + +main :: IO () +main = do + putStrLn "I/O manager tests" + sequence_ + [ do putStrLn (show n ++ ". " ++ show scenario) + runScenario scenario + | (n, scenario) <- zip [1 :: Int ..] scenarios ] + +data Scenario = + Scenario { + mode :: Mode, + nsockets :: Int, + nthreads :: Int, + cancelio :: Bool, + size :: Int + } + deriving Show + +data Mode = EmptyBufs + | FullBufs + | EmptyFullBufs + deriving Show + +scenarios :: [Scenario] +scenarios = + [ Scenario { mode, nsockets, nthreads, cancelio = False, size } + | mode <- [EmptyBufs, FullBufs, EmptyFullBufs] + , (nsockets, nthreads, size) <- + [ (1,0,10) + , (1,0,100) + , (2,1,100) + , (2,3,100) + , (3,5,1000) + ] + ] + ++ [ Scenario { mode, nsockets, nthreads, cancelio = True, size } + | (mode, nsockets, nthreads, size) <- + [ (EmptyBufs, 2,3,100) + , (FullBufs, 2,3,100) + , (EmptyFullBufs, 2,3,100) + , (EmptyFullBufs, 3,5,1000) + , (EmptyFullBufs, 7,10,5000) + ] + ] + +runScenario :: Scenario -> IO () +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyBuffersSimple size + +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyBuffers size nsockets nthreads + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets = 1, size } = + scenarioFullBuffersSimple size + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyFullBuffersSimple size + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioEmptyBuffersCancel size nthreads + +runScenario Scenario { mode = FullBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioFullBuffersCancel size nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = True, + nsockets, nthreads, size } = + scenarioEmptyFullBuffersCancel size nsockets nthreads + +{- +Scenario: empty socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ + ┏━━▼━━┳━━┿━━┓ +empty buffer ┃ s1a ┃ s1b ┃ + ┣━━━━━╋━━━━━┫ +unused buffer ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersSimple :: Int -> IO () +scenarioEmptyBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (receiverEmpty sync s1b) + let expected = input + checkExpected id expected actual + + +{- +Scenario: empty socket buffers, n sockets, n-1 copy hops, m copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ + n sockets in total, n-1 hops +-} +scenarioEmptyBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverEmpty sync snb) + let expected = input + checkExpected id expected actual + + +{- +Scenario: full socket buffers, 1 socket, 0 copy hops + ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ + │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersSimple :: Int -> IO () +scenarioFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s1b input) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: full socket buffers, n sockets, n-1 copy hops x m copy threads + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┗━━━━━━━━━━━━━━━━┛ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffers :: Int -> Int -> Int -> IO () +scenarioFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + sync <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderFull sync snb input) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty and full socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ + │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b◀──╂ ┃ + ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersSimple :: Int -> IO () +scenarioEmptyFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull s1b s1b) + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: empty & full socket buffers, 3 sockets, 2x2 copy hops x 5 copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ s2a ┃ s2b ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ + ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersCancel :: Int -> Int -> IO () +scenarioEmptyBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (copyBetweenFdsNChaosMonkey ReadFirst m schedule s1b s2a) + *> Concurrently (receiverEmpty sync s2b) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: full buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┗━━━━━━━━━━━━━━━━┛ + ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersCancel :: Int -> Int -> IO () +scenarioFullBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + mapM_ zeroFillFdBuffer [s1b, s2b] + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s2b input) + *> Concurrently (copyBetweenFdsNChaosMonkey WriteFirst m schedule s2a s1b) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty & full buffers, n sockets, 2(n-1) copy hops x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersCancel :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffersCancel sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedules1 = map chaosMonkeySchedule [1..] + schedules2 = map chaosMonkeySchedule [2..] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey ReadFirst m schedule sib si'a + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules1 + ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey WriteFirst m schedule si'a sib + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules2 + ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +checkExpected :: (Eq a, Show a) => ([Word8] -> a) -> [Word8] -> [Word8] -> IO () +checkExpected normalise expected actual + | expected_normalised == actual_normalised = return () + | otherwise = do + putStrLn "---------" + putStrLn $ "expected output differs:" + putStrLn $ "expected: " ++ show expected_normalised + putStrLn $ "actual: " ++ show actual_normalised + putStrLn "---------" + where + expected_normalised = normalise expected + actual_normalised = normalise actual + +listToBag :: Ord a => [a] -> Map.Map a Int +listToBag = Map.fromListWith (+) . map (\k -> (k,1)) + + +-- | The \"empty buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /reading/, i.e. the socket buffers are usually empty. +-- +-- We do this by synchronising between the sending and receiving ends so that +-- we only send one byte at a time, and the sender waits for the receiver to +-- get it. +-- +-- To do this we use a simple TVar Bool shared between the sender and receiver. +-- The sender sends a byte and then waits for the tvar to be set to true by +-- the receiver, at which point it resets the tvar to false and continues. +-- +-- This is usually used in a loop. +-- +newtype EmptyBufPtcl = EmptyBufPtcl (TVar Bool) + +newEmptyBufPtcl :: IO EmptyBufPtcl +newEmptyBufPtcl = EmptyBufPtcl <$> newTVarIO False + +sendEmptyBufPtcl :: EmptyBufPtcl -> Fd -> Word8 -> IO () +sendEmptyBufPtcl (EmptyBufPtcl sync) fd x = do + writeByteBlocking fd x + atomically $ do + continue <- readTVar sync + check continue + writeTVar sync False + +recvEmptyBufPtcl :: EmptyBufPtcl -> Fd -> IO (Maybe Word8) +recvEmptyBufPtcl (EmptyBufPtcl sync) fd = do + res <- readByteBlocking fd + atomically $ writeTVar sync True + return res + +-- | The \"full buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /writing/, i.e. the socket buffers are usually full. +-- +-- Sending through a full socket buffer is surprisingly tricky in practice +-- however. Suppose we have a thread blocked on writing into a socket (because +-- the socket) buffer is full. One might expect that if another thread reads +-- some data from the socket that this would unblock the writing thread. On +-- Linux at least, this is not necessarily the case. One may have to remove +-- much more data before the writer is unblocked. +-- +-- (It probably behaves this way because the Linux kernel implementation of +-- local socket tracks packets written, and each packet has some overhead. So +-- there has to be enough space to fit a whole packet.) +-- +-- So what we do is this: +-- +-- Write side: +-- * try to write a byte +-- * if it succeeds, repeat +-- * else it returns EAGAIN +-- * sync to release reader +-- * block on readiness for writing +-- * sync to stop reader +-- * repeat +-- +-- Read side: +-- * sync wait to be released +-- * read a byte (not expected to block) +-- * wait for either sync to stop or timeout +-- * either way, repeat +-- +-- The point is this: the writer will block on writing but while it is blocked it +-- will allow the read side to read a byte and then wait a bit. This might be +-- enough to free up space and allow the writer to complete (in which case the +-- reader will not read more bytes) but if it's not enough then the reader will +-- eventually stop waiting and read again. Eventually it must be enough to free -- up space. +-- +-- This protocol /should/ work across many hops, where the intermediate hops +-- just do simple blocking read\/write of bytes. So this should just be needed +-- at the far ends of the hops. +-- +data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait milliseconds + +newFullBufPtcl :: Int -> IO FullBufPtcl +newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitms + where + waitms = nhops * 100 --100ms per hop + +sendFullBufPtcl :: FullBufPtcl -> Fd -> Word8 -> IO () +sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do + res <- writeByteNonBlocking fd x + case res of + Just () -> + traceIO ("sendFullBufPtcl: wrote byte '" ++ show x + ++ "' on fd " ++ show fd) + Nothing -> do + atomically $ writeTVar sync True + traceIO ("sendFullBufPtcl: waiting to write byte '" ++ show x + ++ "' on fd " ++ show fd) + threadWaitWrite fd + atomically $ writeTVar sync False + -- go round again + sendFullBufPtcl ptcl fd x + +finishSendFullBufPtcl :: FullBufPtcl -> IO () +finishSendFullBufPtcl (FullBufPtcl sync _waitms) = + atomically $ writeTVar sync True -- release reader to finish + +recvFullBufPtcl :: FullBufPtcl -> Fd -> IO (Maybe Word8) +recvFullBufPtcl (FullBufPtcl sync waitms) fd = do + atomically $ readTVar sync >>= check + res <- readByteNonBlocking fd + case res of + Nothing -> fail "recvFullBufPtcl: unexpected blocking" + Just Nothing -> return Nothing + Just (Just x) -> do + traceIO ("recvFullBufPtcl: read byte '" ++ show x + ++ "' on fd " ++ show fd ++ ", now waiting") + _ <- timeout waitms $ atomically $ readTVar sync >>= check . not + return (Just x) + + +senderEmpty :: EmptyBufPtcl -> Fd -> [Word8] -> IO () +senderEmpty ptcl fd xs = do + mapM_ (sendEmptyBufPtcl ptcl fd) xs + shutdown fd SHUT_WR + +receiverEmpty :: EmptyBufPtcl -> Fd -> IO [Word8] +receiverEmpty ptcl fd = + untilM (recvEmptyBufPtcl ptcl fd) + + +senderFull :: FullBufPtcl -> Fd -> [Word8] -> IO () +senderFull ptcl fd xs = do + mapM_ (sendFullBufPtcl ptcl fd) xs + finishSendFullBufPtcl ptcl + shutdown fd SHUT_WR + +receiverFull :: FullBufPtcl -> Fd -> IO [Word8] +receiverFull ptcl fd = + untilM (recvFullBufPtcl ptcl fd) + + +untilM :: Monad m => m (Maybe x) -> m [x] +untilM action = + go [] + where + go xs = do + mx <- action + case mx of + Nothing -> return (reverse xs) + Just x -> go (x:xs) + + +reflectorEmptyToFull :: EmptyBufPtcl -> FullBufPtcl -> Fd -> Fd -> IO () +reflectorEmptyToFull ptclEmpty ptclFull fdFrom fdTo = do + copyloop + finishSendFullBufPtcl ptclFull + shutdown fdTo SHUT_WR + where + copyloop = do + mx <- recvEmptyBufPtcl ptclEmpty fdFrom + case mx of + Nothing -> return () + Just x -> do sendFullBufPtcl ptclFull fdTo x + copyloop + + +data ReadOrWriteFirst = ReadFirst | WriteFirst + deriving (Eq) + +-- | Use N threads concurrently to copy bytes. Each thread copies bytes, +-- one-by-one, from one Fd to another, either starting with a +-- read or a write (of 0). +-- +-- Returns the bytes copied, one sublist per thread. Note that the split +-- between threads will be non-deterministic. +-- +-- Once all bytes are copied (indicated by EOF on the source), the destination +-- Fd is shutdown for writing. This allows the other end of the destination Fd +-- will be receive an EOF. The destination Fd is only shutdown once all +-- threads are complete. +-- +copyBetweenFdsN :: ReadOrWriteFirst -> Int -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsN rw n fdFrom fdTo = do + result <- + runConcurrently $ + sequenceA + [ Concurrently (copyBetweenFds rw fdFrom fdTo) + | _i <- [0..n-1] ] + shutdown fdTo SHUT_WR + return result + + +copyBetweenFds :: ReadOrWriteFirst -> Fd -> Fd -> IO [Word8] +copyBetweenFds rw fdFrom fdTo = + case rw of + ReadFirst -> goRead [] + WriteFirst -> goWrite [] 0 + where + goRead acc = do + res <- readByteBlocking fdFrom + case res of + Nothing -> return (reverse acc) + Just byte -> goWrite acc byte + + goWrite acc byte = do + writeByteBlocking fdTo byte + goRead (byte:acc) + +-- | It turns out that chaos monkeys are more predictable than you might think. +-- +-- Each schedule entry (i,j) says: on transferring byte i, interrupt thread j. +-- +type ChaosMonkeySchedule = [(Int, Int)] + +chaosMonkeySchedule :: Int -> ChaosMonkeySchedule +chaosMonkeySchedule seed = + go (Prng seed) 0 + where + go prng i = + let (prng', a) = random prng + (prng'', j) = random prng' + i' = i + 1 + a `mod` 3 -- so 1,2,3 + in (i', j) : go prng'' i' + + +newtype Prng = Prng Int deriving Show + +random :: Prng -> (Prng, Int) +random (Prng n) = + let !n' = n * 1103515245 + 12345 + !x = (n' `div` 65536) `mod` 32768 + in (Prng n', x) + +-- | Like copyBetweenFdsN but with scheduled interruption of blocking I\/O +-- operations by asynchronous exceptions to cancel the I\/O. +-- +-- Each copying thread will catch the async exception and repeat. The sending +-- of the async exceptions is done based on a pre-defined schedule, based on +-- the n'th byte read by each thread. +-- +copyBetweenFdsNChaosMonkey :: ReadOrWriteFirst -> Int + -> ChaosMonkeySchedule + -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsNChaosMonkey rw n schedule fdFrom fdTo = + mask_ $ do + sync <- newTVarIO False + bracket (replicateM n (async (copyBetweenFds' sync))) + (mapM_ cancel) $ \copyThreads -> + withAsync (chaosMonkey sync copyThreads schedule) $ \monkeyThread -> do + _ <- waitAny copyThreads + results <- mapM wait copyThreads + cancel monkeyThread + shutdown fdTo SHUT_WR + return results + where + chaosMonkey :: TVar Bool -> [Async a] -> ChaosMonkeySchedule -> IO () + chaosMonkey sync threads = go 0 + where + go _ [] = return () + go !b sched@((i,_j):_) | b < i = do + awaitPulse sync + go (b+1) sched + go !b ((i,j):sched') | b == i = do + let tn = j `mod` n + tid = asyncThreadId (threads !! tn) + traceIO $ "interrupting thread number " ++ show tn ++ ", " ++ show tid + throwTo tid Interrupted + go b sched' + go !b ((_i,_j):sched') | otherwise = + go b sched' + + awaitPulse sync = atomically $ do + check =<< readTVar sync + writeTVar sync False + pulse sync = atomically $ writeTVar sync True + + copyBetweenFds' sync = + case rw of + ReadFirst -> goRead sync [] + WriteFirst -> goWrite sync [] 0 + + goRead sync acc = do + res <- try $ readByteBlocking fdFrom + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "read interrupted on " ++ show tid + goRead sync acc + Right Nothing -> return (reverse acc) + Right (Just byte) -> do + when (rw == WriteFirst) (pulse sync) + goWrite sync acc byte + + goWrite sync acc byte = do + res <- try $ writeByteBlocking fdTo byte + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "write interrupted on " ++ show tid + goWrite sync acc byte + Right () -> do + when (rw == ReadFirst) (pulse sync) + goRead sync (byte:acc) + +data Interrupted = Interrupted deriving Show +instance Exception Interrupted + +readByteBlocking :: Fd -> IO (Maybe Word8) +readByteBlocking fd = + allocaBytes 1 $ \bufptr -> + readLoop bufptr + where + readLoop bufptr = do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitRead fd + readLoop bufptr + | otherwise -> throwIO err + Right 1 -> Just <$> peek bufptr + Right 0 -> return Nothing + Right _ -> fail "impossible" + +readByteNonBlocking :: Fd -> IO (Maybe (Maybe Word8)) +readByteNonBlocking fd = + allocaBytes 1 $ \bufptr -> do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> Just . Just <$> peek bufptr + Right 0 -> return (Just Nothing) + Right _ -> fail "impossible" + +writeByteBlocking :: Fd -> Word8 -> IO () +writeByteBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + writeLoop bufptr + where + writeLoop bufptr = do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitWrite fd + writeLoop bufptr + | otherwise -> throwIO err + Right 1 -> return () + Right _ -> fail "impossible" + +writeByteNonBlocking :: Fd -> Word8 -> IO (Maybe ()) +writeByteNonBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> return (Just ()) + Right _ -> fail "impossible" + +read :: Fd -> Ptr Word8 -> CSize -> IO CLong +read fd buf count = + throwErrnoIfMinus1 "read" $ do + r <- c_read fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("read " ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + +write :: Fd -> Ptr Word8 -> CSize -> IO CLong +write fd buf count = + throwErrnoIfMinus1 "write" $ do + r <- c_write fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("write" ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + + +-- Ensure the fd's write buffer is full of zeros. +-- +-- The Fd must be in non-blocking mode. +-- +-- Uses 1 byte writes, which on Linux at least, fills up the buffer quickly. +-- Presumably this is due to the overhead of tracking as packets. +-- +zeroFillFdBuffer :: Fd -> IO () +zeroFillFdBuffer fd = + allocaBytes 1 $ \bufptr -> poke bufptr 0 >> go bufptr 0 + where + go :: Ptr Word8 -> Int -> IO () + go !bufptr !count = do + res <- c_write fd bufptr 1 + errno <- getErrno + case () of + _ | res == 1 -> + go bufptr (count + 1) + + | res < 0 && (errno == eAGAIN || errno == eWOULDBLOCK) -> + return () + + _ -> throwErrno "zeroFillFdBuffer" + + +-- We have to use a local socket rather than a pipe, because we need a +-- bi-directional pipe, and Posix (specially Linux) pipes are unidirectional. +-- It needs to be bidirectional so that we have multiple threads ending up +-- blocked reading and writing on the same socket, to test the IO manager +-- handles this case correctly. +-- +-- Also set the buffer size to be as small as possible (1 page). +-- +localSocketPair :: IO (Fd, Fd) +localSocketPair = + allocaArray 2 $ \sv -> do + let sockdomain = #{const AF_LOCAL} + socktype = #{const SOCK_STREAM} + sockproto = 0 + throwErrnoIfMinus1_ "socketpair" $ + c_socketpair sockdomain socktype sockproto sv + [a,b] <- peekArray 2 sv + forM_ [Fd a, Fd b] $ \fd@(Fd fdcint) -> do + c_fcntl_write fdcint #{const F_SETFL} #{const O_NONBLOCK} + let bufsize = 1024 + setsockopt fd #{const SOL_SOCKET} #{const SO_SNDBUF} bufsize + setsockopt fd #{const SOL_SOCKET} #{const SO_RCVBUF} bufsize + return (Fd a, Fd b) + +withLocalSocketPair :: (Fd -> Fd -> IO a) -> IO a +withLocalSocketPair action = + bracket + localSocketPair + (\(a, b) -> close a >> close b) + (uncurry action) + +withLocalSocketPairs :: Int -> ([(Fd, Fd)] -> IO a) -> IO a +withLocalSocketPairs n = + bracket + (replicateM n localSocketPair) + (mapM_ (\(a, b) -> close a >> close b)) + +setsockopt :: Fd -> CInt -> CInt -> CInt -> IO () +setsockopt fd level option value = + with value $ \p -> + throwErrnoIfMinus1_ "setsockopt" $ + c_setsockopt fd level option p (fromIntegral (sizeOf value)) + +close :: Fd -> IO () +close fd = + throwErrnoIfMinus1_ "close" $ + c_close fd + +data ShutdownDir = SHUT_RD | SHUT_WR | SHUT_RDWR + +shutdown :: Fd -> ShutdownDir -> IO () +shutdown fd dir = + throwErrnoIfMinus1_ "shutdown" $ + c_shutdown fd how + where + how :: CInt + how = case dir of + SHUT_RD -> #{const SHUT_RD} + SHUT_WR -> #{const SHUT_WR} + SHUT_RDWR -> #{const SHUT_RDWR} + +-- int socketpair(int domain, int type, int protocol, int sv[2]); +foreign import ccall "sys/socket.h socketpair" + c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt + +foreign import ccall "sys/socket.h setsockopt" + c_setsockopt :: Fd -> CInt -> CInt -> Ptr CInt -> CInt -> IO CInt + +foreign import capi unsafe "HsBase.h fcntl" + c_fcntl_write :: CInt -> CInt -> CLong -> IO CInt + +foreign import ccall unsafe "unistd.h write" + c_write :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h read" + c_read :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h close" + c_close :: Fd -> IO CInt + +foreign import ccall unsafe "sys/socket.h shutdown" + c_shutdown :: Fd -> CInt -> IO CInt + +traceIO :: String -> IO () +traceIO _ = return () +--traceIO = BSC.putStrLn . BSC.pack + + +#ifdef USE_ASYNC_BUNDLED + +------------------------------------------------------------------------------- +-- Mini async library +-- + +data Async a = Async + { asyncThreadId :: !ThreadId + , _asyncWait :: STM (Either SomeException a) + } + +async :: IO a -> IO (Async a) +async = \action -> do + var <- newEmptyTMVarIO + t <- forkFinally action (\r -> atomically $ putTMVar var r) + return (Async t (readTMVar var)) + +withAsync :: IO a -> (Async a -> IO b) -> IO b +withAsync action inner = + mask $ \restore -> do + a <- async (restore action) + restore (inner a) `finally` uninterruptibleCancel a + +cancel :: Async a -> IO () +cancel a@(Async t _) = throwTo t AsyncCancelled <* waitCatch a + +uninterruptibleCancel :: Async a -> IO () +uninterruptibleCancel = uninterruptibleMask_ . cancel + +data AsyncCancelled = AsyncCancelled + deriving Show + +instance Exception AsyncCancelled where + fromException = asyncExceptionFromException + toException = asyncExceptionToException + +wait :: Async a -> IO a +wait = atomically . waitSTM + +waitSTM :: Async a -> STM a +waitSTM a = do + r <- waitCatchSTM a + either throwSTM return r + +waitCatch :: Async a -> IO (Either SomeException a) +waitCatch = atomically . waitCatchSTM + +waitCatchSTM :: Async a -> STM (Either SomeException a) +waitCatchSTM (Async _ w) = w + +waitBoth :: Async a -> Async b -> IO (a,b) +waitBoth left right = atomically (waitBothSTM left right) + +waitBothSTM :: Async a -> Async b -> STM (a,b) +waitBothSTM left right = do + a <- waitSTM left `orElse` (waitSTM right >> retry) + b <- waitSTM right + return (a,b) + +waitAny :: [Async a] -> IO (Async a, a) +waitAny = atomically . waitAnySTM + +waitAnySTM :: [Async a] -> STM (Async a, a) +waitAnySTM = foldr orElse retry . map (\a -> waitSTM a >>= \r -> return (a, r)) + +newtype Concurrently a = Concurrently { runConcurrently :: IO a } + +instance Functor Concurrently where + fmap f (Concurrently a) = Concurrently $ f <$> a + +instance Applicative Concurrently where + pure = Concurrently . return + Concurrently fs <*> Concurrently as = + Concurrently $ (\(f, a) -> f a) <$> concurrently fs as + +concurrently :: IO a -> IO b -> IO (a,b) +concurrently left right = + withAsync left $ \a -> + withAsync right $ \b -> + waitBoth a b + +#endif + ===================================== testsuite/tests/rts/IOManager.stdout ===================================== @@ -0,0 +1,21 @@ +I/O manager tests +1. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +2. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +3. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +4. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +5. Scenario {mode = EmptyBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +6. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +7. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +8. Scenario {mode = FullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +9. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +10. Scenario {mode = FullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +11. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +12. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +13. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +14. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +15. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +16. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +17. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +18. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +19. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = True, size = 1000} +20. Scenario {mode = EmptyFullBufs, nsockets = 7, nthreads = 10, cancelio = True, size = 5000} ===================================== testsuite/tests/rts/Makefile ===================================== @@ -157,3 +157,8 @@ T23142: grep -m1 -c "CATCH_STM_FRAME" T23142.log grep -m1 -c "MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log grep -m1 -c "SMALL_MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log + +HSC2HS_OPTS = --cc="$(TEST_CC)" $(addprefix --cflag=,$(TEST_CC_OPTS)) --ld=$(TEST_CC) $(addprefix --lflag=,$(TEST_CC_OPTS)) + +IOManager.hs: IOManager.hsc + '$(HSC2HS)' $(HSC2HS_OPTS) $< ===================================== testsuite/tests/rts/T5644/all.T ===================================== @@ -1,8 +1,9 @@ test('T5644', [extra_files(['Conf.hs', 'ManyQueue.hs', 'Util.hs', 'heap-overflow.hs']), - + only_ways(['optasm','threaded1','threaded2']), extra_run_opts('+RTS -M20m -RTS'), - exit_code(251) # RTS exit code for "out of memory" + exit_code(251), # RTS exit code for "out of memory" + when(arch('wasm32'), [ignore_stderr, exit_code(1)]) ], multimod_compile_and_run, ['heap-overflow.hs','-O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -44,6 +44,8 @@ test('derefnull', when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), when(arch('javascript'), [ignore_stderr, exit_code(1)]), + # On wasm32, 0x0 is a valid linear memory address + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(0)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the @@ -82,6 +84,8 @@ test('divbyzero', when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), + # wasmtime returns sigabrt error code upon wasm traps + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(134)]), # since these test are supposed to crash the # profile report will be empty always. # so disable the check for profiling @@ -604,3 +608,7 @@ test('T23221', test('T23142', [unless(debug_rts(), skip), req_interp], makefile_test, ['T23142']) test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) + +test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), + pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], + compile_and_run, ['']) ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr ===================================== ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout ===================================== ===================================== testsuite/tests/simplCore/prog003/test.T ===================================== @@ -1,3 +1,3 @@ -test('simplCore.oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), +test('simplCore-oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), only_ways(['optasm'])], multimod_compile_and_run, ['OneShot2', '-v0']) ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -19,7 +19,8 @@ test('simplrun007', normal, compile_and_run, ['']) test('simplrun008', normal, compile_and_run, ['']) test('simplrun009', normal, compile_and_run, ['']) test('simplrun010', [extra_run_opts('24 16 8 +RTS -M10m -RTS'), - exit_code(251)] + exit_code(251), + when(arch('wasm32'), [ignore_stderr, exit_code(1)])] , compile_and_run, ['']) test('simplrun011', normal, compile_and_run, ['-fno-worker-wrapper']) ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7304e989d27dd47634866ecf7226cfa2e6a9bb6...5a735c06bb37a213a5a2dca0cfa909a77b673895 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7304e989d27dd47634866ecf7226cfa2e6a9bb6...5a735c06bb37a213a5a2dca0cfa909a77b673895 You're receiving 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 Nov 5 04:24:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 00:24:24 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add a test for I/O managers Message-ID: <654718f811810_27efe974e541505554f0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - 4 changed files: - + testsuite/tests/rts/IOManager.hsc - + testsuite/tests/rts/IOManager.stdout - testsuite/tests/rts/Makefile - testsuite/tests/rts/all.T Changes: ===================================== testsuite/tests/rts/IOManager.hsc ===================================== @@ -0,0 +1,1089 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE NamedFieldPuns #-} + +module Main (main) where + +-- When building within the GHC testsuite, we do not have access to the +-- async package, so we use a bundled version. The cut down version is +-- included at the end of this file. +#define USE_ASYNC_BUNDLED 1 + +import qualified Data.Map as Map +import Control.Monad +import Control.Concurrent +#ifndef USE_ASYNC_BUNDLED +import Control.Concurrent.Async +#endif +import Control.Concurrent.STM +import Control.Exception +import GHC.IO.Exception (ioe_errno) +import System.Timeout + +import Foreign +import Foreign.C +import System.Posix.Types (Fd(Fd)) + +import Prelude hiding (read) + +#include +#include + +{- +The purpose of these tests is to try to get some decent test coverage of the +GHC I/O managers. Most of the time the I/O manager only has to deal with one +thread blocking on a file descriptor at once, but it's important to also cover +the more complex cases: + + * Multiple file descriptors + * Multiple threads blocking on reading/writing + * Multiple threads blocking on reading and writing on the same file descriptor + * Killing threads blocking on reading/writing, while there are still other + remaining threads. + +We start with some simple scenarios and work up towards the complex scenarios. + +To do this we use anonymous unix domain sockets, created using socketpair(). +We cannot use ordinary pipes because they are unidirectional, with a write-only +file descriptor for one end and a read-only file descriptor for the other end: +which makes it impossible to have threads waiting for reading and writing on +the same file descriptor. + +Unfortunately this makes these tests Unix-only for now, due to the use of +socketpair(). In principle it's possible on Win32 to create a bidirectional +non-blocking pipe by using the named pipe API with a unique name (since this is +what the Win32 CreatePipe() API does internally, but uses blocking mode). Thus +this test could in principle be extended to work on Windows. + +For blocking on reading we need socket buffers to be empty, while for blocking +on writing we need socket buffers to be full. The empty case is nice and simple +but the full case is surprisingly asymmetric. + +The most complex scenario looks like this: a sequence of sockets, with +Haskell threads copying bytes between them. Data is injected at one end by a +special sender thread and collected at the other end of the pipeline by a +special receiver thread. Each socket has two directions, in one direction we +arrange for the socket buffers to be usually empty, so threads are typically +blocked on reading, while in the other direction we arrange for the buffers to +be usually full so that threads are typically blocked on writing. Between each +pair of sockets we use one or more Haskell threads that just copy a byte from +source socket to destination socket. This simple copying behaviour works with +both full and empty buffers, the difference is just whether the copying threads +are usually blocked on the reading or writing side. We use different numbers of +threads to get coverage of the 1 and many cases. + + ╍╍╍╍╍╍╍╍▶ data flow direction ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ + ┇ + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┇ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ▼ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ in ┃ out ┃ ┃ in ┃ out ┃ ┃ in ┃ out ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ out ┃ in ┃ ┃ out ┃ in ┃ ┃ out ┃ in ◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┇ + ┇ + ◀╍╍╍╍╍╍╍╍╍ data flow direction ◀╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ + +The simpler scenarios are all subsets of this complex one. + +These scenarios make use of two protocols: the "empty buffer" protocol and the +"full buffer" protocol. See 'EmptyBufPtcl' and 'FullBufPtcl' below for details. +-} + +main :: IO () +main = do + putStrLn "I/O manager tests" + sequence_ + [ do putStrLn (show n ++ ". " ++ show scenario) + runScenario scenario + | (n, scenario) <- zip [1 :: Int ..] scenarios ] + +data Scenario = + Scenario { + mode :: Mode, + nsockets :: Int, + nthreads :: Int, + cancelio :: Bool, + size :: Int + } + deriving Show + +data Mode = EmptyBufs + | FullBufs + | EmptyFullBufs + deriving Show + +scenarios :: [Scenario] +scenarios = + [ Scenario { mode, nsockets, nthreads, cancelio = False, size } + | mode <- [EmptyBufs, FullBufs, EmptyFullBufs] + , (nsockets, nthreads, size) <- + [ (1,0,10) + , (1,0,100) + , (2,1,100) + , (2,3,100) + , (3,5,1000) + ] + ] + ++ [ Scenario { mode, nsockets, nthreads, cancelio = True, size } + | (mode, nsockets, nthreads, size) <- + [ (EmptyBufs, 2,3,100) + , (FullBufs, 2,3,100) + , (EmptyFullBufs, 2,3,100) + , (EmptyFullBufs, 3,5,1000) + , (EmptyFullBufs, 7,10,5000) + ] + ] + +runScenario :: Scenario -> IO () +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyBuffersSimple size + +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyBuffers size nsockets nthreads + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets = 1, size } = + scenarioFullBuffersSimple size + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyFullBuffersSimple size + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioEmptyBuffersCancel size nthreads + +runScenario Scenario { mode = FullBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioFullBuffersCancel size nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = True, + nsockets, nthreads, size } = + scenarioEmptyFullBuffersCancel size nsockets nthreads + +{- +Scenario: empty socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ + ┏━━▼━━┳━━┿━━┓ +empty buffer ┃ s1a ┃ s1b ┃ + ┣━━━━━╋━━━━━┫ +unused buffer ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersSimple :: Int -> IO () +scenarioEmptyBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (receiverEmpty sync s1b) + let expected = input + checkExpected id expected actual + + +{- +Scenario: empty socket buffers, n sockets, n-1 copy hops, m copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ + n sockets in total, n-1 hops +-} +scenarioEmptyBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverEmpty sync snb) + let expected = input + checkExpected id expected actual + + +{- +Scenario: full socket buffers, 1 socket, 0 copy hops + ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ + │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersSimple :: Int -> IO () +scenarioFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s1b input) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: full socket buffers, n sockets, n-1 copy hops x m copy threads + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┗━━━━━━━━━━━━━━━━┛ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffers :: Int -> Int -> Int -> IO () +scenarioFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + sync <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderFull sync snb input) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty and full socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ + │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b◀──╂ ┃ + ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersSimple :: Int -> IO () +scenarioEmptyFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull s1b s1b) + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: empty & full socket buffers, 3 sockets, 2x2 copy hops x 5 copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ s2a ┃ s2b ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ + ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersCancel :: Int -> Int -> IO () +scenarioEmptyBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (copyBetweenFdsNChaosMonkey ReadFirst m schedule s1b s2a) + *> Concurrently (receiverEmpty sync s2b) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: full buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┗━━━━━━━━━━━━━━━━┛ + ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersCancel :: Int -> Int -> IO () +scenarioFullBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + mapM_ zeroFillFdBuffer [s1b, s2b] + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s2b input) + *> Concurrently (copyBetweenFdsNChaosMonkey WriteFirst m schedule s2a s1b) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty & full buffers, n sockets, 2(n-1) copy hops x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersCancel :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffersCancel sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedules1 = map chaosMonkeySchedule [1..] + schedules2 = map chaosMonkeySchedule [2..] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey ReadFirst m schedule sib si'a + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules1 + ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey WriteFirst m schedule si'a sib + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules2 + ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +checkExpected :: (Eq a, Show a) => ([Word8] -> a) -> [Word8] -> [Word8] -> IO () +checkExpected normalise expected actual + | expected_normalised == actual_normalised = return () + | otherwise = do + putStrLn "---------" + putStrLn $ "expected output differs:" + putStrLn $ "expected: " ++ show expected_normalised + putStrLn $ "actual: " ++ show actual_normalised + putStrLn "---------" + where + expected_normalised = normalise expected + actual_normalised = normalise actual + +listToBag :: Ord a => [a] -> Map.Map a Int +listToBag = Map.fromListWith (+) . map (\k -> (k,1)) + + +-- | The \"empty buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /reading/, i.e. the socket buffers are usually empty. +-- +-- We do this by synchronising between the sending and receiving ends so that +-- we only send one byte at a time, and the sender waits for the receiver to +-- get it. +-- +-- To do this we use a simple TVar Bool shared between the sender and receiver. +-- The sender sends a byte and then waits for the tvar to be set to true by +-- the receiver, at which point it resets the tvar to false and continues. +-- +-- This is usually used in a loop. +-- +newtype EmptyBufPtcl = EmptyBufPtcl (TVar Bool) + +newEmptyBufPtcl :: IO EmptyBufPtcl +newEmptyBufPtcl = EmptyBufPtcl <$> newTVarIO False + +sendEmptyBufPtcl :: EmptyBufPtcl -> Fd -> Word8 -> IO () +sendEmptyBufPtcl (EmptyBufPtcl sync) fd x = do + writeByteBlocking fd x + atomically $ do + continue <- readTVar sync + check continue + writeTVar sync False + +recvEmptyBufPtcl :: EmptyBufPtcl -> Fd -> IO (Maybe Word8) +recvEmptyBufPtcl (EmptyBufPtcl sync) fd = do + res <- readByteBlocking fd + atomically $ writeTVar sync True + return res + +-- | The \"full buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /writing/, i.e. the socket buffers are usually full. +-- +-- Sending through a full socket buffer is surprisingly tricky in practice +-- however. Suppose we have a thread blocked on writing into a socket (because +-- the socket) buffer is full. One might expect that if another thread reads +-- some data from the socket that this would unblock the writing thread. On +-- Linux at least, this is not necessarily the case. One may have to remove +-- much more data before the writer is unblocked. +-- +-- (It probably behaves this way because the Linux kernel implementation of +-- local socket tracks packets written, and each packet has some overhead. So +-- there has to be enough space to fit a whole packet.) +-- +-- So what we do is this: +-- +-- Write side: +-- * try to write a byte +-- * if it succeeds, repeat +-- * else it returns EAGAIN +-- * sync to release reader +-- * block on readiness for writing +-- * sync to stop reader +-- * repeat +-- +-- Read side: +-- * sync wait to be released +-- * read a byte (not expected to block) +-- * wait for either sync to stop or timeout +-- * either way, repeat +-- +-- The point is this: the writer will block on writing but while it is blocked it +-- will allow the read side to read a byte and then wait a bit. This might be +-- enough to free up space and allow the writer to complete (in which case the +-- reader will not read more bytes) but if it's not enough then the reader will +-- eventually stop waiting and read again. Eventually it must be enough to free -- up space. +-- +-- This protocol /should/ work across many hops, where the intermediate hops +-- just do simple blocking read\/write of bytes. So this should just be needed +-- at the far ends of the hops. +-- +data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait milliseconds + +newFullBufPtcl :: Int -> IO FullBufPtcl +newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitms + where + waitms = nhops * 100 --100ms per hop + +sendFullBufPtcl :: FullBufPtcl -> Fd -> Word8 -> IO () +sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do + res <- writeByteNonBlocking fd x + case res of + Just () -> + traceIO ("sendFullBufPtcl: wrote byte '" ++ show x + ++ "' on fd " ++ show fd) + Nothing -> do + atomically $ writeTVar sync True + traceIO ("sendFullBufPtcl: waiting to write byte '" ++ show x + ++ "' on fd " ++ show fd) + threadWaitWrite fd + atomically $ writeTVar sync False + -- go round again + sendFullBufPtcl ptcl fd x + +finishSendFullBufPtcl :: FullBufPtcl -> IO () +finishSendFullBufPtcl (FullBufPtcl sync _waitms) = + atomically $ writeTVar sync True -- release reader to finish + +recvFullBufPtcl :: FullBufPtcl -> Fd -> IO (Maybe Word8) +recvFullBufPtcl (FullBufPtcl sync waitms) fd = do + atomically $ readTVar sync >>= check + res <- readByteNonBlocking fd + case res of + Nothing -> fail "recvFullBufPtcl: unexpected blocking" + Just Nothing -> return Nothing + Just (Just x) -> do + traceIO ("recvFullBufPtcl: read byte '" ++ show x + ++ "' on fd " ++ show fd ++ ", now waiting") + _ <- timeout waitms $ atomically $ readTVar sync >>= check . not + return (Just x) + + +senderEmpty :: EmptyBufPtcl -> Fd -> [Word8] -> IO () +senderEmpty ptcl fd xs = do + mapM_ (sendEmptyBufPtcl ptcl fd) xs + shutdown fd SHUT_WR + +receiverEmpty :: EmptyBufPtcl -> Fd -> IO [Word8] +receiverEmpty ptcl fd = + untilM (recvEmptyBufPtcl ptcl fd) + + +senderFull :: FullBufPtcl -> Fd -> [Word8] -> IO () +senderFull ptcl fd xs = do + mapM_ (sendFullBufPtcl ptcl fd) xs + finishSendFullBufPtcl ptcl + shutdown fd SHUT_WR + +receiverFull :: FullBufPtcl -> Fd -> IO [Word8] +receiverFull ptcl fd = + untilM (recvFullBufPtcl ptcl fd) + + +untilM :: Monad m => m (Maybe x) -> m [x] +untilM action = + go [] + where + go xs = do + mx <- action + case mx of + Nothing -> return (reverse xs) + Just x -> go (x:xs) + + +reflectorEmptyToFull :: EmptyBufPtcl -> FullBufPtcl -> Fd -> Fd -> IO () +reflectorEmptyToFull ptclEmpty ptclFull fdFrom fdTo = do + copyloop + finishSendFullBufPtcl ptclFull + shutdown fdTo SHUT_WR + where + copyloop = do + mx <- recvEmptyBufPtcl ptclEmpty fdFrom + case mx of + Nothing -> return () + Just x -> do sendFullBufPtcl ptclFull fdTo x + copyloop + + +data ReadOrWriteFirst = ReadFirst | WriteFirst + deriving (Eq) + +-- | Use N threads concurrently to copy bytes. Each thread copies bytes, +-- one-by-one, from one Fd to another, either starting with a +-- read or a write (of 0). +-- +-- Returns the bytes copied, one sublist per thread. Note that the split +-- between threads will be non-deterministic. +-- +-- Once all bytes are copied (indicated by EOF on the source), the destination +-- Fd is shutdown for writing. This allows the other end of the destination Fd +-- will be receive an EOF. The destination Fd is only shutdown once all +-- threads are complete. +-- +copyBetweenFdsN :: ReadOrWriteFirst -> Int -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsN rw n fdFrom fdTo = do + result <- + runConcurrently $ + sequenceA + [ Concurrently (copyBetweenFds rw fdFrom fdTo) + | _i <- [0..n-1] ] + shutdown fdTo SHUT_WR + return result + + +copyBetweenFds :: ReadOrWriteFirst -> Fd -> Fd -> IO [Word8] +copyBetweenFds rw fdFrom fdTo = + case rw of + ReadFirst -> goRead [] + WriteFirst -> goWrite [] 0 + where + goRead acc = do + res <- readByteBlocking fdFrom + case res of + Nothing -> return (reverse acc) + Just byte -> goWrite acc byte + + goWrite acc byte = do + writeByteBlocking fdTo byte + goRead (byte:acc) + +-- | It turns out that chaos monkeys are more predictable than you might think. +-- +-- Each schedule entry (i,j) says: on transferring byte i, interrupt thread j. +-- +type ChaosMonkeySchedule = [(Int, Int)] + +chaosMonkeySchedule :: Int -> ChaosMonkeySchedule +chaosMonkeySchedule seed = + go (Prng seed) 0 + where + go prng i = + let (prng', a) = random prng + (prng'', j) = random prng' + i' = i + 1 + a `mod` 3 -- so 1,2,3 + in (i', j) : go prng'' i' + + +newtype Prng = Prng Int deriving Show + +random :: Prng -> (Prng, Int) +random (Prng n) = + let !n' = n * 1103515245 + 12345 + !x = (n' `div` 65536) `mod` 32768 + in (Prng n', x) + +-- | Like copyBetweenFdsN but with scheduled interruption of blocking I\/O +-- operations by asynchronous exceptions to cancel the I\/O. +-- +-- Each copying thread will catch the async exception and repeat. The sending +-- of the async exceptions is done based on a pre-defined schedule, based on +-- the n'th byte read by each thread. +-- +copyBetweenFdsNChaosMonkey :: ReadOrWriteFirst -> Int + -> ChaosMonkeySchedule + -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsNChaosMonkey rw n schedule fdFrom fdTo = + mask_ $ do + sync <- newTVarIO False + bracket (replicateM n (async (copyBetweenFds' sync))) + (mapM_ cancel) $ \copyThreads -> + withAsync (chaosMonkey sync copyThreads schedule) $ \monkeyThread -> do + _ <- waitAny copyThreads + results <- mapM wait copyThreads + cancel monkeyThread + shutdown fdTo SHUT_WR + return results + where + chaosMonkey :: TVar Bool -> [Async a] -> ChaosMonkeySchedule -> IO () + chaosMonkey sync threads = go 0 + where + go _ [] = return () + go !b sched@((i,_j):_) | b < i = do + awaitPulse sync + go (b+1) sched + go !b ((i,j):sched') | b == i = do + let tn = j `mod` n + tid = asyncThreadId (threads !! tn) + traceIO $ "interrupting thread number " ++ show tn ++ ", " ++ show tid + throwTo tid Interrupted + go b sched' + go !b ((_i,_j):sched') | otherwise = + go b sched' + + awaitPulse sync = atomically $ do + check =<< readTVar sync + writeTVar sync False + pulse sync = atomically $ writeTVar sync True + + copyBetweenFds' sync = + case rw of + ReadFirst -> goRead sync [] + WriteFirst -> goWrite sync [] 0 + + goRead sync acc = do + res <- try $ readByteBlocking fdFrom + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "read interrupted on " ++ show tid + goRead sync acc + Right Nothing -> return (reverse acc) + Right (Just byte) -> do + when (rw == WriteFirst) (pulse sync) + goWrite sync acc byte + + goWrite sync acc byte = do + res <- try $ writeByteBlocking fdTo byte + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "write interrupted on " ++ show tid + goWrite sync acc byte + Right () -> do + when (rw == ReadFirst) (pulse sync) + goRead sync (byte:acc) + +data Interrupted = Interrupted deriving Show +instance Exception Interrupted + +readByteBlocking :: Fd -> IO (Maybe Word8) +readByteBlocking fd = + allocaBytes 1 $ \bufptr -> + readLoop bufptr + where + readLoop bufptr = do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitRead fd + readLoop bufptr + | otherwise -> throwIO err + Right 1 -> Just <$> peek bufptr + Right 0 -> return Nothing + Right _ -> fail "impossible" + +readByteNonBlocking :: Fd -> IO (Maybe (Maybe Word8)) +readByteNonBlocking fd = + allocaBytes 1 $ \bufptr -> do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> Just . Just <$> peek bufptr + Right 0 -> return (Just Nothing) + Right _ -> fail "impossible" + +writeByteBlocking :: Fd -> Word8 -> IO () +writeByteBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + writeLoop bufptr + where + writeLoop bufptr = do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitWrite fd + writeLoop bufptr + | otherwise -> throwIO err + Right 1 -> return () + Right _ -> fail "impossible" + +writeByteNonBlocking :: Fd -> Word8 -> IO (Maybe ()) +writeByteNonBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> return (Just ()) + Right _ -> fail "impossible" + +read :: Fd -> Ptr Word8 -> CSize -> IO CLong +read fd buf count = + throwErrnoIfMinus1 "read" $ do + r <- c_read fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("read " ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + +write :: Fd -> Ptr Word8 -> CSize -> IO CLong +write fd buf count = + throwErrnoIfMinus1 "write" $ do + r <- c_write fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("write" ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + + +-- Ensure the fd's write buffer is full of zeros. +-- +-- The Fd must be in non-blocking mode. +-- +-- Uses 1 byte writes, which on Linux at least, fills up the buffer quickly. +-- Presumably this is due to the overhead of tracking as packets. +-- +zeroFillFdBuffer :: Fd -> IO () +zeroFillFdBuffer fd = + allocaBytes 1 $ \bufptr -> poke bufptr 0 >> go bufptr 0 + where + go :: Ptr Word8 -> Int -> IO () + go !bufptr !count = do + res <- c_write fd bufptr 1 + errno <- getErrno + case () of + _ | res == 1 -> + go bufptr (count + 1) + + | res < 0 && (errno == eAGAIN || errno == eWOULDBLOCK) -> + return () + + _ -> throwErrno "zeroFillFdBuffer" + + +-- We have to use a local socket rather than a pipe, because we need a +-- bi-directional pipe, and Posix (specially Linux) pipes are unidirectional. +-- It needs to be bidirectional so that we have multiple threads ending up +-- blocked reading and writing on the same socket, to test the IO manager +-- handles this case correctly. +-- +-- Also set the buffer size to be as small as possible (1 page). +-- +localSocketPair :: IO (Fd, Fd) +localSocketPair = + allocaArray 2 $ \sv -> do + let sockdomain = #{const AF_LOCAL} + socktype = #{const SOCK_STREAM} + sockproto = 0 + throwErrnoIfMinus1_ "socketpair" $ + c_socketpair sockdomain socktype sockproto sv + [a,b] <- peekArray 2 sv + forM_ [Fd a, Fd b] $ \fd@(Fd fdcint) -> do + c_fcntl_write fdcint #{const F_SETFL} #{const O_NONBLOCK} + let bufsize = 1024 + setsockopt fd #{const SOL_SOCKET} #{const SO_SNDBUF} bufsize + setsockopt fd #{const SOL_SOCKET} #{const SO_RCVBUF} bufsize + return (Fd a, Fd b) + +withLocalSocketPair :: (Fd -> Fd -> IO a) -> IO a +withLocalSocketPair action = + bracket + localSocketPair + (\(a, b) -> close a >> close b) + (uncurry action) + +withLocalSocketPairs :: Int -> ([(Fd, Fd)] -> IO a) -> IO a +withLocalSocketPairs n = + bracket + (replicateM n localSocketPair) + (mapM_ (\(a, b) -> close a >> close b)) + +setsockopt :: Fd -> CInt -> CInt -> CInt -> IO () +setsockopt fd level option value = + with value $ \p -> + throwErrnoIfMinus1_ "setsockopt" $ + c_setsockopt fd level option p (fromIntegral (sizeOf value)) + +close :: Fd -> IO () +close fd = + throwErrnoIfMinus1_ "close" $ + c_close fd + +data ShutdownDir = SHUT_RD | SHUT_WR | SHUT_RDWR + +shutdown :: Fd -> ShutdownDir -> IO () +shutdown fd dir = + throwErrnoIfMinus1_ "shutdown" $ + c_shutdown fd how + where + how :: CInt + how = case dir of + SHUT_RD -> #{const SHUT_RD} + SHUT_WR -> #{const SHUT_WR} + SHUT_RDWR -> #{const SHUT_RDWR} + +-- int socketpair(int domain, int type, int protocol, int sv[2]); +foreign import ccall "sys/socket.h socketpair" + c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt + +foreign import ccall "sys/socket.h setsockopt" + c_setsockopt :: Fd -> CInt -> CInt -> Ptr CInt -> CInt -> IO CInt + +foreign import capi unsafe "HsBase.h fcntl" + c_fcntl_write :: CInt -> CInt -> CLong -> IO CInt + +foreign import ccall unsafe "unistd.h write" + c_write :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h read" + c_read :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h close" + c_close :: Fd -> IO CInt + +foreign import ccall unsafe "sys/socket.h shutdown" + c_shutdown :: Fd -> CInt -> IO CInt + +traceIO :: String -> IO () +traceIO _ = return () +--traceIO = BSC.putStrLn . BSC.pack + + +#ifdef USE_ASYNC_BUNDLED + +------------------------------------------------------------------------------- +-- Mini async library +-- + +data Async a = Async + { asyncThreadId :: !ThreadId + , _asyncWait :: STM (Either SomeException a) + } + +async :: IO a -> IO (Async a) +async = \action -> do + var <- newEmptyTMVarIO + t <- forkFinally action (\r -> atomically $ putTMVar var r) + return (Async t (readTMVar var)) + +withAsync :: IO a -> (Async a -> IO b) -> IO b +withAsync action inner = + mask $ \restore -> do + a <- async (restore action) + restore (inner a) `finally` uninterruptibleCancel a + +cancel :: Async a -> IO () +cancel a@(Async t _) = throwTo t AsyncCancelled <* waitCatch a + +uninterruptibleCancel :: Async a -> IO () +uninterruptibleCancel = uninterruptibleMask_ . cancel + +data AsyncCancelled = AsyncCancelled + deriving Show + +instance Exception AsyncCancelled where + fromException = asyncExceptionFromException + toException = asyncExceptionToException + +wait :: Async a -> IO a +wait = atomically . waitSTM + +waitSTM :: Async a -> STM a +waitSTM a = do + r <- waitCatchSTM a + either throwSTM return r + +waitCatch :: Async a -> IO (Either SomeException a) +waitCatch = atomically . waitCatchSTM + +waitCatchSTM :: Async a -> STM (Either SomeException a) +waitCatchSTM (Async _ w) = w + +waitBoth :: Async a -> Async b -> IO (a,b) +waitBoth left right = atomically (waitBothSTM left right) + +waitBothSTM :: Async a -> Async b -> STM (a,b) +waitBothSTM left right = do + a <- waitSTM left `orElse` (waitSTM right >> retry) + b <- waitSTM right + return (a,b) + +waitAny :: [Async a] -> IO (Async a, a) +waitAny = atomically . waitAnySTM + +waitAnySTM :: [Async a] -> STM (Async a, a) +waitAnySTM = foldr orElse retry . map (\a -> waitSTM a >>= \r -> return (a, r)) + +newtype Concurrently a = Concurrently { runConcurrently :: IO a } + +instance Functor Concurrently where + fmap f (Concurrently a) = Concurrently $ f <$> a + +instance Applicative Concurrently where + pure = Concurrently . return + Concurrently fs <*> Concurrently as = + Concurrently $ (\(f, a) -> f a) <$> concurrently fs as + +concurrently :: IO a -> IO b -> IO (a,b) +concurrently left right = + withAsync left $ \a -> + withAsync right $ \b -> + waitBoth a b + +#endif + ===================================== testsuite/tests/rts/IOManager.stdout ===================================== @@ -0,0 +1,21 @@ +I/O manager tests +1. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +2. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +3. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +4. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +5. Scenario {mode = EmptyBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +6. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +7. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +8. Scenario {mode = FullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +9. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +10. Scenario {mode = FullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +11. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +12. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +13. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +14. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +15. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +16. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +17. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +18. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +19. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = True, size = 1000} +20. Scenario {mode = EmptyFullBufs, nsockets = 7, nthreads = 10, cancelio = True, size = 5000} ===================================== testsuite/tests/rts/Makefile ===================================== @@ -157,3 +157,8 @@ T23142: grep -m1 -c "CATCH_STM_FRAME" T23142.log grep -m1 -c "MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log grep -m1 -c "SMALL_MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log + +HSC2HS_OPTS = --cc="$(TEST_CC)" $(addprefix --cflag=,$(TEST_CC_OPTS)) --ld=$(TEST_CC) $(addprefix --lflag=,$(TEST_CC_OPTS)) + +IOManager.hs: IOManager.hsc + '$(HSC2HS)' $(HSC2HS_OPTS) $< ===================================== testsuite/tests/rts/all.T ===================================== @@ -604,3 +604,7 @@ test('T23221', test('T23142', [unless(debug_rts(), skip), req_interp], makefile_test, ['T23142']) test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) + +test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), + pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], + compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0dfb1fa799af254c8a1e1045fc3996af2d57a613...2e448f985331e02a0b7c16b25d000183068afc04 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0dfb1fa799af254c8a1e1045fc3996af2d57a613...2e448f985331e02a0b7c16b25d000183068afc04 You're receiving 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 Nov 5 04:25:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 00:25:00 -0400 Subject: [Git][ghc/ghc][master] 3 commits: compiler: fix eager blackhole symbol in wasm32 NCG Message-ID: <6547191c63b8a_27efe97500bc8c558630@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - 10 changed files: - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - hadrian/src/Settings/Builders/RunTest.hs - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/regalloc/all.T - testsuite/tests/rts/T5644/all.T - testsuite/tests/rts/all.T - testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr - testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout - testsuite/tests/simplCore/prog003/test.T - testsuite/tests/simplCore/should_run/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -883,7 +883,7 @@ lower_CmmReg lbl (CmmGlobal (GlobalRegUse greg reg_use_ty)) = do pure $ SomeWasmExpr ty_word $ WasmExpr $ - WasmSymConst "stg_EAGER_BLACKHOLE_info" + WasmSymConst "__stg_EAGER_BLACKHOLE_info" GCEnter1 -> do onFuncSym "__stg_gc_enter_1" [] [ty_word_cmm] pure $ SomeWasmExpr ty_word $ WasmExpr $ WasmSymConst "__stg_gc_enter_1" ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -118,7 +118,7 @@ inTreeCompilerArgs stg = do os <- queryHostTarget queryOS arch <- queryTargetTarget queryArch - let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64"] + let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32"] let withNativeCodeGen | unregisterised = False | arch `elem` codegen_arches = True ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,10 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -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('cmm_sink_sp', [ only_ways(['optasm']), + when(arch('wasm32'), fragile(24152)), + 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/regalloc/all.T ===================================== @@ -1,6 +1,8 @@ test('regalloc_unit_tests', [ when(unregisterised(), skip), extra_files(['no_spills.cmm']), when(not have_ncg(), skip), + # no regalloc business on wasm32 + when(arch('wasm32'), expect_fail), [ignore_stderr, only_ways(['normal'])], extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) ===================================== testsuite/tests/rts/T5644/all.T ===================================== @@ -1,8 +1,9 @@ test('T5644', [extra_files(['Conf.hs', 'ManyQueue.hs', 'Util.hs', 'heap-overflow.hs']), - + only_ways(['optasm','threaded1','threaded2']), extra_run_opts('+RTS -M20m -RTS'), - exit_code(251) # RTS exit code for "out of memory" + exit_code(251), # RTS exit code for "out of memory" + when(arch('wasm32'), [ignore_stderr, exit_code(1)]) ], multimod_compile_and_run, ['heap-overflow.hs','-O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -44,6 +44,8 @@ test('derefnull', when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), when(arch('javascript'), [ignore_stderr, exit_code(1)]), + # On wasm32, 0x0 is a valid linear memory address + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(0)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the @@ -82,6 +84,8 @@ test('divbyzero', when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), + # wasmtime returns sigabrt error code upon wasm traps + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(134)]), # since these test are supposed to crash the # profile report will be empty always. # so disable the check for profiling ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr ===================================== ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout ===================================== ===================================== testsuite/tests/simplCore/prog003/test.T ===================================== @@ -1,3 +1,3 @@ -test('simplCore.oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), +test('simplCore-oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), only_ways(['optasm'])], multimod_compile_and_run, ['OneShot2', '-v0']) ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -19,7 +19,8 @@ test('simplrun007', normal, compile_and_run, ['']) test('simplrun008', normal, compile_and_run, ['']) test('simplrun009', normal, compile_and_run, ['']) test('simplrun010', [extra_run_opts('24 16 8 +RTS -M10m -RTS'), - exit_code(251)] + exit_code(251), + when(arch('wasm32'), [ignore_stderr, exit_code(1)])] , compile_and_run, ['']) test('simplrun011', normal, compile_and_run, ['-fno-worker-wrapper']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e448f985331e02a0b7c16b25d000183068afc04...1b90735c99f1179328f6dd67dbcc81f964901a19 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e448f985331e02a0b7c16b25d000183068afc04...1b90735c99f1179328f6dd67dbcc81f964901a19 You're receiving 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 Nov 5 04:26:25 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 00:26:25 -0400 Subject: [Git][ghc/ghc][master] EPA: make locA a function, not a field name Message-ID: <654719715121c_27efe975006ed056607c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 5 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/ThToHs.hs - testsuite/tests/parser/should_compile/T23315/T23315.stderr Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== testsuite/tests/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db9a649693b1a1ba1d6b1ce1b86889578d2e86f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db9a649693b1a1ba1d6b1ce1b86889578d2e86f8 You're receiving 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 Nov 5 04:27:02 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 00:27:02 -0400 Subject: [Git][ghc/ghc][master] Update the unification count in wrapUnifierX Message-ID: <6547199684e9e_27efe974e52a805692e1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - 3 changed files: - compiler/GHC/Tc/Solver/Monad.hs - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/833e250c74da9899896796b6ff8d1630f8295ec3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/833e250c74da9899896796b6ff8d1630f8295ec3 You're receiving 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 Nov 5 04:27:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 00:27:24 -0400 Subject: [Git][ghc/ghc][master] Remove an accidental git conflict marker from a comment. Message-ID: <654719ac87585_27efe97500acc45697b2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 1 changed file: - compiler/GHC/HsToCore/Pmc.hs Changes: ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e451139f7a97d219ed8630b054d3a0875037aa0c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e451139f7a97d219ed8630b054d3a0875037aa0c You're receiving 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 Nov 5 11:26:31 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 Nov 2023 06:26:31 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-l2l-cleanup Message-ID: <65477be7507b8_27efe97f177ecc5923a1@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-l2l-cleanup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-l2l-cleanup You're receiving 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 Nov 5 16:03:35 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 Nov 2023 11:03:35 -0500 Subject: [Git][ghc/ghc][wip/az/epa-l2l-cleanup] EPA: get rid of l2l and friends Message-ID: <6547bcd71e1a9_27efe9857a9da861371f@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-l2l-cleanup at Glasgow Haskell Compiler / GHC Commits: 9b08f177 by Alan Zimmerman at 2023-11-05T16:03:02+00:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - 16 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - utils/haddock Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4332,6 +4332,9 @@ glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA +n2l :: LocatedN a -> LocatedA a +n2l (L la a) = L (l2l la) a + anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -50,7 +50,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. - la2na, na2la, n2l, l2n, l2l, la2la, + l2l, la2la, reLoc, HasLoc(..), getHasLocList, @@ -993,29 +993,13 @@ knowing that in most cases the original list is empty. -- |Helper function (temporary) during transition of names -- Discards any annotations -l2n :: LocatedAn a1 a2 -> LocatedN a2 -l2n (L la a) = L (noAnnSrcSpan (locA la)) a - -n2l :: LocatedN a -> LocatedA a -n2l (L la a) = L (na2la la) a - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2na :: SrcSpanAnn' a -> SrcSpanAnnN -la2na l = noAnnSrcSpan (locA l) - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 -la2la (L la a) = L (noAnnSrcSpan (locA la)) a - -l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = SrcSpanAnn EpAnnNotUsed (locA l) +l2l :: (HasLoc a, HasAnnotation b) => a -> b +l2l a = noAnnSrcSpan (getHasLoc a) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann -na2la l = noAnnSrcSpan (locA l) +la2la :: (HasLoc l, HasAnnotation l2) => (GenLocated l a) -> (GenLocated l2 a) +la2la (L la a) = L (noAnnSrcSpan (getHasLoc la)) a locA :: (HasLoc a) => a -> SrcSpan locA = getHasLoc ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1837,7 +1837,7 @@ instance DisambECP (HsExpr GhcPs) where mkHsParPV l lpar e rpar = do cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (HsPar (EpAnn (spanAsAnchor l) NoEpAnns cs) lpar e rpar) - mkHsVarPV v@(L l _) = return $ L (na2la l) (HsVar noExtField v) + mkHsVarPV v@(L l _) = return $ L (l2l l) (HsVar noExtField v) mkHsLitPV (L l a) = do cs <- getCommentsFor l return $ L l (HsLit (comment (realSrcSpan l) cs) a) @@ -1912,7 +1912,7 @@ instance DisambECP (PatBuilder GhcPs) where mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat mkHsDoPV l _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat mkHsParPV l lpar p rpar = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar) - mkHsVarPV v@(getLoc -> l) = return $ L (na2la l) (PatBuilderVar v) + mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v) mkHsLitPV lit@(L l a) = do checkUnboxedLitPat lit return $ L l (PatBuilderPat (LitPat noExtField a)) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -244,7 +244,7 @@ finishHsVar (L l name) = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - ; return (HsVar noExtField (L (la2na l) name), unitFV name) } + ; return (HsVar noExtField (L (l2l l) name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) rnUnboundVar v = do @@ -280,7 +280,7 @@ rnExpr (HsVar _ (L l v)) -> rnExpr (ExplicitList noAnn []) | otherwise - -> finishHsVar (L (na2la l) nm) + -> finishHsVar (L (l2l l) nm) }}} rnExpr (HsIPVar x v) ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2539,7 +2539,7 @@ extendPatSynEnv dup_fields_ok has_sel val_decls local_fix_env thing = do { return ((PatSynName bnd_name, con_info) : names) | L bind_loc (PatSynBind _ (PSB { psb_id = L _ n, psb_args = as })) <- bind = do - bnd_name <- newTopSrcBinder (L (la2na bind_loc) n) + bnd_name <- newTopSrcBinder (L (l2l bind_loc) n) let con_info = mkConInfo (conDetailsArity length as) [] return ((PatSynName bnd_name, con_info) : names) | otherwise ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -869,10 +869,10 @@ getLocalNonValBinders fixity_env new_tc dup_fields_ok has_sel tc_decl -- NOT for type/data instances = do { let TyDeclBinders (main_bndr, tc_flav) at_bndrs sig_bndrs (LConsWithFields cons_with_flds flds) = hsLTyClDeclBinders tc_decl - ; tycon_name <- newTopSrcBinder $ l2n main_bndr - ; at_names <- mapM (newTopSrcBinder . l2n . fst) at_bndrs - ; sig_names <- mapM (newTopSrcBinder . l2n) sig_bndrs - ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; tycon_name <- newTopSrcBinder $ la2la main_bndr + ; at_names <- mapM (newTopSrcBinder . la2la . fst) at_bndrs + ; sig_names <- mapM (newTopSrcBinder . la2la) sig_bndrs + ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst con_names_with_flds) flds ; mapM_ (add_dup_fld_errs flds') con_names_with_flds ; let tc_gre = mkLocalTyConGRE (fmap (const tycon_name) tc_flav) tycon_name @@ -947,7 +947,7 @@ getLocalNonValBinders fixity_env new_di dup_fields_ok has_sel mb_cls dfid@(DataFamInstDecl { dfid_eqn = ti_decl }) = do { main_name <- unLoc <$> lookupFamInstName mb_cls (feqn_tycon ti_decl) ; let LConsWithFields cons_with_flds flds = hsDataFamInstBinders dfid - ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst sub_names) flds ; mapM_ (add_dup_fld_errs flds') sub_names ; let fld_env = mk_fld_env sub_names flds' @@ -2133,14 +2133,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) where occ = occName n {- ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -558,7 +558,7 @@ rnPatAndThen _ (NPat x (L l lit) mb_neg _eq) ; return (NPat x (L l lit') mb_neg' eq') } rnPatAndThen mk (NPlusKPat _ rdr (L l lit) _ _ _ ) - = do { new_name <- newPatName mk (l2n rdr) + = do { new_name <- newPatName mk (la2la rdr) ; (lit', _) <- liftCpsFV $ rnOverLit lit -- See Note [Negative zero] -- We skip negateName as -- negative zero doesn't make ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -391,12 +391,12 @@ mkQuasiQuoteExpr :: UntypedSpliceFlavour -> Name mkQuasiQuoteExpr flavour quoter (L q_span' quote) = L q_span $ HsApp noComments (L q_span $ HsApp noComments (L q_span - (HsVar noExtField (L (la2na q_span) quote_selector))) + (HsVar noExtField (L (l2l q_span) quote_selector))) quoterExpr) quoteExpr where q_span = noAnnSrcSpan (locA q_span') - quoterExpr = L q_span $! HsVar noExtField $! (L (la2na q_span) quoter) + quoterExpr = L q_span $! HsVar noExtField $! (L (l2l q_span) quoter) quoteExpr = L q_span $! HsLit noComments $! HsString NoSourceText quote quote_selector = case flavour of UntypedExpSplice -> quoteExpName ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1241,7 +1241,7 @@ dynCompileExpr expr = do parsed_expr <- parseExpr expr -- > Data.Dynamic.toDyn expr let loc = getLoc parsed_expr - to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (la2na loc) $ getRdrName toDynName) + to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (l2l loc) $ getRdrName toDynName) parsed_expr hval <- compileParsedExpr to_dyn_expr return (unsafeCoerce hval :: Dynamic) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2292,7 +2292,7 @@ mkFunBindSE arity loc fun pats_and_exprs mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBind fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches) + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches) -- | Make a function binding. If no equations are given, produce a function -- with the given arity that uses an empty case expression for the last @@ -2320,7 +2320,7 @@ mkRdrFunBindEC :: Arity -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- fmap _ z = case z of {} @@ -2344,7 +2344,7 @@ mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindSE arity fun@(L loc fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- compare _ _ = error "Void compare" ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -710,7 +710,7 @@ lookupChildrenExport spec_parent rdr_items = mapAndReportM doOne rdr_items do { ub <- reportUnboundName unboundName ; let l = getLoc n gre = mkLocalGRE UnboundGRE NoParent ub - ; return (L l (IEName noExtField (L (la2na l) ub)), gre)} + ; return (L l (IEName noExtField (L (l2l l) ub)), gre)} FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) -> do { checkPatSynParent spec_parent par child_nm ; return (replaceLWrappedName n child_nm, child) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1542,7 +1542,7 @@ splitHsAppTys hs_ty 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) + = ( L (l2l sp) (HsTyVar noAnn prom op) , HsValArg l : HsValArg r : as ) go f as = (f, as) ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -195,7 +195,7 @@ tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs, tcdMeths = default_binds})) = recoverM (return emptyLHsBinds) $ setSrcSpan (getLocA class_name) $ - do { clas <- tcLookupLocatedClass (n2l class_name) + do { clas <- tcLookupLocatedClass (la2la class_name) -- We make a separate binding for each default method. -- At one time I used a single AbsBinds for all of them, thus @@ -281,7 +281,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn local_dm_ty = instantiateMethod clas global_dm_id (mkTyVarTys tyvars) - lm_bind = dm_bind { fun_id = L (la2na bind_loc) local_dm_name } + lm_bind = dm_bind { fun_id = L (l2l bind_loc) local_dm_name } -- Substitute the local_meth_name for the binder -- NB: the binding is always a FunBind ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -610,7 +610,7 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) -- itself, so we make do with the location of family name ; (co_ax_branch, co_ax_validity_info) <- tcTyFamInstEqn fam_tc mb_clsinfo - (L (na2la $ getLoc fam_lname) eqn) + (L (l2l $ getLoc fam_lname) eqn) -- (2) check for validity ; checkConsistentFamInst mb_clsinfo fam_tc co_ax_branch ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -943,7 +943,7 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) mk_mg :: LHsExpr GhcRn -> MatchGroup GhcRn (LHsExpr GhcRn) mk_mg body = mkMatchGroup (Generated SkipPmc) (noLocA [builder_match]) where - builder_args = [L (na2la loc) (VarPat noExtField (L loc n)) + builder_args = [L (l2l loc) (VarPat noExtField (L loc n)) | L loc n <- args] builder_match = mkMatch (mkPrefixFunRhs ps_lname) builder_args body ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b75ff8a88bbdd0d60032a4e304d37ec65526c06b +Subproject commit 2cbf7f0a55898e0c2827ae9ad13727b34877e793 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b08f1773fe4a13fdde428afa019e3cf9b7f4a5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b08f1773fe4a13fdde428afa019e3cf9b7f4a5f You're receiving 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 Nov 5 17:50:48 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 Nov 2023 12:50:48 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 51 commits: JS/userguide: add explanation of writing jsbits Message-ID: <6547d5f8caae8_27efe987ff3ad462731@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - ad4dabca by Alan Zimmerman at 2023-11-05T11:22:44+00:00 EPA: get rid of l2l and friends - - - - - 1a12566a by Alan Zimmerman at 2023-11-05T11:22:54+00:00 EPA: get rid of l2l and friends - - - - - 0e5ce7cb by Alan Zimmerman at 2023-11-05T11:22:54+00:00 EPA: harmonise acsa and acsA [2023-10-01 Sun] Failing tests HsDocTy - - - - - ffa0672d by Alan Zimmerman at 2023-11-05T16:36:30+00:00 EPA: Replace Anchor with EpaLocation [2023-09-21 Thu] Only test failing is HsDocTy - - - - - 91e50c11 by Alan Zimmerman at 2023-11-05T16:36:35+00:00 EPA: get rid of AnchorOperation [2023-09-21 Thu] Only error is HsDocTy - - - - - 53d45e65 by Alan Zimmerman at 2023-11-05T16:36:35+00:00 EPA: splitLHsForAllTyInvis no ann returned - - - - - 6028d3d2 by Alan Zimmerman at 2023-11-05T16:36:35+00:00 EPA: Replace Monoid with NoAnn [2023-08-19 Sat] AddClassMethod fails - - - - - 16cf1d13 by Alan Zimmerman at 2023-11-05T16:36:36+00:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - 2092f422 by Alan Zimmerman at 2023-11-05T16:36:36+00:00 EPA: Present no longer has annotation - - - - - b46e3586 by Alan Zimmerman at 2023-11-05T16:36:36+00:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 916aa034 by Alan Zimmerman at 2023-11-05T16:36:36+00:00 EPA: Remove parenthesizeHsType - - - - - 57dd8fb2 by Alan Zimmerman at 2023-11-05T16:48:22+00:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - 3dd3c6e0 by Alan Zimmerman at 2023-11-05T16:58:51+00:00 EPA: Remove SrcSpanAnn [2023-10-12 Thu] Failures HsDocTy T15242 - - - - - e8102c1d by Alan Zimmerman at 2023-11-05T16:58:52+00:00 EPA: Remove SrcSpanAnn completely - - - - - f73fc9fb by Alan Zimmerman at 2023-11-05T16:58:52+00:00 Clean up mkScope - - - - - ee9531d4 by Alan Zimmerman at 2023-11-05T16:58:52+00:00 EPA: Clean up TC Monad Utils - - - - - 7c879d34 by Alan Zimmerman at 2023-11-05T16:58:52+00:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - fd4d3911 by Alan Zimmerman at 2023-11-05T16:58:52+00:00 Semigroup instances for AnnList and AnnContext - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de36136680d4fde57abd0467829c9e4db2f3d90c...fd4d3911ad2c88a8f07bc5158b703d4d15942bd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de36136680d4fde57abd0467829c9e4db2f3d90c...fd4d3911ad2c88a8f07bc5158b703d4d15942bd2 You're receiving 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 Nov 5 19:42:53 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 05 Nov 2023 14:42:53 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 22 commits: docs: fix ScopedTypeVariables example (#24101) Message-ID: <6547f03d82c7f_27efe98a7fb3d863325f@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - e661c26d by Apoorv Ingle at 2023-11-05T20:42:36+01:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 26 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/653af9dd3bef4bbdc91b9d378452a0c4d61f4e6f...e661c26df00566f811fd2516aba3ccaa604b9dd9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/653af9dd3bef4bbdc91b9d378452a0c4d61f4e6f...e661c26df00566f811fd2516aba3ccaa604b9dd9 You're receiving 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 Nov 5 20:44:27 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 05 Nov 2023 15:44:27 -0500 Subject: [Git][ghc/ghc][wip/az/epa-l2l-cleanup] EPA: get rid of l2l and friends Message-ID: <6547feaba4d2f_27efe98bef724464041b@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-l2l-cleanup at Glasgow Haskell Compiler / GHC Commits: 64ccd790 by Alan Zimmerman at 2023-11-05T20:44:02+00:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - 16 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - utils/haddock Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4332,6 +4332,9 @@ glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA +n2l :: LocatedN a -> LocatedA a +n2l (L la a) = L (l2l la) a + anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -50,7 +50,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. - la2na, na2la, n2l, l2n, l2l, la2la, + l2l, la2la, reLoc, HasLoc(..), getHasLocList, @@ -991,31 +991,15 @@ knowing that in most cases the original list is empty. -- --------------------------------------------------------------------- --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -l2n :: LocatedAn a1 a2 -> LocatedN a2 -l2n (L la a) = L (noAnnSrcSpan (locA la)) a +l2l :: (HasLoc a, HasAnnotation b) => a -> b +l2l a = noAnnSrcSpan (getHasLoc a) -n2l :: LocatedN a -> LocatedA a -n2l (L la a) = L (na2la la) a - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2na :: SrcSpanAnn' a -> SrcSpanAnnN -la2na l = noAnnSrcSpan (locA l) - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 -la2la (L la a) = L (noAnnSrcSpan (locA la)) a - -l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = SrcSpanAnn EpAnnNotUsed (locA l) - --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann -na2la l = noAnnSrcSpan (locA l) +la2la :: (HasLoc l, HasAnnotation l2) => GenLocated l a -> GenLocated l2 a +la2la (L la a) = L (noAnnSrcSpan (getHasLoc la)) a locA :: (HasLoc a) => a -> SrcSpan locA = getHasLoc ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1837,7 +1837,7 @@ instance DisambECP (HsExpr GhcPs) where mkHsParPV l lpar e rpar = do cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (HsPar (EpAnn (spanAsAnchor l) NoEpAnns cs) lpar e rpar) - mkHsVarPV v@(L l _) = return $ L (na2la l) (HsVar noExtField v) + mkHsVarPV v@(L l _) = return $ L (l2l l) (HsVar noExtField v) mkHsLitPV (L l a) = do cs <- getCommentsFor l return $ L l (HsLit (comment (realSrcSpan l) cs) a) @@ -1912,7 +1912,7 @@ instance DisambECP (PatBuilder GhcPs) where mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat mkHsDoPV l _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat mkHsParPV l lpar p rpar = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar) - mkHsVarPV v@(getLoc -> l) = return $ L (na2la l) (PatBuilderVar v) + mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v) mkHsLitPV lit@(L l a) = do checkUnboxedLitPat lit return $ L l (PatBuilderPat (LitPat noExtField a)) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -244,7 +244,7 @@ finishHsVar (L l name) = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - ; return (HsVar noExtField (L (la2na l) name), unitFV name) } + ; return (HsVar noExtField (L (l2l l) name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) rnUnboundVar v = do @@ -280,7 +280,7 @@ rnExpr (HsVar _ (L l v)) -> rnExpr (ExplicitList noAnn []) | otherwise - -> finishHsVar (L (na2la l) nm) + -> finishHsVar (L (l2l l) nm) }}} rnExpr (HsIPVar x v) ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2539,7 +2539,7 @@ extendPatSynEnv dup_fields_ok has_sel val_decls local_fix_env thing = do { return ((PatSynName bnd_name, con_info) : names) | L bind_loc (PatSynBind _ (PSB { psb_id = L _ n, psb_args = as })) <- bind = do - bnd_name <- newTopSrcBinder (L (la2na bind_loc) n) + bnd_name <- newTopSrcBinder (L (l2l bind_loc) n) let con_info = mkConInfo (conDetailsArity length as) [] return ((PatSynName bnd_name, con_info) : names) | otherwise ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -869,10 +869,10 @@ getLocalNonValBinders fixity_env new_tc dup_fields_ok has_sel tc_decl -- NOT for type/data instances = do { let TyDeclBinders (main_bndr, tc_flav) at_bndrs sig_bndrs (LConsWithFields cons_with_flds flds) = hsLTyClDeclBinders tc_decl - ; tycon_name <- newTopSrcBinder $ l2n main_bndr - ; at_names <- mapM (newTopSrcBinder . l2n . fst) at_bndrs - ; sig_names <- mapM (newTopSrcBinder . l2n) sig_bndrs - ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; tycon_name <- newTopSrcBinder $ la2la main_bndr + ; at_names <- mapM (newTopSrcBinder . la2la . fst) at_bndrs + ; sig_names <- mapM (newTopSrcBinder . la2la) sig_bndrs + ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst con_names_with_flds) flds ; mapM_ (add_dup_fld_errs flds') con_names_with_flds ; let tc_gre = mkLocalTyConGRE (fmap (const tycon_name) tc_flav) tycon_name @@ -947,7 +947,7 @@ getLocalNonValBinders fixity_env new_di dup_fields_ok has_sel mb_cls dfid@(DataFamInstDecl { dfid_eqn = ti_decl }) = do { main_name <- unLoc <$> lookupFamInstName mb_cls (feqn_tycon ti_decl) ; let LConsWithFields cons_with_flds flds = hsDataFamInstBinders dfid - ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst sub_names) flds ; mapM_ (add_dup_fld_errs flds') sub_names ; let fld_env = mk_fld_env sub_names flds' @@ -2133,14 +2133,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) where occ = occName n {- ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -558,7 +558,7 @@ rnPatAndThen _ (NPat x (L l lit) mb_neg _eq) ; return (NPat x (L l lit') mb_neg' eq') } rnPatAndThen mk (NPlusKPat _ rdr (L l lit) _ _ _ ) - = do { new_name <- newPatName mk (l2n rdr) + = do { new_name <- newPatName mk (la2la rdr) ; (lit', _) <- liftCpsFV $ rnOverLit lit -- See Note [Negative zero] -- We skip negateName as -- negative zero doesn't make ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -391,12 +391,12 @@ mkQuasiQuoteExpr :: UntypedSpliceFlavour -> Name mkQuasiQuoteExpr flavour quoter (L q_span' quote) = L q_span $ HsApp noComments (L q_span $ HsApp noComments (L q_span - (HsVar noExtField (L (la2na q_span) quote_selector))) + (HsVar noExtField (L (l2l q_span) quote_selector))) quoterExpr) quoteExpr where q_span = noAnnSrcSpan (locA q_span') - quoterExpr = L q_span $! HsVar noExtField $! (L (la2na q_span) quoter) + quoterExpr = L q_span $! HsVar noExtField $! (L (l2l q_span) quoter) quoteExpr = L q_span $! HsLit noComments $! HsString NoSourceText quote quote_selector = case flavour of UntypedExpSplice -> quoteExpName ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1241,7 +1241,7 @@ dynCompileExpr expr = do parsed_expr <- parseExpr expr -- > Data.Dynamic.toDyn expr let loc = getLoc parsed_expr - to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (la2na loc) $ getRdrName toDynName) + to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (l2l loc) $ getRdrName toDynName) parsed_expr hval <- compileParsedExpr to_dyn_expr return (unsafeCoerce hval :: Dynamic) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2292,7 +2292,7 @@ mkFunBindSE arity loc fun pats_and_exprs mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBind fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches) + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches) -- | Make a function binding. If no equations are given, produce a function -- with the given arity that uses an empty case expression for the last @@ -2320,7 +2320,7 @@ mkRdrFunBindEC :: Arity -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- fmap _ z = case z of {} @@ -2344,7 +2344,7 @@ mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindSE arity fun@(L loc fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- compare _ _ = error "Void compare" ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -710,7 +710,7 @@ lookupChildrenExport spec_parent rdr_items = mapAndReportM doOne rdr_items do { ub <- reportUnboundName unboundName ; let l = getLoc n gre = mkLocalGRE UnboundGRE NoParent ub - ; return (L l (IEName noExtField (L (la2na l) ub)), gre)} + ; return (L l (IEName noExtField (L (l2l l) ub)), gre)} FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) -> do { checkPatSynParent spec_parent par child_nm ; return (replaceLWrappedName n child_nm, child) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1542,7 +1542,7 @@ splitHsAppTys hs_ty 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) + = ( L (l2l sp) (HsTyVar noAnn prom op) , HsValArg l : HsValArg r : as ) go f as = (f, as) ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -195,7 +195,7 @@ tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs, tcdMeths = default_binds})) = recoverM (return emptyLHsBinds) $ setSrcSpan (getLocA class_name) $ - do { clas <- tcLookupLocatedClass (n2l class_name) + do { clas <- tcLookupLocatedClass (la2la class_name) -- We make a separate binding for each default method. -- At one time I used a single AbsBinds for all of them, thus @@ -281,7 +281,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn local_dm_ty = instantiateMethod clas global_dm_id (mkTyVarTys tyvars) - lm_bind = dm_bind { fun_id = L (la2na bind_loc) local_dm_name } + lm_bind = dm_bind { fun_id = L (l2l bind_loc) local_dm_name } -- Substitute the local_meth_name for the binder -- NB: the binding is always a FunBind ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -610,7 +610,7 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) -- itself, so we make do with the location of family name ; (co_ax_branch, co_ax_validity_info) <- tcTyFamInstEqn fam_tc mb_clsinfo - (L (na2la $ getLoc fam_lname) eqn) + (L (l2l $ getLoc fam_lname) eqn) -- (2) check for validity ; checkConsistentFamInst mb_clsinfo fam_tc co_ax_branch ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -943,7 +943,7 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) mk_mg :: LHsExpr GhcRn -> MatchGroup GhcRn (LHsExpr GhcRn) mk_mg body = mkMatchGroup (Generated SkipPmc) (noLocA [builder_match]) where - builder_args = [L (na2la loc) (VarPat noExtField (L loc n)) + builder_args = [L (l2l loc) (VarPat noExtField (L loc n)) | L loc n <- args] builder_match = mkMatch (mkPrefixFunRhs ps_lname) builder_args body ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b75ff8a88bbdd0d60032a4e304d37ec65526c06b +Subproject commit 2cbf7f0a55898e0c2827ae9ad13727b34877e793 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64ccd790e0c9d66ed29acfaca20f20c447f35c45 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64ccd790e0c9d66ed29acfaca20f20c447f35c45 You're receiving 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 Nov 5 21:02:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 16:02:56 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Add a test for I/O managers Message-ID: <65480300a494_27efe98c72acf464406e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 7b29c39c by Tobias Haslop at 2023-11-05T16:02:28-05:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - 9b546964 by Tobias Haslop at 2023-11-05T16:02:31-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 25 changed files: - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/ThToHs.hs - hadrian/src/Settings/Builders/RunTest.hs - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/parser/should_compile/T23315/T23315.stderr - testsuite/tests/regalloc/all.T - + testsuite/tests/rts/IOManager.hsc - + testsuite/tests/rts/IOManager.stdout - testsuite/tests/rts/Makefile - testsuite/tests/rts/T5644/all.T - testsuite/tests/rts/all.T - testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr - testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout - testsuite/tests/simplCore/prog003/test.T - testsuite/tests/simplCore/should_run/all.T - + testsuite/tests/typecheck/should_compile/T24146.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -883,7 +883,7 @@ lower_CmmReg lbl (CmmGlobal (GlobalRegUse greg reg_use_ty)) = do pure $ SomeWasmExpr ty_word $ WasmExpr $ - WasmSymConst "stg_EAGER_BLACKHOLE_info" + WasmSymConst "__stg_EAGER_BLACKHOLE_info" GCEnter1 -> do onFuncSym "__stg_gc_enter_1" [] [ty_word_cmm] pure $ SomeWasmExpr ty_word $ WasmExpr $ WasmSymConst "__stg_gc_enter_1" ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -278,7 +278,6 @@ pmcRecSel _ _ = return () {- Note [pmcPatBind doesn't warn on pattern guards] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @pmcPatBind@'s main purpose is to check vanilla pattern bindings, like ->>>>>>> 8760510af3 (This MR is an implementation of the proposal #516.) @x :: Int; Just x = e@, which is in a @PatBindRhs@ context. But its caller is also called for individual pattern guards in a @StmtCtxt at . For example, both pattern guards in @f x y | True <- x, False <- y = ...@ will ===================================== compiler/GHC/Parser.y ===================================== @@ -1019,13 +1019,13 @@ exportlist1 :: { OrdList (LIE GhcPs) } export :: { OrdList (LIE GhcPs) } : maybe_warning_pragma qcname_ext export_subspec {% do { let { span = (maybe comb2 comb3 $1) $2 $> } ; impExp <- mkModuleImpExp $1 (fst $ unLoc $3) $2 (snd $ unLoc $3) - ; return $ unitOL $ reLocA $ sL span $ impExp } } + ; return $ unitOL $ reLoc $ sL span $ impExp } } | maybe_warning_pragma 'module' modid {% do { let { span = (maybe comb2 comb3 $1) $2 $> ; anchor = (maybe glR (\loc -> spanAsAnchor . comb2 loc) $1) $2 } ; locImpExp <- acs (\cs -> sL span (IEModuleContents ($1, EpAnn anchor [mj AnnModule $2] cs) $3)) - ; return $ unitOL $ reLocA $ locImpExp } } + ; return $ unitOL $ reLoc $ locImpExp } } | maybe_warning_pragma 'pattern' qcon { let span = (maybe comb2 comb3 $1) $2 $> - in unitOL $ reLocA $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } + in unitOL $ reLoc $ sL span $ IEVar $1 (sLLa $2 $> (IEPattern (glAA $2) $3)) } export_subspec :: { Located ([AddEpAnn],ImpExpSubSpec) } : {- empty -} { sL0 ([],ImpExpAbs) } @@ -1117,7 +1117,7 @@ importdecl :: { LImportDecl GhcPs } , importDeclAnnAs = fst $8 } ; let loc = (comb5 $1 $6 $7 (snd $8) $9); - ; fmap reLocA $ acs (\cs -> L loc $ + ; fmap reLoc $ acs (\cs -> L loc $ ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False , ideclName = $6, ideclPkgQual = snd $5 , ideclSource = snd $2, ideclSafe = snd $3 @@ -1192,9 +1192,9 @@ importlist1 :: { OrdList (LIE GhcPs) } | import { $1 } import :: { OrdList (LIE GhcPs) } - : qcname_ext export_subspec {% fmap (unitOL . reLocA . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } - | 'module' modid {% fmap (unitOL . reLocA) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } - | 'pattern' qcon { unitOL $ reLocA $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } + : qcname_ext export_subspec {% fmap (unitOL . reLoc . (sLL $1 $>)) $ mkModuleImpExp Nothing (fst $ unLoc $2) $1 (snd $ unLoc $2) } + | 'module' modid {% fmap (unitOL . reLoc) $ acs (\cs -> sLL $1 $> (IEModuleContents (Nothing, EpAnn (glEE $1 $>) [mj AnnModule $1] cs) $2)) } + | 'pattern' qcon { unitOL $ reLoc $ sLL $1 $> $ IEVar Nothing (sLLa $1 $> (IEPattern (glAA $1) $2)) } ----------------------------------------------------------------------------- -- Fixity Declarations @@ -2174,7 +2174,7 @@ ctype :: { LHsType GhcPs } , hst_xqual = NoExtField , hst_body = $3 })) } - | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLocA $1) $3)) } + | ipvar '::' ctype {% acsA (\cs -> sLL $1 $> (HsIParamTy (EpAnn (glEE $1 $>) [mu AnnDcolon $2] cs) (reLoc $1) $3)) } | type { $1 } ---------------------- @@ -2736,7 +2736,7 @@ exp :: { ECP } -- Embed types into expressions and patterns for required type arguments | 'type' atype {% do { requireExplicitNamespaces (getLoc $1) - ; return $ ECP $ mkHsEmbTyPV (comb2 $1 (reLoc $>)) (hsTok $1) $2 } } + ; return $ ECP $ mkHsEmbTyPV (comb2 $1 $>) (hsTok $1) $2 } } infixexp :: { ECP } : exp10 { $1 } @@ -2998,7 +2998,7 @@ aexp2 :: { ECP } -- Template Haskell Extension | splice_untyped { ECP $ pvA $ mkHsSplicePV $1 } - | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLocA $1) } + | splice_typed { ecpFromExp $ fmap (uncurry HsTypedSplice) (reLoc $1) } | SIMPLEQUOTE qvar {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } | SIMPLEQUOTE qcon {% fmap ecpFromExp $ acsA (\cs -> sLL $1 $> $ HsUntypedBracket (EpAnn (glEE $1 $>) [mj AnnSimpleQuote $1] cs) (VarBr noExtField True $2)) } @@ -3036,8 +3036,8 @@ projection | PREFIX_PROJ field {% acs (\cs -> sLL $1 $> ((sLLa $1 $> $ DotFieldOcc (EpAnn (glEE $1 $>) (AnnFieldLabel (Just $ glAA $1)) cs) $2) :| [])) } splice_exp :: { LHsExpr GhcPs } - : splice_untyped { fmap (HsUntypedSplice noAnn) (reLocA $1) } - | splice_typed { fmap (uncurry HsTypedSplice) (reLocA $1) } + : splice_untyped { fmap (HsUntypedSplice noAnn) (reLoc $1) } + | splice_typed { fmap (uncurry HsTypedSplice) (reLoc $1) } splice_untyped :: { Located (HsUntypedSplice GhcPs) } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer @@ -3338,7 +3338,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) } ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) } : '->' exp { unECP $2 >>= \ $2 -> - acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) } + acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 $2) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) } | gdpats { $1 >>= \gdpats -> return $ sL1 gdpats (reverse (unLoc gdpats)) } @@ -3535,7 +3535,7 @@ dbinds :: { Located [LIPBind GhcPs] } -- reversed dbind :: { LIPBind GhcPs } dbind : ipvar '=' exp {% runPV (unECP $3) >>= \ $3 -> - acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLocA $1) $3)) } + acsA (\cs -> sLL $1 $> (IPBind (EpAnn (glEE $1 $>) [mj AnnEqual $2] cs) (reLoc $1) $3)) } ipvar :: { Located HsIPName } : IPDUPVARID { sL1 $1 (HsIPName (getIPDUPVARID $1)) } @@ -4361,7 +4361,7 @@ acsa a = do return (a cs) acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) -acsA a = reLocA <$> acs a +acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a @@ -4421,7 +4421,7 @@ mcs ll = mj AnnCloseS ll pvA :: MonadP m => m (Located a) -> m (LocatedAn t a) pvA a = do { av <- a - ; return (reLocA av) } + ; return (reLoc av) } pvN :: MonadP m => m (Located a) -> m (LocatedN a) pvN a = do { (L l av) <- a @@ -4475,7 +4475,7 @@ hsDoAnn (L l _) (L ll _) kw listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor listAsAnchor [] (L l _) = spanAsAnchor l -listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s) +listAsAnchor (h:_) s = spanAsAnchor (comb2 h s) listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor listAsAnchorM [] = Nothing ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. la2na, na2la, n2l, l2n, l2l, la2la, - reLoc, reLocA, reLocL, reLocC, reLocN, + reLoc, HasLoc(..), getHasLocList, srcSpan2e, la2e, realSrcSpan, @@ -78,6 +78,7 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. HasAnnotation(..), + locA, noLocA, getLocA, noSrcSpanA, @@ -579,7 +580,7 @@ emptyComments = EpaComments [] -- Important that the fields are strict as these live inside L nodes which -- are live for a long time. -data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan } +data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locAn :: !SrcSpan } deriving (Data, Eq) -- See Note [XRec and Anno in the AST] @@ -1016,27 +1017,23 @@ l2l l = SrcSpanAnn EpAnnNotUsed (locA l) na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) -reLoc :: LocatedAn a e -> Located e -reLoc (L (SrcSpanAnn _ l) a) = L l a +locA :: (HasLoc a) => a -> SrcSpan +locA = getHasLoc -reLocA :: Located e -> LocatedAn ann e -reLocA (L l a) = (L (SrcSpanAnn EpAnnNotUsed l) a) +reLoc :: (HasLoc (GenLocated a e), HasAnnotation b) + => GenLocated a e -> GenLocated b e +reLoc (L la a) = L (noAnnSrcSpan $ locA (L la a) ) a -reLocL :: LocatedN e -> LocatedA e -reLocL (L l a) = (L (na2la l) a) - -reLocC :: LocatedN e -> LocatedC e -reLocC (L l a) = (L (na2la l) a) - -reLocN :: LocatedN a -> Located a -reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e -instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where +instance HasAnnotation (SrcSpan) where + noAnnSrcSpan l = l + +instance HasAnnotation (SrcSpanAnn' (EpAnn ann)) where noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l noLocA :: (HasAnnotation e) => a -> GenLocated e a @@ -1060,11 +1057,14 @@ class HasLoc a where -- ^ conveniently calculate locations for things without locations attached getHasLoc :: a -> SrcSpan -instance HasLoc (Located a) where - getHasLoc (L l _) = l +instance (HasLoc l) => HasLoc (GenLocated l a) where + getHasLoc (L l _) = getHasLoc l + +instance HasLoc SrcSpan where + getHasLoc l = l -instance HasLoc (GenLocated (SrcSpanAnn' a) e) where - getHasLoc (L (SrcSpanAnn _ l) _) = l +instance HasLoc (SrcSpanAnn' a) where + getHasLoc (SrcSpanAnn _ l) = l instance (HasLoc a) => (HasLoc (Maybe a)) where getHasLoc (Just a) = getHasLoc a ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1727,7 +1727,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsOpAppPV l c1 op c2 = do let cmdArg c = L (l2l $ getLoc c) $ HsCmdTop noExtField c cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLocL op) Infix Nothing [cmdArg c1, cmdArg c2] + return $ L (noAnnSrcSpan l) $ HsCmdArrForm (EpAnn (spanAsAnchor l) (AnnList Nothing Nothing Nothing [] []) cs) (reLoc op) Infix Nothing [cmdArg c1, cmdArg c2] mkHsCasePV l c (L lm m) anns = do cs <- getCommentsFor l @@ -1807,7 +1807,7 @@ instance DisambECP (HsExpr GhcPs) where superInfixOp m = m mkHsOpAppPV l e1 op e2 = do cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLocL op) e2 + return $ L (noAnnSrcSpan l) $ OpApp (EpAnn (spanAsAnchor l) [] cs) e1 (reLoc op) e2 mkHsCasePV l e (L lm m) anns = do cs <- getCommentsFor l let mg = mkMatchGroup FromSource (L lm m) @@ -2092,7 +2092,7 @@ instance DisambTD DataConBuilder where = -- When the user writes data T = {-# UNPACK #-} Int :+ Bool -- we apply {-# UNPACK #-} to the LHS do lhs' <- addUnpackednessP unpk lhs - let l = combineLocsA (reLocA unpk) constr_stuff + let l = combineLocsA (reLoc unpk) constr_stuff return $ L l (InfixDataConBuilder lhs' data_con rhs) | otherwise = do addError $ mkPlainErrorMsgEnvelope (getLoc unpk) PsErrUnpackDataCon ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -1197,6 +1197,9 @@ if you do so. -- Getters and setters of GHC.Tc.Utils.Env fields -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +getUnifiedRef :: TcS (IORef Int) +getUnifiedRef = TcS (return . tcs_unified) + -- Getter of inerts and worklist getInertSetRef :: TcS (IORef InertSet) getInertSetRef = TcS (return . tcs_inerts) @@ -2040,21 +2043,28 @@ wrapUnifierX :: CtEvidence -> Role -> (UnifyEnv -> TcM a) -- Some calls to uType -> TcS (a, Bag Ct, [TcTyVar], RewriterSet) wrapUnifierX ev role do_unifications - = wrapTcS $ - do { defer_ref <- TcM.newTcRef emptyBag - ; unified_ref <- TcM.newTcRef [] - ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) - ; let env = UE { u_role = role - , u_rewriters = rewriters - , u_loc = ctEvLoc ev - , u_defer = defer_ref - , u_unified = Just unified_ref} - - ; res <- do_unifications env - - ; cts <- TcM.readTcRef defer_ref - ; unified <- TcM.readTcRef unified_ref - ; return (res, cts, unified, rewriters) } + = do { unif_count_ref <- getUnifiedRef + ; wrapTcS $ + do { defer_ref <- TcM.newTcRef emptyBag + ; unified_ref <- TcM.newTcRef [] + ; rewriters <- TcM.zonkRewriterSet (ctEvRewriters ev) + ; let env = UE { u_role = role + , u_rewriters = rewriters + , u_loc = ctEvLoc ev + , u_defer = defer_ref + , u_unified = Just unified_ref} + + ; res <- do_unifications env + + ; cts <- TcM.readTcRef defer_ref + ; unified <- TcM.readTcRef unified_ref + + -- Don't forget to update the count of variables + -- unified, lest we forget to iterate (#24146) + ; unless (null unified) $ + TcM.updTcRef unif_count_ref (+ (length unified)) + + ; return (res, cts, unified, rewriters) } } {- ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1016,7 +1016,7 @@ cvtImplicitParamBind :: String -> TH.Exp -> CvtM (LIPBind GhcPs) cvtImplicitParamBind n e = do n' <- wrapL (ipName n) e' <- cvtl e - returnLA (IPBind noAnn (reLocA n') e') + returnLA (IPBind noAnn (reLoc n') e') ------------------------------------------------------------------- -- Expressions @@ -1799,7 +1799,7 @@ cvtTypeKind typeOrKind ty ImplicitParamT n t -> do { n' <- wrapL $ ipName n ; t' <- cvtType t - ; returnLA (HsIParamTy noAnn (reLocA n') t') + ; returnLA (HsIParamTy noAnn (reLoc n') t') } _ -> failWith (MalformedType typeOrKind ty) ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -118,7 +118,7 @@ inTreeCompilerArgs stg = do os <- queryHostTarget queryOS arch <- queryTargetTarget queryArch - let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64"] + let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32"] let withNativeCodeGen | unregisterised = False | arch `elem` codegen_arches = True ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,12 +39,26 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,10 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -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('cmm_sink_sp', [ only_ways(['optasm']), + when(arch('wasm32'), fragile(24152)), + 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/parser/should_compile/T23315/T23315.stderr ===================================== @@ -108,5 +108,3 @@ " More docs")) [])) [])))))])) - - ===================================== testsuite/tests/regalloc/all.T ===================================== @@ -1,6 +1,8 @@ test('regalloc_unit_tests', [ when(unregisterised(), skip), extra_files(['no_spills.cmm']), when(not have_ncg(), skip), + # no regalloc business on wasm32 + when(arch('wasm32'), expect_fail), [ignore_stderr, only_ways(['normal'])], extra_run_opts('"' + config.libdir + '"') ], compile_and_run, ['-package ghc']) ===================================== testsuite/tests/rts/IOManager.hsc ===================================== @@ -0,0 +1,1089 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE NamedFieldPuns #-} + +module Main (main) where + +-- When building within the GHC testsuite, we do not have access to the +-- async package, so we use a bundled version. The cut down version is +-- included at the end of this file. +#define USE_ASYNC_BUNDLED 1 + +import qualified Data.Map as Map +import Control.Monad +import Control.Concurrent +#ifndef USE_ASYNC_BUNDLED +import Control.Concurrent.Async +#endif +import Control.Concurrent.STM +import Control.Exception +import GHC.IO.Exception (ioe_errno) +import System.Timeout + +import Foreign +import Foreign.C +import System.Posix.Types (Fd(Fd)) + +import Prelude hiding (read) + +#include +#include + +{- +The purpose of these tests is to try to get some decent test coverage of the +GHC I/O managers. Most of the time the I/O manager only has to deal with one +thread blocking on a file descriptor at once, but it's important to also cover +the more complex cases: + + * Multiple file descriptors + * Multiple threads blocking on reading/writing + * Multiple threads blocking on reading and writing on the same file descriptor + * Killing threads blocking on reading/writing, while there are still other + remaining threads. + +We start with some simple scenarios and work up towards the complex scenarios. + +To do this we use anonymous unix domain sockets, created using socketpair(). +We cannot use ordinary pipes because they are unidirectional, with a write-only +file descriptor for one end and a read-only file descriptor for the other end: +which makes it impossible to have threads waiting for reading and writing on +the same file descriptor. + +Unfortunately this makes these tests Unix-only for now, due to the use of +socketpair(). In principle it's possible on Win32 to create a bidirectional +non-blocking pipe by using the named pipe API with a unique name (since this is +what the Win32 CreatePipe() API does internally, but uses blocking mode). Thus +this test could in principle be extended to work on Windows. + +For blocking on reading we need socket buffers to be empty, while for blocking +on writing we need socket buffers to be full. The empty case is nice and simple +but the full case is surprisingly asymmetric. + +The most complex scenario looks like this: a sequence of sockets, with +Haskell threads copying bytes between them. Data is injected at one end by a +special sender thread and collected at the other end of the pipeline by a +special receiver thread. Each socket has two directions, in one direction we +arrange for the socket buffers to be usually empty, so threads are typically +blocked on reading, while in the other direction we arrange for the buffers to +be usually full so that threads are typically blocked on writing. Between each +pair of sockets we use one or more Haskell threads that just copy a byte from +source socket to destination socket. This simple copying behaviour works with +both full and empty buffers, the difference is just whether the copying threads +are usually blocked on the reading or writing side. We use different numbers of +threads to get coverage of the 1 and many cases. + + ╍╍╍╍╍╍╍╍▶ data flow direction ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ + ┇ + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┇ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ▼ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ in ┃ out ┃ ┃ in ┃ out ┃ ┃ in ┃ out ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ out ┃ in ┃ ┃ out ┃ in ┃ ┃ out ┃ in ◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┇ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┇ + ┇ + ◀╍╍╍╍╍╍╍╍╍ data flow direction ◀╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ + +The simpler scenarios are all subsets of this complex one. + +These scenarios make use of two protocols: the "empty buffer" protocol and the +"full buffer" protocol. See 'EmptyBufPtcl' and 'FullBufPtcl' below for details. +-} + +main :: IO () +main = do + putStrLn "I/O manager tests" + sequence_ + [ do putStrLn (show n ++ ". " ++ show scenario) + runScenario scenario + | (n, scenario) <- zip [1 :: Int ..] scenarios ] + +data Scenario = + Scenario { + mode :: Mode, + nsockets :: Int, + nthreads :: Int, + cancelio :: Bool, + size :: Int + } + deriving Show + +data Mode = EmptyBufs + | FullBufs + | EmptyFullBufs + deriving Show + +scenarios :: [Scenario] +scenarios = + [ Scenario { mode, nsockets, nthreads, cancelio = False, size } + | mode <- [EmptyBufs, FullBufs, EmptyFullBufs] + , (nsockets, nthreads, size) <- + [ (1,0,10) + , (1,0,100) + , (2,1,100) + , (2,3,100) + , (3,5,1000) + ] + ] + ++ [ Scenario { mode, nsockets, nthreads, cancelio = True, size } + | (mode, nsockets, nthreads, size) <- + [ (EmptyBufs, 2,3,100) + , (FullBufs, 2,3,100) + , (EmptyFullBufs, 2,3,100) + , (EmptyFullBufs, 3,5,1000) + , (EmptyFullBufs, 7,10,5000) + ] + ] + +runScenario :: Scenario -> IO () +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyBuffersSimple size + +runScenario Scenario { mode = EmptyBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyBuffers size nsockets nthreads + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets = 1, size } = + scenarioFullBuffersSimple size + +runScenario Scenario { mode = FullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets = 1, size } = + scenarioEmptyFullBuffersSimple size + +runScenario Scenario { mode = EmptyFullBufs, cancelio = False, + nsockets, nthreads, size } = + scenarioEmptyFullBuffers size nsockets nthreads + +runScenario Scenario { mode = EmptyBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioEmptyBuffersCancel size nthreads + +runScenario Scenario { mode = FullBufs, cancelio = True, + nsockets, nthreads, size } = + assert (nsockets == 2) $ + scenarioFullBuffersCancel size nthreads + +runScenario Scenario { mode = EmptyFullBufs, cancelio = True, + nsockets, nthreads, size } = + scenarioEmptyFullBuffersCancel size nsockets nthreads + +{- +Scenario: empty socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ + ┏━━▼━━┳━━┿━━┓ +empty buffer ┃ s1a ┃ s1b ┃ + ┣━━━━━╋━━━━━┫ +unused buffer ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersSimple :: Int -> IO () +scenarioEmptyBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (receiverEmpty sync s1b) + let expected = input + checkExpected id expected actual + + +{- +Scenario: empty socket buffers, n sockets, n-1 copy hops, m copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ + n sockets in total, n-1 hops +-} +scenarioEmptyBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverEmpty sync snb) + let expected = input + checkExpected id expected actual + + +{- +Scenario: full socket buffers, 1 socket, 0 copy hops + ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ + │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersSimple :: Int -> IO () +scenarioFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s1b input) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: full socket buffers, n sockets, n-1 copy hops x m copy threads + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ ┗━━━━━━━━━━━━━━━━┛ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffers :: Int -> Int -> Int -> IO () +scenarioFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + sync <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderFull sync snb input) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty and full socket buffers, 1 socket, 0 copy hops + ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ + │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b◀──╂ ┃ + ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersSimple :: Int -> IO () +scenarioEmptyFullBuffersSimple sz = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPair $ \s1a s1b -> do + traceIO $ "s1a = " ++ show s1a ++ ", s1b = " ++ show s1b + zeroFillFdBuffer s1b + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull s1b s1b) + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (dropWhile (==0)) expected actual + +{- +Scenario: empty & full socket buffers, 3 sockets, 2x2 copy hops x 5 copy threads + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┏━━━━━━━━━━━━━━━━┓ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffers :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffers sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently (copyBetweenFdsN ReadFirst m sib si'a) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently (copyBetweenFdsN WriteFirst m si'a sib) + | ((_sia, sib), (si'a, _si'b)) <- zip sockets (tail sockets) ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┏━━━━━━━━━━━━━━━━┓ + ┃ send thread ┃ ┃ block on read ┃ ┃ receive thread ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━━━┛ + │ │ │ │ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ +empty buffers ┃ s1a ┃ s1b ┃ ┃ s2a ┃ s2b ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ + ┃ ┃ ┃ ┃ ┃ ┃ + ┗━━━━━┻━━━━━┛ ┗━━━━━┻━━━━━┛ +-} +scenarioEmptyBuffersCancel :: Int -> Int -> IO () +scenarioEmptyBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + sync <- newEmptyBufPtcl + runConcurrently $ + Concurrently (senderEmpty sync s1a input) + *> Concurrently (copyBetweenFdsNChaosMonkey ReadFirst m schedule s1b s2a) + *> Concurrently (receiverEmpty sync s2b) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: full buffers, 2 sockets, 1 copy hop x m copy threads +with copy thread cancellation + ┏━━━━━┳━━━━━┓ ┏━━━━━┳━━━━━┓ +unused buffers ┃ ┃ ┃ ┃ ┃ ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ +full buffers ┃ s1a ┃ s1b ┃ ┃ s1a ┃ s1b ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ + │ │ │ │ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━━━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ send thread ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┗━━━━━━━━━━━━━━━━┛ + ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioFullBuffersCancel :: Int -> Int -> IO () +scenarioFullBuffersCancel sz m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedule = chaosMonkeySchedule 0 + actual <- + withLocalSocketPair $ \s1a s1b -> + withLocalSocketPair $ \s2a s2b -> do + mapM_ zeroFillFdBuffer [s1b, s2b] + sync <- newFullBufPtcl 1 + runConcurrently $ + Concurrently (senderFull sync s2b input) + *> Concurrently (copyBetweenFdsNChaosMonkey WriteFirst m schedule s2a s1b) + *> Concurrently (receiverFull sync s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +{- +Scenario: empty & full buffers, n sockets, 2(n-1) copy hops x m copy threads +with copy thread cancellation + ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ + ┃ m copy threads ┃ ┃ m copy threads ┃ + ┏━━━━━━━━━━━━━━━━┓ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ send thread ┃ ┃ block on read ┃ ┃ block on read ┃ + ┗━━━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ ┗━▲━━━━━━━━━━━━┿━┛ + │ │ │ │ │ ┏━━━━━━━━━┓ + ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━┿━━┓ ┏━━▼━━┳━━━━━┓ ┃ ┃ +empty buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb ╂──▶reflect ┃ + ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┣━━━━━╋━━━━━┫ ┃ thread ┃ +full buffers ┃ s1a ┃ s1b ┃ ┃ sia ┃ sib ┃ ┃ sna ┃ snb◀──╂ ┃ + ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━▲━━┛ ┗━━┿━━┻━━━━━┛ ┃ ┃ + │ │ │ │ │ ┗━━━━━━━━━┛ + ┏━━━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ ┏━┿━━━━━━━━━━━━▼━┓ + ┃ receive thread ┃ ┃ m copy threads ┃ ┃ m copy threads ┃ + ┗━━━━━━━━━━━━━━━━┛ ┃ cancellation ┃ ┃ cancellation ┃ + ┃ block on write ┃ ┃ block on write ┃ + ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ +-} +scenarioEmptyFullBuffersCancel :: Int -> Int -> Int -> IO () +scenarioEmptyFullBuffersCancel sz n m = do + let input = map (fromIntegral :: Int -> Word8) [1..sz] + schedules1 = map chaosMonkeySchedule [1..] + schedules2 = map chaosMonkeySchedule [2..] + actual <- + withLocalSocketPairs n $ \sockets-> do + let (s1a, _) = head sockets + (_, snb) = last sockets + sequence_ [ zeroFillFdBuffer sib | (_sia, sib) <- sockets ] + syncEmpty <- newEmptyBufPtcl + syncFull <- newFullBufPtcl n + runConcurrently $ + Concurrently (senderEmpty syncEmpty s1a input) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey ReadFirst m schedule sib si'a + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules1 + ] + *> Concurrently (reflectorEmptyToFull syncEmpty syncFull snb snb) + *> sequenceA + [ Concurrently $ + copyBetweenFdsNChaosMonkey WriteFirst m schedule si'a sib + | ((_sia, sib), (si'a, _si'b), schedule) + <- zip3 sockets (tail sockets) schedules2 + ] + *> Concurrently (receiverFull syncFull s1a) + let expected = input + checkExpected (Map.delete 0 . listToBag) expected actual + + +checkExpected :: (Eq a, Show a) => ([Word8] -> a) -> [Word8] -> [Word8] -> IO () +checkExpected normalise expected actual + | expected_normalised == actual_normalised = return () + | otherwise = do + putStrLn "---------" + putStrLn $ "expected output differs:" + putStrLn $ "expected: " ++ show expected_normalised + putStrLn $ "actual: " ++ show actual_normalised + putStrLn "---------" + where + expected_normalised = normalise expected + actual_normalised = normalise actual + +listToBag :: Ord a => [a] -> Map.Map a Int +listToBag = Map.fromListWith (+) . map (\k -> (k,1)) + + +-- | The \"empty buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /reading/, i.e. the socket buffers are usually empty. +-- +-- We do this by synchronising between the sending and receiving ends so that +-- we only send one byte at a time, and the sender waits for the receiver to +-- get it. +-- +-- To do this we use a simple TVar Bool shared between the sender and receiver. +-- The sender sends a byte and then waits for the tvar to be set to true by +-- the receiver, at which point it resets the tvar to false and continues. +-- +-- This is usually used in a loop. +-- +newtype EmptyBufPtcl = EmptyBufPtcl (TVar Bool) + +newEmptyBufPtcl :: IO EmptyBufPtcl +newEmptyBufPtcl = EmptyBufPtcl <$> newTVarIO False + +sendEmptyBufPtcl :: EmptyBufPtcl -> Fd -> Word8 -> IO () +sendEmptyBufPtcl (EmptyBufPtcl sync) fd x = do + writeByteBlocking fd x + atomically $ do + continue <- readTVar sync + check continue + writeTVar sync False + +recvEmptyBufPtcl :: EmptyBufPtcl -> Fd -> IO (Maybe Word8) +recvEmptyBufPtcl (EmptyBufPtcl sync) fd = do + res <- readByteBlocking fd + atomically $ writeTVar sync True + return res + +-- | The \"full buffer protocol\" is for sending a series of bytes over a +-- series of hops -- consisting of sockets and simple copying threads -- in +-- such a way that the copying threads are usually blocking waiting on +-- /writing/, i.e. the socket buffers are usually full. +-- +-- Sending through a full socket buffer is surprisingly tricky in practice +-- however. Suppose we have a thread blocked on writing into a socket (because +-- the socket) buffer is full. One might expect that if another thread reads +-- some data from the socket that this would unblock the writing thread. On +-- Linux at least, this is not necessarily the case. One may have to remove +-- much more data before the writer is unblocked. +-- +-- (It probably behaves this way because the Linux kernel implementation of +-- local socket tracks packets written, and each packet has some overhead. So +-- there has to be enough space to fit a whole packet.) +-- +-- So what we do is this: +-- +-- Write side: +-- * try to write a byte +-- * if it succeeds, repeat +-- * else it returns EAGAIN +-- * sync to release reader +-- * block on readiness for writing +-- * sync to stop reader +-- * repeat +-- +-- Read side: +-- * sync wait to be released +-- * read a byte (not expected to block) +-- * wait for either sync to stop or timeout +-- * either way, repeat +-- +-- The point is this: the writer will block on writing but while it is blocked it +-- will allow the read side to read a byte and then wait a bit. This might be +-- enough to free up space and allow the writer to complete (in which case the +-- reader will not read more bytes) but if it's not enough then the reader will +-- eventually stop waiting and read again. Eventually it must be enough to free -- up space. +-- +-- This protocol /should/ work across many hops, where the intermediate hops +-- just do simple blocking read\/write of bytes. So this should just be needed +-- at the far ends of the hops. +-- +data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait milliseconds + +newFullBufPtcl :: Int -> IO FullBufPtcl +newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitms + where + waitms = nhops * 100 --100ms per hop + +sendFullBufPtcl :: FullBufPtcl -> Fd -> Word8 -> IO () +sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do + res <- writeByteNonBlocking fd x + case res of + Just () -> + traceIO ("sendFullBufPtcl: wrote byte '" ++ show x + ++ "' on fd " ++ show fd) + Nothing -> do + atomically $ writeTVar sync True + traceIO ("sendFullBufPtcl: waiting to write byte '" ++ show x + ++ "' on fd " ++ show fd) + threadWaitWrite fd + atomically $ writeTVar sync False + -- go round again + sendFullBufPtcl ptcl fd x + +finishSendFullBufPtcl :: FullBufPtcl -> IO () +finishSendFullBufPtcl (FullBufPtcl sync _waitms) = + atomically $ writeTVar sync True -- release reader to finish + +recvFullBufPtcl :: FullBufPtcl -> Fd -> IO (Maybe Word8) +recvFullBufPtcl (FullBufPtcl sync waitms) fd = do + atomically $ readTVar sync >>= check + res <- readByteNonBlocking fd + case res of + Nothing -> fail "recvFullBufPtcl: unexpected blocking" + Just Nothing -> return Nothing + Just (Just x) -> do + traceIO ("recvFullBufPtcl: read byte '" ++ show x + ++ "' on fd " ++ show fd ++ ", now waiting") + _ <- timeout waitms $ atomically $ readTVar sync >>= check . not + return (Just x) + + +senderEmpty :: EmptyBufPtcl -> Fd -> [Word8] -> IO () +senderEmpty ptcl fd xs = do + mapM_ (sendEmptyBufPtcl ptcl fd) xs + shutdown fd SHUT_WR + +receiverEmpty :: EmptyBufPtcl -> Fd -> IO [Word8] +receiverEmpty ptcl fd = + untilM (recvEmptyBufPtcl ptcl fd) + + +senderFull :: FullBufPtcl -> Fd -> [Word8] -> IO () +senderFull ptcl fd xs = do + mapM_ (sendFullBufPtcl ptcl fd) xs + finishSendFullBufPtcl ptcl + shutdown fd SHUT_WR + +receiverFull :: FullBufPtcl -> Fd -> IO [Word8] +receiverFull ptcl fd = + untilM (recvFullBufPtcl ptcl fd) + + +untilM :: Monad m => m (Maybe x) -> m [x] +untilM action = + go [] + where + go xs = do + mx <- action + case mx of + Nothing -> return (reverse xs) + Just x -> go (x:xs) + + +reflectorEmptyToFull :: EmptyBufPtcl -> FullBufPtcl -> Fd -> Fd -> IO () +reflectorEmptyToFull ptclEmpty ptclFull fdFrom fdTo = do + copyloop + finishSendFullBufPtcl ptclFull + shutdown fdTo SHUT_WR + where + copyloop = do + mx <- recvEmptyBufPtcl ptclEmpty fdFrom + case mx of + Nothing -> return () + Just x -> do sendFullBufPtcl ptclFull fdTo x + copyloop + + +data ReadOrWriteFirst = ReadFirst | WriteFirst + deriving (Eq) + +-- | Use N threads concurrently to copy bytes. Each thread copies bytes, +-- one-by-one, from one Fd to another, either starting with a +-- read or a write (of 0). +-- +-- Returns the bytes copied, one sublist per thread. Note that the split +-- between threads will be non-deterministic. +-- +-- Once all bytes are copied (indicated by EOF on the source), the destination +-- Fd is shutdown for writing. This allows the other end of the destination Fd +-- will be receive an EOF. The destination Fd is only shutdown once all +-- threads are complete. +-- +copyBetweenFdsN :: ReadOrWriteFirst -> Int -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsN rw n fdFrom fdTo = do + result <- + runConcurrently $ + sequenceA + [ Concurrently (copyBetweenFds rw fdFrom fdTo) + | _i <- [0..n-1] ] + shutdown fdTo SHUT_WR + return result + + +copyBetweenFds :: ReadOrWriteFirst -> Fd -> Fd -> IO [Word8] +copyBetweenFds rw fdFrom fdTo = + case rw of + ReadFirst -> goRead [] + WriteFirst -> goWrite [] 0 + where + goRead acc = do + res <- readByteBlocking fdFrom + case res of + Nothing -> return (reverse acc) + Just byte -> goWrite acc byte + + goWrite acc byte = do + writeByteBlocking fdTo byte + goRead (byte:acc) + +-- | It turns out that chaos monkeys are more predictable than you might think. +-- +-- Each schedule entry (i,j) says: on transferring byte i, interrupt thread j. +-- +type ChaosMonkeySchedule = [(Int, Int)] + +chaosMonkeySchedule :: Int -> ChaosMonkeySchedule +chaosMonkeySchedule seed = + go (Prng seed) 0 + where + go prng i = + let (prng', a) = random prng + (prng'', j) = random prng' + i' = i + 1 + a `mod` 3 -- so 1,2,3 + in (i', j) : go prng'' i' + + +newtype Prng = Prng Int deriving Show + +random :: Prng -> (Prng, Int) +random (Prng n) = + let !n' = n * 1103515245 + 12345 + !x = (n' `div` 65536) `mod` 32768 + in (Prng n', x) + +-- | Like copyBetweenFdsN but with scheduled interruption of blocking I\/O +-- operations by asynchronous exceptions to cancel the I\/O. +-- +-- Each copying thread will catch the async exception and repeat. The sending +-- of the async exceptions is done based on a pre-defined schedule, based on +-- the n'th byte read by each thread. +-- +copyBetweenFdsNChaosMonkey :: ReadOrWriteFirst -> Int + -> ChaosMonkeySchedule + -> Fd -> Fd -> IO [[Word8]] +copyBetweenFdsNChaosMonkey rw n schedule fdFrom fdTo = + mask_ $ do + sync <- newTVarIO False + bracket (replicateM n (async (copyBetweenFds' sync))) + (mapM_ cancel) $ \copyThreads -> + withAsync (chaosMonkey sync copyThreads schedule) $ \monkeyThread -> do + _ <- waitAny copyThreads + results <- mapM wait copyThreads + cancel monkeyThread + shutdown fdTo SHUT_WR + return results + where + chaosMonkey :: TVar Bool -> [Async a] -> ChaosMonkeySchedule -> IO () + chaosMonkey sync threads = go 0 + where + go _ [] = return () + go !b sched@((i,_j):_) | b < i = do + awaitPulse sync + go (b+1) sched + go !b ((i,j):sched') | b == i = do + let tn = j `mod` n + tid = asyncThreadId (threads !! tn) + traceIO $ "interrupting thread number " ++ show tn ++ ", " ++ show tid + throwTo tid Interrupted + go b sched' + go !b ((_i,_j):sched') | otherwise = + go b sched' + + awaitPulse sync = atomically $ do + check =<< readTVar sync + writeTVar sync False + pulse sync = atomically $ writeTVar sync True + + copyBetweenFds' sync = + case rw of + ReadFirst -> goRead sync [] + WriteFirst -> goWrite sync [] 0 + + goRead sync acc = do + res <- try $ readByteBlocking fdFrom + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "read interrupted on " ++ show tid + goRead sync acc + Right Nothing -> return (reverse acc) + Right (Just byte) -> do + when (rw == WriteFirst) (pulse sync) + goWrite sync acc byte + + goWrite sync acc byte = do + res <- try $ writeByteBlocking fdTo byte + case res of + Left Interrupted -> do + tid <- myThreadId + traceIO $ "write interrupted on " ++ show tid + goWrite sync acc byte + Right () -> do + when (rw == ReadFirst) (pulse sync) + goRead sync (byte:acc) + +data Interrupted = Interrupted deriving Show +instance Exception Interrupted + +readByteBlocking :: Fd -> IO (Maybe Word8) +readByteBlocking fd = + allocaBytes 1 $ \bufptr -> + readLoop bufptr + where + readLoop bufptr = do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitRead fd + readLoop bufptr + | otherwise -> throwIO err + Right 1 -> Just <$> peek bufptr + Right 0 -> return Nothing + Right _ -> fail "impossible" + +readByteNonBlocking :: Fd -> IO (Maybe (Maybe Word8)) +readByteNonBlocking fd = + allocaBytes 1 $ \bufptr -> do + res <- try $ read fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> Just . Just <$> peek bufptr + Right 0 -> return (Just Nothing) + Right _ -> fail "impossible" + +writeByteBlocking :: Fd -> Word8 -> IO () +writeByteBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + writeLoop bufptr + where + writeLoop bufptr = do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> do threadWaitWrite fd + writeLoop bufptr + | otherwise -> throwIO err + Right 1 -> return () + Right _ -> fail "impossible" + +writeByteNonBlocking :: Fd -> Word8 -> IO (Maybe ()) +writeByteNonBlocking fd byte = + allocaBytes 1 $ \bufptr -> do + poke bufptr byte + res <- try $ write fd bufptr 1 + case res of + Left err | fmap Errno (ioe_errno err) == Just eWOULDBLOCK + -> return Nothing + | otherwise -> throwIO err + Right 1 -> return (Just ()) + Right _ -> fail "impossible" + +read :: Fd -> Ptr Word8 -> CSize -> IO CLong +read fd buf count = + throwErrnoIfMinus1 "read" $ do + r <- c_read fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("read " ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + +write :: Fd -> Ptr Word8 -> CSize -> IO CLong +write fd buf count = + throwErrnoIfMinus1 "write" $ do + r <- c_write fd buf count +{- + errno <- getErrno + let rstr | r == -1 && errno == eWOULDBLOCK = "EWOULDBLOCK" + | otherwise = show r + traceIO ("write" ++ show (fd, count) ++ " = " ++ rstr) +-} + return r + + +-- Ensure the fd's write buffer is full of zeros. +-- +-- The Fd must be in non-blocking mode. +-- +-- Uses 1 byte writes, which on Linux at least, fills up the buffer quickly. +-- Presumably this is due to the overhead of tracking as packets. +-- +zeroFillFdBuffer :: Fd -> IO () +zeroFillFdBuffer fd = + allocaBytes 1 $ \bufptr -> poke bufptr 0 >> go bufptr 0 + where + go :: Ptr Word8 -> Int -> IO () + go !bufptr !count = do + res <- c_write fd bufptr 1 + errno <- getErrno + case () of + _ | res == 1 -> + go bufptr (count + 1) + + | res < 0 && (errno == eAGAIN || errno == eWOULDBLOCK) -> + return () + + _ -> throwErrno "zeroFillFdBuffer" + + +-- We have to use a local socket rather than a pipe, because we need a +-- bi-directional pipe, and Posix (specially Linux) pipes are unidirectional. +-- It needs to be bidirectional so that we have multiple threads ending up +-- blocked reading and writing on the same socket, to test the IO manager +-- handles this case correctly. +-- +-- Also set the buffer size to be as small as possible (1 page). +-- +localSocketPair :: IO (Fd, Fd) +localSocketPair = + allocaArray 2 $ \sv -> do + let sockdomain = #{const AF_LOCAL} + socktype = #{const SOCK_STREAM} + sockproto = 0 + throwErrnoIfMinus1_ "socketpair" $ + c_socketpair sockdomain socktype sockproto sv + [a,b] <- peekArray 2 sv + forM_ [Fd a, Fd b] $ \fd@(Fd fdcint) -> do + c_fcntl_write fdcint #{const F_SETFL} #{const O_NONBLOCK} + let bufsize = 1024 + setsockopt fd #{const SOL_SOCKET} #{const SO_SNDBUF} bufsize + setsockopt fd #{const SOL_SOCKET} #{const SO_RCVBUF} bufsize + return (Fd a, Fd b) + +withLocalSocketPair :: (Fd -> Fd -> IO a) -> IO a +withLocalSocketPair action = + bracket + localSocketPair + (\(a, b) -> close a >> close b) + (uncurry action) + +withLocalSocketPairs :: Int -> ([(Fd, Fd)] -> IO a) -> IO a +withLocalSocketPairs n = + bracket + (replicateM n localSocketPair) + (mapM_ (\(a, b) -> close a >> close b)) + +setsockopt :: Fd -> CInt -> CInt -> CInt -> IO () +setsockopt fd level option value = + with value $ \p -> + throwErrnoIfMinus1_ "setsockopt" $ + c_setsockopt fd level option p (fromIntegral (sizeOf value)) + +close :: Fd -> IO () +close fd = + throwErrnoIfMinus1_ "close" $ + c_close fd + +data ShutdownDir = SHUT_RD | SHUT_WR | SHUT_RDWR + +shutdown :: Fd -> ShutdownDir -> IO () +shutdown fd dir = + throwErrnoIfMinus1_ "shutdown" $ + c_shutdown fd how + where + how :: CInt + how = case dir of + SHUT_RD -> #{const SHUT_RD} + SHUT_WR -> #{const SHUT_WR} + SHUT_RDWR -> #{const SHUT_RDWR} + +-- int socketpair(int domain, int type, int protocol, int sv[2]); +foreign import ccall "sys/socket.h socketpair" + c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt + +foreign import ccall "sys/socket.h setsockopt" + c_setsockopt :: Fd -> CInt -> CInt -> Ptr CInt -> CInt -> IO CInt + +foreign import capi unsafe "HsBase.h fcntl" + c_fcntl_write :: CInt -> CInt -> CLong -> IO CInt + +foreign import ccall unsafe "unistd.h write" + c_write :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h read" + c_read :: Fd -> Ptr Word8 -> CSize -> IO CLong + +foreign import ccall unsafe "unistd.h close" + c_close :: Fd -> IO CInt + +foreign import ccall unsafe "sys/socket.h shutdown" + c_shutdown :: Fd -> CInt -> IO CInt + +traceIO :: String -> IO () +traceIO _ = return () +--traceIO = BSC.putStrLn . BSC.pack + + +#ifdef USE_ASYNC_BUNDLED + +------------------------------------------------------------------------------- +-- Mini async library +-- + +data Async a = Async + { asyncThreadId :: !ThreadId + , _asyncWait :: STM (Either SomeException a) + } + +async :: IO a -> IO (Async a) +async = \action -> do + var <- newEmptyTMVarIO + t <- forkFinally action (\r -> atomically $ putTMVar var r) + return (Async t (readTMVar var)) + +withAsync :: IO a -> (Async a -> IO b) -> IO b +withAsync action inner = + mask $ \restore -> do + a <- async (restore action) + restore (inner a) `finally` uninterruptibleCancel a + +cancel :: Async a -> IO () +cancel a@(Async t _) = throwTo t AsyncCancelled <* waitCatch a + +uninterruptibleCancel :: Async a -> IO () +uninterruptibleCancel = uninterruptibleMask_ . cancel + +data AsyncCancelled = AsyncCancelled + deriving Show + +instance Exception AsyncCancelled where + fromException = asyncExceptionFromException + toException = asyncExceptionToException + +wait :: Async a -> IO a +wait = atomically . waitSTM + +waitSTM :: Async a -> STM a +waitSTM a = do + r <- waitCatchSTM a + either throwSTM return r + +waitCatch :: Async a -> IO (Either SomeException a) +waitCatch = atomically . waitCatchSTM + +waitCatchSTM :: Async a -> STM (Either SomeException a) +waitCatchSTM (Async _ w) = w + +waitBoth :: Async a -> Async b -> IO (a,b) +waitBoth left right = atomically (waitBothSTM left right) + +waitBothSTM :: Async a -> Async b -> STM (a,b) +waitBothSTM left right = do + a <- waitSTM left `orElse` (waitSTM right >> retry) + b <- waitSTM right + return (a,b) + +waitAny :: [Async a] -> IO (Async a, a) +waitAny = atomically . waitAnySTM + +waitAnySTM :: [Async a] -> STM (Async a, a) +waitAnySTM = foldr orElse retry . map (\a -> waitSTM a >>= \r -> return (a, r)) + +newtype Concurrently a = Concurrently { runConcurrently :: IO a } + +instance Functor Concurrently where + fmap f (Concurrently a) = Concurrently $ f <$> a + +instance Applicative Concurrently where + pure = Concurrently . return + Concurrently fs <*> Concurrently as = + Concurrently $ (\(f, a) -> f a) <$> concurrently fs as + +concurrently :: IO a -> IO b -> IO (a,b) +concurrently left right = + withAsync left $ \a -> + withAsync right $ \b -> + waitBoth a b + +#endif + ===================================== testsuite/tests/rts/IOManager.stdout ===================================== @@ -0,0 +1,21 @@ +I/O manager tests +1. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +2. Scenario {mode = EmptyBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +3. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +4. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +5. Scenario {mode = EmptyBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +6. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +7. Scenario {mode = FullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +8. Scenario {mode = FullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +9. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +10. Scenario {mode = FullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +11. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 10} +12. Scenario {mode = EmptyFullBufs, nsockets = 1, nthreads = 0, cancelio = False, size = 100} +13. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 1, cancelio = False, size = 100} +14. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = False, size = 100} +15. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = False, size = 1000} +16. Scenario {mode = EmptyBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +17. Scenario {mode = FullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +18. Scenario {mode = EmptyFullBufs, nsockets = 2, nthreads = 3, cancelio = True, size = 100} +19. Scenario {mode = EmptyFullBufs, nsockets = 3, nthreads = 5, cancelio = True, size = 1000} +20. Scenario {mode = EmptyFullBufs, nsockets = 7, nthreads = 10, cancelio = True, size = 5000} ===================================== testsuite/tests/rts/Makefile ===================================== @@ -157,3 +157,8 @@ T23142: grep -m1 -c "CATCH_STM_FRAME" T23142.log grep -m1 -c "MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log grep -m1 -c "SMALL_MUT_ARR_PTRS_FROZEN_DIRTY" T23142.log + +HSC2HS_OPTS = --cc="$(TEST_CC)" $(addprefix --cflag=,$(TEST_CC_OPTS)) --ld=$(TEST_CC) $(addprefix --lflag=,$(TEST_CC_OPTS)) + +IOManager.hs: IOManager.hsc + '$(HSC2HS)' $(HSC2HS_OPTS) $< ===================================== testsuite/tests/rts/T5644/all.T ===================================== @@ -1,8 +1,9 @@ test('T5644', [extra_files(['Conf.hs', 'ManyQueue.hs', 'Util.hs', 'heap-overflow.hs']), - + only_ways(['optasm','threaded1','threaded2']), extra_run_opts('+RTS -M20m -RTS'), - exit_code(251) # RTS exit code for "out of memory" + exit_code(251), # RTS exit code for "out of memory" + when(arch('wasm32'), [ignore_stderr, exit_code(1)]) ], multimod_compile_and_run, ['heap-overflow.hs','-O']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -44,6 +44,8 @@ test('derefnull', when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), when(arch('javascript'), [ignore_stderr, exit_code(1)]), + # On wasm32, 0x0 is a valid linear memory address + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(0)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the @@ -82,6 +84,8 @@ test('divbyzero', when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), + # wasmtime returns sigabrt error code upon wasm traps + when(arch('wasm32'), [ignore_stdout, ignore_stderr, exit_code(134)]), # since these test are supposed to crash the # profile report will be empty always. # so disable the check for profiling @@ -604,3 +608,7 @@ test('T23221', test('T23142', [unless(debug_rts(), skip), req_interp], makefile_test, ['T23142']) test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) + +test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), + pre_cmd('$MAKE -s --no-print-directory IOManager.hs')], + compile_and_run, ['']) ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr → testsuite/tests/simplCore/prog003/simplCore-oneShot.stderr ===================================== ===================================== testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout → testsuite/tests/simplCore/prog003/simplCore-oneShot.stdout ===================================== ===================================== testsuite/tests/simplCore/prog003/test.T ===================================== @@ -1,3 +1,3 @@ -test('simplCore.oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), +test('simplCore-oneShot', [extra_files(['OneShot1.hs', 'OneShot2.hs']), only_ways(['optasm'])], multimod_compile_and_run, ['OneShot2', '-v0']) ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -19,7 +19,8 @@ test('simplrun007', normal, compile_and_run, ['']) test('simplrun008', normal, compile_and_run, ['']) test('simplrun009', normal, compile_and_run, ['']) test('simplrun010', [extra_run_opts('24 16 8 +RTS -M10m -RTS'), - exit_code(251)] + exit_code(251), + when(arch('wasm32'), [ignore_stderr, exit_code(1)])] , compile_and_run, ['']) test('simplrun011', normal, compile_and_run, ['-fno-worker-wrapper']) ===================================== testsuite/tests/typecheck/should_compile/T24146.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeFamilies #-} +module M where + +class (a ~ b) => Aggregate a b where +instance Aggregate a a where + +liftM :: (Aggregate ae am) => (forall r. am -> r) -> ae +liftM _ = undefined + +class Positive a + +mytake :: (Positive n) => n -> r +mytake = undefined + +x :: (Positive n) => n +x = liftM mytake ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -902,3 +902,4 @@ test('InstanceWarnings', normal, multimod_compile, ['InstanceWarnings', '']) test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) +test('T24146', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a735c06bb37a213a5a2dca0cfa909a77b673895...9b5469648293779febc9a05c8d6bb306a2b7d7ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a735c06bb37a213a5a2dca0cfa909a77b673895...9b5469648293779febc9a05c8d6bb306a2b7d7ba You're receiving 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 Nov 5 22:02:17 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 05 Nov 2023 17:02:17 -0500 Subject: [Git][ghc/ghc][wip/expand-do] Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. Message-ID: <654810e92d3d1_27efe98e1dbdc8649845@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: f206c989 by Apoorv Ingle at 2023-11-05T23:02:09+01:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 30 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - + compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Types/ErrCtxt.hs - compiler/GHC/Tc/Types/LclEnv.hs - compiler/GHC/Tc/Types/Origin.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f206c989ce003ff2c57fdc7fb437d83219a244dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f206c989ce003ff2c57fdc7fb437d83219a244dd You're receiving 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 Nov 6 01:03:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 20:03:06 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <65483b49e77f8_27efe9927ed8c06679c1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0aa3a4f1 by Tobias Haslop at 2023-11-05T20:02:56-05:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - 74c71b09 by Tobias Haslop at 2023-11-05T20:03:00-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 3 changed files: - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs Changes: ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,12 +39,26 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b5469648293779febc9a05c8d6bb306a2b7d7ba...74c71b09543cb9d91fe7a66dad0d94af423a0bbf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9b5469648293779febc9a05c8d6bb306a2b7d7ba...74c71b09543cb9d91fe7a66dad0d94af423a0bbf You're receiving 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 Nov 6 04:53:45 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 05 Nov 2023 23:53:45 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <65487159ec52a_27efe99821c5a8690946@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b7182c62 by Tobias Haslop at 2023-11-05T23:53:22-05:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - 2da2ef55 by Tobias Haslop at 2023-11-05T23:53:26-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 3 changed files: - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs Changes: ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,12 +39,26 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74c71b09543cb9d91fe7a66dad0d94af423a0bbf...2da2ef55a012ac7acb961338871c9196e4a48f18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74c71b09543cb9d91fe7a66dad0d94af423a0bbf...2da2ef55a012ac7acb961338871c9196e4a48f18 You're receiving 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 Nov 6 08:14:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 Nov 2023 03:14:17 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <6548a05984615_1761a410bf8c810463c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e3c8f19b by Tobias Haslop at 2023-11-06T03:14:09-05:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - 8df66b46 by Tobias Haslop at 2023-11-06T03:14:13-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 3 changed files: - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs Changes: ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,12 +39,26 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2da2ef55a012ac7acb961338871c9196e4a48f18...8df66b466ddf507c43c1b5e491a133194aed651a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2da2ef55a012ac7acb961338871c9196e4a48f18...8df66b466ddf507c43c1b5e491a133194aed651a You're receiving 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 Nov 6 10:14:49 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 06 Nov 2023 05:14:49 -0500 Subject: [Git][ghc/ghc][wip/expand-do] Apply 1 suggestion(s) to 1 file(s) Message-ID: <6548bc992a7a6_21cb8a10687441125e2@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 39b4c2c2 by Gergő Érdi at 2023-11-06T10:14:47+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/Tc/Gen/Do.hs Changes: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -326,12 +326,12 @@ The {l1} etc are location/source span information stored in the AST by the parse The 3 non-obvious points to consider are: 1. Wrap the expression with a `fail` block if the pattern match is not irrefutable. - See Part 1. Below + See Part 1. below 2. Generate appropriate warnings for discarded results in a body statement eg. say `do { .. ; (g p :: m Int) ; ... }` - See Part 2. Below + See Part 2. below 3. Generating appropriate type error messages which blame the correct source spans - See Part 3 Below + See Part 3. below Part 1. Expanding Patterns Bindings ----------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39b4c2c2d97f810e330e69c3cdefc36cafe81bee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39b4c2c2d97f810e330e69c3cdefc36cafe81bee You're receiving 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 Nov 6 11:12:39 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 06 Nov 2023 06:12:39 -0500 Subject: [Git][ghc/ghc][wip/expand-do] push the `match_ctxt` business inside `tcMatchLambda` Message-ID: <6548ca2795064_21cb8a31ce35c1277b6@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 6054e134 by Gergő Érdi at 2023-11-06T12:12:07+01:00 push the `match_ctxt` business inside `tcMatchLambda` - - - - - 3 changed files: - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs Changes: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -326,12 +326,12 @@ The {l1} etc are location/source span information stored in the AST by the parse The 3 non-obvious points to consider are: 1. Wrap the expression with a `fail` block if the pattern match is not irrefutable. - See Part 1. Below + See Part 1. below 2. Generate appropriate warnings for discarded results in a body statement eg. say `do { .. ; (g p :: m Int) ; ... }` - See Part 2. Below + See Part 2. below 3. Generating appropriate type error messages which blame the correct source spans - See Part 3 Below + See Part 3. below Part 1. Expanding Patterns Bindings ----------------------------------- ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -265,19 +265,9 @@ tcExpr e@(HsIPVar _ x) res_ty origin = IPOccOrigin x tcExpr e@(HsLam x lam_variant matches) res_ty - = do { (wrap, matches') <- tcMatchLambda herald match_ctxt matches res_ty + = do { (wrap, matches') <- tcMatchLambda herald lam_variant matches res_ty ; return (mkHsWrap wrap $ HsLam x lam_variant matches') } where - match_ctxt - | Just f <- doExpansionFlavour (mg_ext matches) - -- See Part 3. B. of Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`. Testcase: Typeable1 - = MC { mc_what = StmtCtxt (HsDoStmt f) - , mc_body = tcBodyNC -- NB: Do not add any error contexts - -- It has already been done - } - | otherwise - = MC { mc_what = LamAlt lam_variant - , mc_body = tcBody } herald = ExpectedFunTyLam lam_variant e ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -77,6 +77,7 @@ import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Types.Name import GHC.Types.Id import GHC.Types.SrcLoc +import GHC.Types.Basic import Control.Monad import Control.Arrow ( second ) @@ -155,11 +156,11 @@ tcMatchesCase ctxt (Scaled scrut_mult scrut_ty) matches res_ty = tcMatches ctxt [ExpFunPatTy (Scaled scrut_mult (mkCheckExpType scrut_ty))] res_ty matches tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify - -> TcMatchCtxt HsExpr + -> HsLamVariant -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -tcMatchLambda herald match_ctxt match res_ty +tcMatchLambda herald lam_variant match res_ty = 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 @@ -168,6 +169,18 @@ tcMatchLambda herald match_ctxt match res_ty n_pats | isEmptyMatchGroup match = 1 -- must be lambda-case | otherwise = matchGroupArity match + match_ctxt + | Just f <- doExpansionFlavour (mg_ext match) + -- See Part 3. B. of Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`. Testcase: Typeable1 + = MC { mc_what = StmtCtxt (HsDoStmt f) + , mc_body = tcBodyNC -- NB: Do not add any error contexts + -- It has already been done + } + | otherwise + = MC { mc_what = LamAlt lam_variant + , mc_body = tcBody } + + -- @tcGRHSsPat@ typechecks @[GRHSs]@ that occur in a @PatMonoBind at . tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6054e13486fe64cfe6146a2751f1652ccc9b72cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6054e13486fe64cfe6146a2751f1652ccc9b72cd You're receiving 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 Nov 6 11:24:27 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 06 Nov 2023 06:24:27 -0500 Subject: [Git][ghc/ghc][wip/expand-do] - Note changes. Making expansion example a bit more complex Message-ID: <6548cceb506ef_21cb8a34cb17c132565@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: a142de1d by Apoorv Ingle at 2023-11-06T12:22:06+01:00 - Note changes. Making expansion example a bit more complex - - - - - 1 changed file: - compiler/GHC/Tc/Gen/Do.hs Changes: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -410,15 +410,17 @@ It stores the original statement (with location) and the expanded expression ----------------------------- For example, the `do`-block - do { e1; e2 } + do { e1; e2; e3 } expands (ignoring the location info) to - ‹ExpandedThingRn do { e1; e2 }› -- Original Do Expression + ‹ExpandedThingRn do { e1; e2; e3 }› -- Original Do Expression -- Expanded Do Expression - (‹ExpandedThingRn e1› -- Original Statement - ({(>>) e1} -- Expanded Expression - ‹PopErrCtxt› (‹ExpandedThingRn e2› {e2}))) + (‹ExpandedThingRn e1› -- Original Statement + ({(>>) e1} -- Expanded Expression + ‹PopErrCtxt› (‹ExpandedThingRn e2› + ({(>>) e2} + ‹PopErrCtxt› (‹ExpandedThingRn e3› {e3}))))) * Whenever the typechecker steps through an `ExpandedThingRn`, we push the original statement in the error context, set the error location to the @@ -457,9 +459,9 @@ It stores the original statement (with location) and the expanded expression expands (ignoring the location information) to ‹ExpandedThingRn do{ p <- e1; e2 }› -- Original Do Expression - -- + -- (‹ExpandedThingRn (p <- e1)› -- Original Statement - (((>>=) e1) -- Expanded Expression + (((>>=) e1) -- Expanded Expression ‹PopErrCtxt› ((\ p -> ‹ExpandedThingRn (e2)› e2))) ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a142de1d44d78e97335704317c425b58e61a58e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a142de1d44d78e97335704317c425b58e61a58e3 You're receiving 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 Nov 6 11:56:02 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 06:56:02 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/9.4.8-backports Message-ID: <6548d4522a438_21cb8a41207ec13914d@gitlab.mail> Zubin pushed new branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/9.4.8-backports You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Nov 6 11:59:20 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 06:59:20 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] Prepare release 9.4.8 Message-ID: <6548d518c5a17_21cb8a44c50dc141030@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 3f8c8f9f by Zubin Duggal at 2023-11-06T17:29:10+05:30 Prepare release 9.4.8 - - - - - 5 changed files: - configure.ac - docs/users_guide/9.4.7-notes.rst - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f8c8f9fb92d111ef3ebd9c0d6f9028d969f2789 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f8c8f9fb92d111ef3ebd9c0d6f9028d969f2789 You're receiving 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 Nov 6 11:59:56 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 06:59:56 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] Prepare release 9.4.8 Message-ID: <6548d53cb1249_21cb8a4c4da70141351@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 45a57211 by Zubin Duggal at 2023-11-06T17:29:49+05:30 Prepare release 9.4.8 - - - - - 6 changed files: - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45a57211b4c1e2b93ba923ffd57af571a3b017d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45a57211b4c1e2b93ba923ffd57af571a3b017d6 You're receiving 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 Nov 6 12:37:09 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 07:37:09 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] testsuite: add the req_process predicate Message-ID: <6548ddf5231b7_2baaec962148170b4@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: cb149c64 by Cheng Shao at 2023-11-06T18:06:58+05:30 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. (cherry picked from commit ce580426ce3052e3b3d2847d0312652ea9087994) - - - - - 2 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -134,6 +134,8 @@ class TestConfig: # Do we have interpreter support? self.have_interp = False + # Do we even have processes? + self.have_process = True # Does the platform support loading of dynamic shared libraries? e.g. # some musl-based environments do not. self.supports_dynamic_libs = True ===================================== testsuite/driver/testlib.py ===================================== @@ -274,6 +274,9 @@ def req_smp( name, opts ): if not config.have_smp: opts.expect = 'fail' +def req_process( name, opts ): + if not config.have_process: + opts.skip = True def ignore_stdout(name, opts): opts.ignore_stdout = True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb149c64b0c0349671ba0a3363edb95455a25051 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb149c64b0c0349671ba0a3363edb95455a25051 You're receiving 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 Nov 6 17:15:18 2023 From: gitlab at gitlab.haskell.org (Oleg Grenrus (@phadej)) Date: Mon, 06 Nov 2023 12:15:18 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/st-delim Message-ID: <65491f265dc1b_2baaec6d21f6c614a5@gitlab.mail> Oleg Grenrus pushed new branch wip/st-delim at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/st-delim You're receiving 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 Nov 6 17:34:48 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Mon, 06 Nov 2023 12:34:48 -0500 Subject: [Git][ghc/ghc][wip/supersven/riscv64-ncg] Fix MO_FF_CONV Message-ID: <654923b8e756e_2baaec798804464317@gitlab.mail> Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC Commits: 9a68096e by Sven Tennie at 2023-11-06T18:33:45+01:00 Fix MO_FF_CONV The instruction needs precision suffixes to be valid. - - - - - 2 changed files: - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/RV64/CodeGen.hs ===================================== @@ -631,7 +631,7 @@ getRegister' config plat expr = truncateReg from to dst ) MO_SS_Conv from to -> ss_conv from to reg code - MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` FCVT (OpReg to dst) (OpReg from reg)) + MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` annExpr e (FCVT (OpReg to dst) (OpReg from reg))) -- Conversions MO_XX_Conv _from to -> swizzleRegisterRep (intFormat to) <$> getRegister e ===================================== compiler/GHC/CmmToAsm/RV64/Ppr.hs ===================================== @@ -684,7 +684,11 @@ pprInstr platform instr = case instr of DMBSY r w -> line $ text "\tfence" <+> pprDmbType r <> char ',' <+> pprDmbType w -- 9. Floating Point Instructions -------------------------------------------- - FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 + FCVT o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.d") o1 o2 + FCVT o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.d.s") o1 o2 + FCVT o1 o2 -> pprPanic "RV64.pprInstr - impossible float conversion" $ + line (pprOp platform o1 <> text "->" <> pprOp platform o2) + SCVTF o1@(OpReg W32 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.s.w") o1 o2 SCVTF o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.w") o1 o2 SCVTF o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.d.l") o1 o2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a68096e0005855853de2cd3849352067d9b899d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a68096e0005855853de2cd3849352067d9b899d You're receiving 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 Nov 6 17:48:34 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 06 Nov 2023 12:48:34 -0500 Subject: [Git][ghc/ghc][wip/libbin] 123 commits: Ensure unconstrained instance dictionaries get IPE info Message-ID: <654926f2c0d50_2baaec7e61f34668d5@gitlab.mail> Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC Commits: 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - e7254678 by Matthew Pickering at 2023-11-06T17:48:21+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 29 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/56d4f18418dc8d9f524b765adbb19c1655184e40...e72546787a72c1cc3cd30408eedaa5c681fe97f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/56d4f18418dc8d9f524b765adbb19c1655184e40...e72546787a72c1cc3cd30408eedaa5c681fe97f8 You're receiving 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 Nov 6 17:50:26 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 06 Nov 2023 12:50:26 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 47 commits: EPA Some tweaks to annotations Message-ID: <65492762adf3c_2baaec8027af8698d0@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 96bf62ff by Matthew Pickering at 2023-11-06T17:48:23+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - dc151c42 by Matthew Pickering at 2023-11-06T17:48:23+00:00 fail when bindist configure fails - - - - - a4fee079 by Matthew Pickering at 2023-11-06T17:48:24+00:00 Correctly propagate build/host/target to bindist fix host/target bindist t - - - - - 67fc2f9d by Matthew Pickering at 2023-11-06T17:48:24+00:00 ci: Test cross bindists - - - - - 761c3a9e by Matthew Pickering at 2023-11-06T17:48:24+00:00 CROSS_STAGE variable - - - - - 97c37ca0 by Matthew Pickering at 2023-11-06T17:48:24+00:00 Use explicit syntax rather than pure - - - - - 1cd717c2 by Matthew Pickering at 2023-11-06T17:48:24+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 02e7d44c by Matthew Pickering at 2023-11-06T17:48:24+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 3dc2f86d by Matthew Pickering at 2023-11-06T17:48:58+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 8fd42b63 by GHC GitLab CI at 2023-11-06T17:49:00+00:00 fix - - - - - 3521ff6d by GHC GitLab CI at 2023-11-06T17:49:00+00:00 Build genapply per stage - - - - - ed1dce40 by GHC GitLab CI at 2023-11-06T17:49:00+00:00 Correct GHC_PKG path - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - + compiler/GHC/JS/Ident.hs - + compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs - compiler/GHC/JS/Make.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/JS/Syntax.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af3cf674fced3a22856b39ad6fba3a178ebf5d89...ed1dce4037da401dd2af06d8f70e2444f622b825 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/af3cf674fced3a22856b39ad6fba3a178ebf5d89...ed1dce4037da401dd2af06d8f70e2444f622b825 You're receiving 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 Nov 6 19:14:08 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 14:14:08 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] 4 commits: hadrian: Add no_split_sections tranformer Message-ID: <65493b007aefb_2baaec9cb21288486e@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 938f48dc by Matthew Pickering at 2023-11-07T00:43:55+05:30 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) - - - - - 85835aca by Matthew Pickering at 2023-11-07T00:43:55+05:30 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) - - - - - bf8fd7c8 by Zubin Duggal at 2023-11-07T00:43:55+05:30 Prepare release 9.4.8 - - - - - d06c456e by Cheng Shao at 2023-11-07T00:43:55+05:30 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. (cherry picked from commit ce580426ce3052e3b3d2847d0312652ea9087994) - - - - - 17 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - + hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/driver/testglobals.py - testsuite/driver/testlib.py Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -119,6 +119,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -134,13 +135,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 @@ -159,8 +161,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 } @@ -267,6 +273,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 @@ -771,9 +778,9 @@ jobs = M.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) @@ -781,16 +788,16 @@ jobs = M.fromList $ concatMap flattenJobGroup $ -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) + , fastCI (standardBuildsWithConfig Amd64 Windows vanilla) , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) , allowFailureGroup (addValidateRule ARMLabel (standardBuilds ARMv7 (Linux Debian10))) - , standardBuilds I386 (Linux Debian9) + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) -- Fully static build, in theory usable on any linux distribution. - , allowFailureGroup (fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine) static)) + , allowFailureGroup (fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static))) , disableValidate (fullyStaticBrokenTests (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt))) -- Dynamically linked build, suitable for building your own static executables on alpine , disableValidate (standardBuildsWithConfig Amd64 (Linux Alpine) vanilla) ===================================== .gitlab/jobs.yaml ===================================== @@ -2057,7 +2057,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", @@ -2067,7 +2067,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": { @@ -2109,11 +2109,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" } }, @@ -2371,7 +2371,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", @@ -2381,7 +2381,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": { @@ -2423,18 +2423,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": "ghcilink002 encoding004 T10458 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", @@ -2444,7 +2444,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": { @@ -2486,12 +2486,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" } }, @@ -2675,7 +2675,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", @@ -2685,7 +2685,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": { @@ -2727,11 +2727,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" } }, ===================================== 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== 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 @@ -113,6 +120,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -124,6 +132,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -135,6 +144,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -146,6 +156,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -157,6 +168,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -168,6 +180,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -217,6 +230,10 @@ The supported transformers are listed below: + + + + ===================================== 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 @@ -31,7 +31,6 @@ import Text.Parsec.Combinator as P import Text.Parsec.Char as P import Control.Monad.Except import UserSettings -import Oracles.Setting flavourTransformers :: Map String (Flavour -> Flavour) @@ -40,6 +39,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 @@ -142,27 +142,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 ? -- Only apply to these packages - builder (Ghc CompileHs) ? arg "-split-sections" - --- | 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 } enableThreadSanitizer :: Flavour -> Flavour enableThreadSanitizer = addArgs $ mconcat ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -38,6 +38,7 @@ data Flavour = Flavour { ghcDebugAssertions :: Bool, -- | Build the GHC executable against the threaded runtime system. ghcThreaded :: 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/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 "-split-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 ===================================== @@ -39,6 +39,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 @@ -245,6 +246,7 @@ defaultFlavour = Flavour , ghcDebugged = False , ghcDebugAssertions = False , ghcThreaded = True + , ghcSplitSections = False , ghcDocs = cmdDocsArgs } -- | Default logic for determining whether to build @@ -281,6 +283,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/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). ===================================== testsuite/driver/testglobals.py ===================================== @@ -134,6 +134,8 @@ class TestConfig: # Do we have interpreter support? self.have_interp = False + # Do we even have processes? + self.have_process = True # Does the platform support loading of dynamic shared libraries? e.g. # some musl-based environments do not. self.supports_dynamic_libs = True ===================================== testsuite/driver/testlib.py ===================================== @@ -274,6 +274,9 @@ def req_smp( name, opts ): if not config.have_smp: opts.expect = 'fail' +def req_process( name, opts ): + if not config.have_process: + opts.skip = True def ignore_stdout(name, opts): opts.ignore_stdout = True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb149c64b0c0349671ba0a3363edb95455a25051...d06c456e6e812656a8fa52fb624129b2c0f09b0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb149c64b0c0349671ba0a3363edb95455a25051...d06c456e6e812656a8fa52fb624129b2c0f09b0e You're receiving 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 Nov 6 20:16:03 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 06 Nov 2023 15:16:03 -0500 Subject: [Git][ghc/ghc][wip/expand-do] - Note changes. Making expansion example a bit more complex Message-ID: <654949831c304_2baaec9f4c7a89028e@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 7742deac by Apoorv Ingle at 2023-11-06T21:15:49+01:00 - Note changes. Making expansion example a bit more complex - - - - - 3 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Tc/Gen/Do.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -1425,7 +1425,7 @@ instance (OutputableBndrId p) => Outputable (HsCmdTop (GhcPass p)) where -} type instance XMG GhcPs b = Origin -type instance XMG GhcRn b = Origin +type instance XMG GhcRn b = Origin -- See Note [Generated code and pattern-match checking] type instance XMG GhcTc b = MatchGroupTc data MatchGroupTc ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -68,7 +68,7 @@ import GHC.HsToCore.Monad import GHC.Data.Bag import GHC.Data.OrdList -import Control.Monad (when, forM_) +import Control.Monad (when, unless, forM_) import qualified Data.Semigroup as Semi import Data.List.NonEmpty ( NonEmpty(..) ) import qualified Data.List.NonEmpty as NE @@ -191,7 +191,7 @@ pmcMatches origin ctxt vars matches = {-# SCC "pmcMatches" #-} do result <- {-# SCC "checkMatchGroup" #-} unCA (checkMatchGroup matches) missing tracePm "}: " (ppr (cr_uncov result)) - when (not (isDoExpansionGenerated origin)) -- Generated code shouldn't emit overlapping warnings + unless (isDoExpansionGenerated origin) -- Do expansion generated code shouldn't emit overlapping warnings ({-# SCC "formatReportWarnings" #-} formatReportWarnings ReportMatchGroup ctxt vars result) return (NE.toList (ldiMatchGroup (cr_ret result))) ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -410,15 +410,17 @@ It stores the original statement (with location) and the expanded expression ----------------------------- For example, the `do`-block - do { e1; e2 } + do { e1; e2; e3 } expands (ignoring the location info) to - ‹ExpandedThingRn do { e1; e2 }› -- Original Do Expression + ‹ExpandedThingRn do { e1; e2; e3 }› -- Original Do Expression -- Expanded Do Expression - (‹ExpandedThingRn e1› -- Original Statement - ({(>>) e1} -- Expanded Expression - ‹PopErrCtxt› (‹ExpandedThingRn e2› {e2}))) + (‹ExpandedThingRn e1› -- Original Statement + ({(>>) e1} -- Expanded Expression + ‹PopErrCtxt› (‹ExpandedThingRn e2› + ({(>>) e2} + ‹PopErrCtxt› (‹ExpandedThingRn e3› {e3}))))) * Whenever the typechecker steps through an `ExpandedThingRn`, we push the original statement in the error context, set the error location to the @@ -457,9 +459,9 @@ It stores the original statement (with location) and the expanded expression expands (ignoring the location information) to ‹ExpandedThingRn do{ p <- e1; e2 }› -- Original Do Expression - -- + -- (‹ExpandedThingRn (p <- e1)› -- Original Statement - (((>>=) e1) -- Expanded Expression + (((>>=) e1) -- Expanded Expression ‹PopErrCtxt› ((\ p -> ‹ExpandedThingRn (e2)› e2))) ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7742deacd8eaa5d52b5f774139c54308b6f923f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7742deacd8eaa5d52b5f774139c54308b6f923f9 You're receiving 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 Nov 6 21:48:33 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 Nov 2023 16:48:33 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <65495f3130643_2baaecd75d5701077b0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - cef83ab8 by Tobias Haslop at 2023-11-06T16:48:20-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 85b434b2 by Luite Stegeman at 2023-11-06T16:48:26-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 5 changed files: - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs Changes: ===================================== compiler/GHC/JS/JStg/Monad.hs ===================================== @@ -40,7 +40,6 @@ module GHC.JS.JStg.Monad , JSM , withTag , newIdent - , newIdents , initJSM ) where @@ -95,19 +94,6 @@ newIdent = do env <- get mk_ident :: FastString -> Unique -> Ident mk_ident t i = global (mconcat [t, "_", mkFastString (show i)]) - - --- | A special case optimization over @newIdent at . Given a number of @Ident@ to --- generate, generate all of them at one time and update the state once rather --- than n times. -newIdents :: Int -> JSM [Ident] -newIdents 0 = return [] -newIdents n = do env <- get - let is = take n (uniqsFromSupply $ ids env) - tag = prefix env - return $ fmap (mk_ident tag) is - - -- | Set the tag for @Ident at s for all remaining computations. tag_names :: FastString -> JSM () tag_names tag = modify' (\env -> env {prefix = tag}) ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -149,6 +149,7 @@ import GHC.JS.JStg.Monad import GHC.JS.Transform import Control.Arrow ((***)) +import Control.Monad (replicateM) import Data.Tuple import qualified Data.Map as M @@ -325,7 +326,7 @@ jFunctionSized -> ([JStgExpr] -> JSM JStgStat) -- ^ function body, input is locally unique generated variables -> JSM JStgStat jFunctionSized name arity body = do - func_args <- newIdents arity + func_args <- replicateM arity newIdent FuncStat name func_args <$> (body $ toJExpr <$> func_args) -- | Construct a top-level function subject to JS hoisting. Special case where ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,12 +39,26 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8df66b466ddf507c43c1b5e491a133194aed651a...85b434b2a19bc7142232ef90e186e467b796c445 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8df66b466ddf507c43c1b5e491a133194aed651a...85b434b2a19bc7142232ef90e186e467b796c445 You're receiving 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 Nov 6 22:43:55 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 06 Nov 2023 17:43:55 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] testsuite: add omit_ghci for use in process Message-ID: <65496c2b18e21_2baaecf1038a81171ac@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 89949c9f by Zubin Duggal at 2023-11-07T04:13:47+05:30 testsuite: add omit_ghci for use in process - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -392,6 +392,8 @@ def _omit_ways( name: TestName, opts, ways: List[WayName] ): _lint_ways(name, ways) opts.omit_ways += ways +omit_ghci = omit_ways([WayName('ghci'), WayName('ghci-opt')]) + # ----- def only_ways( ways: List[WayName] ): View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89949c9f7bf79d2af47dc534201f0b0be9605949 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89949c9f7bf79d2af47dc534201f0b0be9605949 You're receiving 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 Nov 7 01:49:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 Nov 2023 20:49:30 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Elaborate on the quantified superclass of Bifunctor Message-ID: <654997aaa54a1_2baaec136fadfc13114e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8d1d48e8 by Tobias Haslop at 2023-11-06T20:49:13-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 6457bc23 by Alan Zimmerman at 2023-11-06T20:49:13-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - 7f1a5f99 by Luite Stegeman at 2023-11-06T20:49:16-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 19 changed files: - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - libraries/base/src/Data/Bifunctor.hs - utils/haddock Changes: ===================================== compiler/GHC/JS/JStg/Monad.hs ===================================== @@ -40,7 +40,6 @@ module GHC.JS.JStg.Monad , JSM , withTag , newIdent - , newIdents , initJSM ) where @@ -95,19 +94,6 @@ newIdent = do env <- get mk_ident :: FastString -> Unique -> Ident mk_ident t i = global (mconcat [t, "_", mkFastString (show i)]) - - --- | A special case optimization over @newIdent at . Given a number of @Ident@ to --- generate, generate all of them at one time and update the state once rather --- than n times. -newIdents :: Int -> JSM [Ident] -newIdents 0 = return [] -newIdents n = do env <- get - let is = take n (uniqsFromSupply $ ids env) - tag = prefix env - return $ fmap (mk_ident tag) is - - -- | Set the tag for @Ident at s for all remaining computations. tag_names :: FastString -> JSM () tag_names tag = modify' (\env -> env {prefix = tag}) ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -149,6 +149,7 @@ import GHC.JS.JStg.Monad import GHC.JS.Transform import Control.Arrow ((***)) +import Control.Monad (replicateM) import Data.Tuple import qualified Data.Map as M @@ -325,7 +326,7 @@ jFunctionSized -> ([JStgExpr] -> JSM JStgStat) -- ^ function body, input is locally unique generated variables -> JSM JStgStat jFunctionSized name arity body = do - func_args <- newIdents arity + func_args <- replicateM arity newIdent FuncStat name func_args <$> (body $ toJExpr <$> func_args) -- | Construct a top-level function subject to JS hoisting. Special case where ===================================== compiler/GHC/Parser.y ===================================== @@ -4332,6 +4332,9 @@ glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA +n2l :: LocatedN a -> LocatedA a +n2l (L la a) = L (l2l la) a + anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -50,7 +50,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. - la2na, na2la, n2l, l2n, l2l, la2la, + l2l, la2la, reLoc, HasLoc(..), getHasLocList, @@ -991,31 +991,15 @@ knowing that in most cases the original list is empty. -- --------------------------------------------------------------------- --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -l2n :: LocatedAn a1 a2 -> LocatedN a2 -l2n (L la a) = L (noAnnSrcSpan (locA la)) a +l2l :: (HasLoc a, HasAnnotation b) => a -> b +l2l a = noAnnSrcSpan (getHasLoc a) -n2l :: LocatedN a -> LocatedA a -n2l (L la a) = L (na2la la) a - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2na :: SrcSpanAnn' a -> SrcSpanAnnN -la2na l = noAnnSrcSpan (locA l) - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 -la2la (L la a) = L (noAnnSrcSpan (locA la)) a - -l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = SrcSpanAnn EpAnnNotUsed (locA l) - --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann -na2la l = noAnnSrcSpan (locA l) +la2la :: (HasLoc l, HasAnnotation l2) => GenLocated l a -> GenLocated l2 a +la2la (L la a) = L (noAnnSrcSpan (getHasLoc la)) a locA :: (HasLoc a) => a -> SrcSpan locA = getHasLoc ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1837,7 +1837,7 @@ instance DisambECP (HsExpr GhcPs) where mkHsParPV l lpar e rpar = do cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (HsPar (EpAnn (spanAsAnchor l) NoEpAnns cs) lpar e rpar) - mkHsVarPV v@(L l _) = return $ L (na2la l) (HsVar noExtField v) + mkHsVarPV v@(L l _) = return $ L (l2l l) (HsVar noExtField v) mkHsLitPV (L l a) = do cs <- getCommentsFor l return $ L l (HsLit (comment (realSrcSpan l) cs) a) @@ -1912,7 +1912,7 @@ instance DisambECP (PatBuilder GhcPs) where mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat mkHsDoPV l _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat mkHsParPV l lpar p rpar = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar) - mkHsVarPV v@(getLoc -> l) = return $ L (na2la l) (PatBuilderVar v) + mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v) mkHsLitPV lit@(L l a) = do checkUnboxedLitPat lit return $ L l (PatBuilderPat (LitPat noExtField a)) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -244,7 +244,7 @@ finishHsVar (L l name) = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - ; return (HsVar noExtField (L (la2na l) name), unitFV name) } + ; return (HsVar noExtField (L (l2l l) name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) rnUnboundVar v = do @@ -280,7 +280,7 @@ rnExpr (HsVar _ (L l v)) -> rnExpr (ExplicitList noAnn []) | otherwise - -> finishHsVar (L (na2la l) nm) + -> finishHsVar (L (l2l l) nm) }}} rnExpr (HsIPVar x v) ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2539,7 +2539,7 @@ extendPatSynEnv dup_fields_ok has_sel val_decls local_fix_env thing = do { return ((PatSynName bnd_name, con_info) : names) | L bind_loc (PatSynBind _ (PSB { psb_id = L _ n, psb_args = as })) <- bind = do - bnd_name <- newTopSrcBinder (L (la2na bind_loc) n) + bnd_name <- newTopSrcBinder (L (l2l bind_loc) n) let con_info = mkConInfo (conDetailsArity length as) [] return ((PatSynName bnd_name, con_info) : names) | otherwise ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -869,10 +869,10 @@ getLocalNonValBinders fixity_env new_tc dup_fields_ok has_sel tc_decl -- NOT for type/data instances = do { let TyDeclBinders (main_bndr, tc_flav) at_bndrs sig_bndrs (LConsWithFields cons_with_flds flds) = hsLTyClDeclBinders tc_decl - ; tycon_name <- newTopSrcBinder $ l2n main_bndr - ; at_names <- mapM (newTopSrcBinder . l2n . fst) at_bndrs - ; sig_names <- mapM (newTopSrcBinder . l2n) sig_bndrs - ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; tycon_name <- newTopSrcBinder $ la2la main_bndr + ; at_names <- mapM (newTopSrcBinder . la2la . fst) at_bndrs + ; sig_names <- mapM (newTopSrcBinder . la2la) sig_bndrs + ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst con_names_with_flds) flds ; mapM_ (add_dup_fld_errs flds') con_names_with_flds ; let tc_gre = mkLocalTyConGRE (fmap (const tycon_name) tc_flav) tycon_name @@ -947,7 +947,7 @@ getLocalNonValBinders fixity_env new_di dup_fields_ok has_sel mb_cls dfid@(DataFamInstDecl { dfid_eqn = ti_decl }) = do { main_name <- unLoc <$> lookupFamInstName mb_cls (feqn_tycon ti_decl) ; let LConsWithFields cons_with_flds flds = hsDataFamInstBinders dfid - ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst sub_names) flds ; mapM_ (add_dup_fld_errs flds') sub_names ; let fld_env = mk_fld_env sub_names flds' @@ -2133,14 +2133,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) where occ = occName n {- ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -558,7 +558,7 @@ rnPatAndThen _ (NPat x (L l lit) mb_neg _eq) ; return (NPat x (L l lit') mb_neg' eq') } rnPatAndThen mk (NPlusKPat _ rdr (L l lit) _ _ _ ) - = do { new_name <- newPatName mk (l2n rdr) + = do { new_name <- newPatName mk (la2la rdr) ; (lit', _) <- liftCpsFV $ rnOverLit lit -- See Note [Negative zero] -- We skip negateName as -- negative zero doesn't make ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -391,12 +391,12 @@ mkQuasiQuoteExpr :: UntypedSpliceFlavour -> Name mkQuasiQuoteExpr flavour quoter (L q_span' quote) = L q_span $ HsApp noComments (L q_span $ HsApp noComments (L q_span - (HsVar noExtField (L (la2na q_span) quote_selector))) + (HsVar noExtField (L (l2l q_span) quote_selector))) quoterExpr) quoteExpr where q_span = noAnnSrcSpan (locA q_span') - quoterExpr = L q_span $! HsVar noExtField $! (L (la2na q_span) quoter) + quoterExpr = L q_span $! HsVar noExtField $! (L (l2l q_span) quoter) quoteExpr = L q_span $! HsLit noComments $! HsString NoSourceText quote quote_selector = case flavour of UntypedExpSplice -> quoteExpName ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1241,7 +1241,7 @@ dynCompileExpr expr = do parsed_expr <- parseExpr expr -- > Data.Dynamic.toDyn expr let loc = getLoc parsed_expr - to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (la2na loc) $ getRdrName toDynName) + to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (l2l loc) $ getRdrName toDynName) parsed_expr hval <- compileParsedExpr to_dyn_expr return (unsafeCoerce hval :: Dynamic) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2292,7 +2292,7 @@ mkFunBindSE arity loc fun pats_and_exprs mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBind fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches) + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches) -- | Make a function binding. If no equations are given, produce a function -- with the given arity that uses an empty case expression for the last @@ -2320,7 +2320,7 @@ mkRdrFunBindEC :: Arity -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- fmap _ z = case z of {} @@ -2344,7 +2344,7 @@ mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindSE arity fun@(L loc fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- compare _ _ = error "Void compare" ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -710,7 +710,7 @@ lookupChildrenExport spec_parent rdr_items = mapAndReportM doOne rdr_items do { ub <- reportUnboundName unboundName ; let l = getLoc n gre = mkLocalGRE UnboundGRE NoParent ub - ; return (L l (IEName noExtField (L (la2na l) ub)), gre)} + ; return (L l (IEName noExtField (L (l2l l) ub)), gre)} FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) -> do { checkPatSynParent spec_parent par child_nm ; return (replaceLWrappedName n child_nm, child) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1542,7 +1542,7 @@ splitHsAppTys hs_ty 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) + = ( L (l2l sp) (HsTyVar noAnn prom op) , HsValArg l : HsValArg r : as ) go f as = (f, as) ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -195,7 +195,7 @@ tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs, tcdMeths = default_binds})) = recoverM (return emptyLHsBinds) $ setSrcSpan (getLocA class_name) $ - do { clas <- tcLookupLocatedClass (n2l class_name) + do { clas <- tcLookupLocatedClass (la2la class_name) -- We make a separate binding for each default method. -- At one time I used a single AbsBinds for all of them, thus @@ -281,7 +281,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn local_dm_ty = instantiateMethod clas global_dm_id (mkTyVarTys tyvars) - lm_bind = dm_bind { fun_id = L (la2na bind_loc) local_dm_name } + lm_bind = dm_bind { fun_id = L (l2l bind_loc) local_dm_name } -- Substitute the local_meth_name for the binder -- NB: the binding is always a FunBind ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -610,7 +610,7 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) -- itself, so we make do with the location of family name ; (co_ax_branch, co_ax_validity_info) <- tcTyFamInstEqn fam_tc mb_clsinfo - (L (na2la $ getLoc fam_lname) eqn) + (L (l2l $ getLoc fam_lname) eqn) -- (2) check for validity ; checkConsistentFamInst mb_clsinfo fam_tc co_ax_branch ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -943,7 +943,7 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) mk_mg :: LHsExpr GhcRn -> MatchGroup GhcRn (LHsExpr GhcRn) mk_mg body = mkMatchGroup (Generated SkipPmc) (noLocA [builder_match]) where - builder_args = [L (na2la loc) (VarPat noExtField (L loc n)) + builder_args = [L (l2l loc) (VarPat noExtField (L loc n)) | L loc n <- args] builder_match = mkMatch (mkPrefixFunRhs ps_lname) builder_args body ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,9 +39,23 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- -- @'second' 'id' ≡ 'id'@ @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b75ff8a88bbdd0d60032a4e304d37ec65526c06b +Subproject commit 2cbf7f0a55898e0c2827ae9ad13727b34877e793 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85b434b2a19bc7142232ef90e186e467b796c445...7f1a5f996c77568d8920ec0ad77c22b83fb89ad8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85b434b2a19bc7142232ef90e186e467b796c445...7f1a5f996c77568d8920ec0ad77c22b83fb89ad8 You're receiving 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 Nov 7 04:39:57 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 06 Nov 2023 23:39:57 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Elaborate on the quantified superclass of Bifunctor Message-ID: <6549bf9c76129_2baaec176eb2a4154344@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f4b8a257 by Tobias Haslop at 2023-11-06T23:39:41-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - fe929bd0 by Alan Zimmerman at 2023-11-06T23:39:41-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - 1163a38a by Luite Stegeman at 2023-11-06T23:39:44-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 19 changed files: - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - libraries/base/src/Data/Bifunctor.hs - utils/haddock Changes: ===================================== compiler/GHC/JS/JStg/Monad.hs ===================================== @@ -40,7 +40,6 @@ module GHC.JS.JStg.Monad , JSM , withTag , newIdent - , newIdents , initJSM ) where @@ -95,19 +94,6 @@ newIdent = do env <- get mk_ident :: FastString -> Unique -> Ident mk_ident t i = global (mconcat [t, "_", mkFastString (show i)]) - - --- | A special case optimization over @newIdent at . Given a number of @Ident@ to --- generate, generate all of them at one time and update the state once rather --- than n times. -newIdents :: Int -> JSM [Ident] -newIdents 0 = return [] -newIdents n = do env <- get - let is = take n (uniqsFromSupply $ ids env) - tag = prefix env - return $ fmap (mk_ident tag) is - - -- | Set the tag for @Ident at s for all remaining computations. tag_names :: FastString -> JSM () tag_names tag = modify' (\env -> env {prefix = tag}) ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -149,6 +149,7 @@ import GHC.JS.JStg.Monad import GHC.JS.Transform import Control.Arrow ((***)) +import Control.Monad (replicateM) import Data.Tuple import qualified Data.Map as M @@ -325,7 +326,7 @@ jFunctionSized -> ([JStgExpr] -> JSM JStgStat) -- ^ function body, input is locally unique generated variables -> JSM JStgStat jFunctionSized name arity body = do - func_args <- newIdents arity + func_args <- replicateM arity newIdent FuncStat name func_args <$> (body $ toJExpr <$> func_args) -- | Construct a top-level function subject to JS hoisting. Special case where ===================================== compiler/GHC/Parser.y ===================================== @@ -4332,6 +4332,9 @@ glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA +n2l :: LocatedN a -> LocatedA a +n2l (L la a) = L (l2l la) a + anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -50,7 +50,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. - la2na, na2la, n2l, l2n, l2l, la2la, + l2l, la2la, reLoc, HasLoc(..), getHasLocList, @@ -991,31 +991,15 @@ knowing that in most cases the original list is empty. -- --------------------------------------------------------------------- --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -l2n :: LocatedAn a1 a2 -> LocatedN a2 -l2n (L la a) = L (noAnnSrcSpan (locA la)) a +l2l :: (HasLoc a, HasAnnotation b) => a -> b +l2l a = noAnnSrcSpan (getHasLoc a) -n2l :: LocatedN a -> LocatedA a -n2l (L la a) = L (na2la la) a - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2na :: SrcSpanAnn' a -> SrcSpanAnnN -la2na l = noAnnSrcSpan (locA l) - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 -la2la (L la a) = L (noAnnSrcSpan (locA la)) a - -l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = SrcSpanAnn EpAnnNotUsed (locA l) - --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann -na2la l = noAnnSrcSpan (locA l) +la2la :: (HasLoc l, HasAnnotation l2) => GenLocated l a -> GenLocated l2 a +la2la (L la a) = L (noAnnSrcSpan (getHasLoc la)) a locA :: (HasLoc a) => a -> SrcSpan locA = getHasLoc ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1837,7 +1837,7 @@ instance DisambECP (HsExpr GhcPs) where mkHsParPV l lpar e rpar = do cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (HsPar (EpAnn (spanAsAnchor l) NoEpAnns cs) lpar e rpar) - mkHsVarPV v@(L l _) = return $ L (na2la l) (HsVar noExtField v) + mkHsVarPV v@(L l _) = return $ L (l2l l) (HsVar noExtField v) mkHsLitPV (L l a) = do cs <- getCommentsFor l return $ L l (HsLit (comment (realSrcSpan l) cs) a) @@ -1912,7 +1912,7 @@ instance DisambECP (PatBuilder GhcPs) where mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat mkHsDoPV l _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat mkHsParPV l lpar p rpar = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar) - mkHsVarPV v@(getLoc -> l) = return $ L (na2la l) (PatBuilderVar v) + mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v) mkHsLitPV lit@(L l a) = do checkUnboxedLitPat lit return $ L l (PatBuilderPat (LitPat noExtField a)) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -244,7 +244,7 @@ finishHsVar (L l name) = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - ; return (HsVar noExtField (L (la2na l) name), unitFV name) } + ; return (HsVar noExtField (L (l2l l) name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) rnUnboundVar v = do @@ -280,7 +280,7 @@ rnExpr (HsVar _ (L l v)) -> rnExpr (ExplicitList noAnn []) | otherwise - -> finishHsVar (L (na2la l) nm) + -> finishHsVar (L (l2l l) nm) }}} rnExpr (HsIPVar x v) ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2539,7 +2539,7 @@ extendPatSynEnv dup_fields_ok has_sel val_decls local_fix_env thing = do { return ((PatSynName bnd_name, con_info) : names) | L bind_loc (PatSynBind _ (PSB { psb_id = L _ n, psb_args = as })) <- bind = do - bnd_name <- newTopSrcBinder (L (la2na bind_loc) n) + bnd_name <- newTopSrcBinder (L (l2l bind_loc) n) let con_info = mkConInfo (conDetailsArity length as) [] return ((PatSynName bnd_name, con_info) : names) | otherwise ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -869,10 +869,10 @@ getLocalNonValBinders fixity_env new_tc dup_fields_ok has_sel tc_decl -- NOT for type/data instances = do { let TyDeclBinders (main_bndr, tc_flav) at_bndrs sig_bndrs (LConsWithFields cons_with_flds flds) = hsLTyClDeclBinders tc_decl - ; tycon_name <- newTopSrcBinder $ l2n main_bndr - ; at_names <- mapM (newTopSrcBinder . l2n . fst) at_bndrs - ; sig_names <- mapM (newTopSrcBinder . l2n) sig_bndrs - ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; tycon_name <- newTopSrcBinder $ la2la main_bndr + ; at_names <- mapM (newTopSrcBinder . la2la . fst) at_bndrs + ; sig_names <- mapM (newTopSrcBinder . la2la) sig_bndrs + ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst con_names_with_flds) flds ; mapM_ (add_dup_fld_errs flds') con_names_with_flds ; let tc_gre = mkLocalTyConGRE (fmap (const tycon_name) tc_flav) tycon_name @@ -947,7 +947,7 @@ getLocalNonValBinders fixity_env new_di dup_fields_ok has_sel mb_cls dfid@(DataFamInstDecl { dfid_eqn = ti_decl }) = do { main_name <- unLoc <$> lookupFamInstName mb_cls (feqn_tycon ti_decl) ; let LConsWithFields cons_with_flds flds = hsDataFamInstBinders dfid - ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst sub_names) flds ; mapM_ (add_dup_fld_errs flds') sub_names ; let fld_env = mk_fld_env sub_names flds' @@ -2133,14 +2133,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) where occ = occName n {- ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -558,7 +558,7 @@ rnPatAndThen _ (NPat x (L l lit) mb_neg _eq) ; return (NPat x (L l lit') mb_neg' eq') } rnPatAndThen mk (NPlusKPat _ rdr (L l lit) _ _ _ ) - = do { new_name <- newPatName mk (l2n rdr) + = do { new_name <- newPatName mk (la2la rdr) ; (lit', _) <- liftCpsFV $ rnOverLit lit -- See Note [Negative zero] -- We skip negateName as -- negative zero doesn't make ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -391,12 +391,12 @@ mkQuasiQuoteExpr :: UntypedSpliceFlavour -> Name mkQuasiQuoteExpr flavour quoter (L q_span' quote) = L q_span $ HsApp noComments (L q_span $ HsApp noComments (L q_span - (HsVar noExtField (L (la2na q_span) quote_selector))) + (HsVar noExtField (L (l2l q_span) quote_selector))) quoterExpr) quoteExpr where q_span = noAnnSrcSpan (locA q_span') - quoterExpr = L q_span $! HsVar noExtField $! (L (la2na q_span) quoter) + quoterExpr = L q_span $! HsVar noExtField $! (L (l2l q_span) quoter) quoteExpr = L q_span $! HsLit noComments $! HsString NoSourceText quote quote_selector = case flavour of UntypedExpSplice -> quoteExpName ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1241,7 +1241,7 @@ dynCompileExpr expr = do parsed_expr <- parseExpr expr -- > Data.Dynamic.toDyn expr let loc = getLoc parsed_expr - to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (la2na loc) $ getRdrName toDynName) + to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (l2l loc) $ getRdrName toDynName) parsed_expr hval <- compileParsedExpr to_dyn_expr return (unsafeCoerce hval :: Dynamic) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2292,7 +2292,7 @@ mkFunBindSE arity loc fun pats_and_exprs mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBind fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches) + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches) -- | Make a function binding. If no equations are given, produce a function -- with the given arity that uses an empty case expression for the last @@ -2320,7 +2320,7 @@ mkRdrFunBindEC :: Arity -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- fmap _ z = case z of {} @@ -2344,7 +2344,7 @@ mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindSE arity fun@(L loc fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- compare _ _ = error "Void compare" ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -710,7 +710,7 @@ lookupChildrenExport spec_parent rdr_items = mapAndReportM doOne rdr_items do { ub <- reportUnboundName unboundName ; let l = getLoc n gre = mkLocalGRE UnboundGRE NoParent ub - ; return (L l (IEName noExtField (L (la2na l) ub)), gre)} + ; return (L l (IEName noExtField (L (l2l l) ub)), gre)} FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) -> do { checkPatSynParent spec_parent par child_nm ; return (replaceLWrappedName n child_nm, child) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1542,7 +1542,7 @@ splitHsAppTys hs_ty 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) + = ( L (l2l sp) (HsTyVar noAnn prom op) , HsValArg l : HsValArg r : as ) go f as = (f, as) ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -195,7 +195,7 @@ tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs, tcdMeths = default_binds})) = recoverM (return emptyLHsBinds) $ setSrcSpan (getLocA class_name) $ - do { clas <- tcLookupLocatedClass (n2l class_name) + do { clas <- tcLookupLocatedClass (la2la class_name) -- We make a separate binding for each default method. -- At one time I used a single AbsBinds for all of them, thus @@ -281,7 +281,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn local_dm_ty = instantiateMethod clas global_dm_id (mkTyVarTys tyvars) - lm_bind = dm_bind { fun_id = L (la2na bind_loc) local_dm_name } + lm_bind = dm_bind { fun_id = L (l2l bind_loc) local_dm_name } -- Substitute the local_meth_name for the binder -- NB: the binding is always a FunBind ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -610,7 +610,7 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) -- itself, so we make do with the location of family name ; (co_ax_branch, co_ax_validity_info) <- tcTyFamInstEqn fam_tc mb_clsinfo - (L (na2la $ getLoc fam_lname) eqn) + (L (l2l $ getLoc fam_lname) eqn) -- (2) check for validity ; checkConsistentFamInst mb_clsinfo fam_tc co_ax_branch ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -943,7 +943,7 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) mk_mg :: LHsExpr GhcRn -> MatchGroup GhcRn (LHsExpr GhcRn) mk_mg body = mkMatchGroup (Generated SkipPmc) (noLocA [builder_match]) where - builder_args = [L (na2la loc) (VarPat noExtField (L loc n)) + builder_args = [L (l2l loc) (VarPat noExtField (L loc n)) | L loc n <- args] builder_match = mkMatch (mkPrefixFunRhs ps_lname) builder_args body ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,9 +39,23 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- -- @'second' 'id' ≡ 'id'@ @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b75ff8a88bbdd0d60032a4e304d37ec65526c06b +Subproject commit 2cbf7f0a55898e0c2827ae9ad13727b34877e793 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f1a5f996c77568d8920ec0ad77c22b83fb89ad8...1163a38a2fabddf037afd705218b5c74e7c34e3c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f1a5f996c77568d8920ec0ad77c22b83fb89ad8...1163a38a2fabddf037afd705218b5c74e7c34e3c You're receiving 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 Nov 7 07:20:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 Nov 2023 02:20:32 -0500 Subject: [Git][ghc/ghc][master] Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <6549e540b8818_2baaec1b3ff9b0172531@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - 3 changed files: - libraries/base/src/Data/Bifoldable.hs - libraries/base/src/Data/Bifunctor.hs - libraries/base/src/Data/Bitraversable.hs Changes: ===================================== libraries/base/src/Data/Bifoldable.hs ===================================== @@ -92,6 +92,15 @@ import GHC.Generics (K1(..)) -- 'bifoldr' f g z t ≡ 'appEndo' ('bifoldMap' (Endo . f) (Endo . g) t) z -- @ -- +-- If the type is also an instance of 'Foldable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'bifoldl' 'const' ≡ 'foldl' +-- 'bifoldr' ('flip' 'const') ≡ 'foldr' +-- 'bifoldMap' ('const' 'mempty') ≡ 'foldMap' +-- @ +-- -- If the type is also a 'Data.Bifunctor.Bifunctor' instance, it should satisfy: -- -- @ @@ -221,7 +230,17 @@ class Bifoldable p where bifoldl f g z t = appEndo (getDual (bifoldMap (Dual . Endo . flip f) (Dual . Endo . flip g) t)) z --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bifoldable methods are lazier than their Foldable counterparts. +-- For example the law @'bifoldr' ('flip' 'const') ≡ 'foldr'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` () +-- () +-- >>> foldr (:) [] (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bifoldable (,) where bifoldMap f g ~(a, b) = f a `mappend` g b ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -44,7 +44,7 @@ import GHC.Generics ( K1(..) ) -- must be a 'Functor' and the 'second' method must agree with 'fmap'. -- From this it follows that: -- --- @'second' 'id' = 'id'@ +-- @'second' 'id' ≡ 'id'@ -- -- If you supply 'bimap', you should ensure that: -- ===================================== libraries/base/src/Data/Bitraversable.hs ===================================== @@ -70,8 +70,8 @@ import GHC.Generics (K1(..)) -- preserving the 'Applicative' operations: -- -- @ --- t ('pure' x) = 'pure' x --- t (f '<*>' x) = t f '<*>' t x +-- t ('pure' x) ≡ 'pure' x +-- t (f '<*>' x) ≡ t f '<*>' t x -- @ -- -- and the identity functor 'Identity' and composition functors @@ -91,11 +91,18 @@ import GHC.Generics (K1(..)) -- -- @ -- 'bimap' f g ≡ 'runIdentity' . 'bitraverse' ('Identity' . f) ('Identity' . g) --- 'bifoldMap' f g = 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) +-- 'bifoldMap' f g ≡ 'getConst' . 'bitraverse' ('Const' . f) ('Const' . g) -- @ -- -- These are available as 'bimapDefault' and 'bifoldMapDefault' respectively. -- +-- If the type is also an instance of 'Traversable', then +-- it must satisfy (up to laziness): +-- +-- @ +-- 'traverse' ≡ 'bitraverse' 'pure' +-- @ +-- -- @since 4.10.0.0 class (Bifunctor t, Bifoldable t) => Bitraversable t where -- | Evaluates the relevant functions at each element in the structure, @@ -164,7 +171,17 @@ bimapM = bitraverse bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) bisequence = bitraverse id id --- | @since 4.10.0.0 +-- | Class laws for tuples hold only up to laziness. The +-- Bitraversable methods are lazier than their Traversable counterparts. +-- For example the law @'bitraverse' 'pure' ≡ 'traverse'@ does +-- not hold for tuples if lazyness is exploited: +-- +-- >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` () +-- () +-- >>> (traverse pure undefined :: IO (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.10.0.0 instance Bitraversable (,) where bitraverse f g ~(a, b) = liftA2 (,) (f a) (g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30baac7affe7c9d31c0252b669eda804695fb598 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30baac7affe7c9d31c0252b669eda804695fb598 You're receiving 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 Nov 7 07:21:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 Nov 2023 02:21:06 -0500 Subject: [Git][ghc/ghc][master] Elaborate on the quantified superclass of Bifunctor Message-ID: <6549e5629f6d_2baaec1b3fa3981762a5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 1 changed file: - libraries/base/src/Data/Bifunctor.hs Changes: ===================================== libraries/base/src/Data/Bifunctor.hs ===================================== @@ -39,9 +39,23 @@ import GHC.Generics ( K1(..) ) -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- +-- The class definition of a 'Bifunctor' @p@ uses the +-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html) +-- language extension to quantify over the first type +-- argument @a@ in its context. The context requires that @p a@ +-- must be a 'Functor' for all @a at . In other words a partially +-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a +-- superclass of 'Bifunctor' such that a function with a +-- 'Bifunctor' constraint may use 'fmap' in its implementation. +-- 'Functor' has been a quantified superclass of +-- 'Bifunctor' since base-4.18.0.0. +-- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. A partially applied 'Bifunctor' --- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- defining both 'first' and 'second'. The 'second' method must +-- agree with 'fmap': +-- +-- @'second' ≡ 'fmap'@ +-- -- From this it follows that: -- -- @'second' 'id' ≡ 'id'@ @@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- --- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. --- -- @since 4.8.0.0 class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df626f008230fd55308d8c64d3879d7ec79b44df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df626f008230fd55308d8c64d3879d7ec79b44df You're receiving 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 Nov 7 07:21:58 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 Nov 2023 02:21:58 -0500 Subject: [Git][ghc/ghc][master] EPA: get rid of l2l and friends Message-ID: <6549e59631264_2baaec1b3ff9b018012c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - 16 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - utils/haddock Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4332,6 +4332,9 @@ glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA +n2l :: LocatedN a -> LocatedA a +n2l (L la a) = L (l2l la) a + anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -50,7 +50,7 @@ module GHC.Parser.Annotation ( -- ** Utilities for converting between different 'GenLocated' when -- ** we do not care about the annotations. - la2na, na2la, n2l, l2n, l2l, la2la, + l2l, la2la, reLoc, HasLoc(..), getHasLocList, @@ -991,31 +991,15 @@ knowing that in most cases the original list is empty. -- --------------------------------------------------------------------- --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -l2n :: LocatedAn a1 a2 -> LocatedN a2 -l2n (L la a) = L (noAnnSrcSpan (locA la)) a +l2l :: (HasLoc a, HasAnnotation b) => a -> b +l2l a = noAnnSrcSpan (getHasLoc a) -n2l :: LocatedN a -> LocatedA a -n2l (L la a) = L (na2la la) a - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2na :: SrcSpanAnn' a -> SrcSpanAnnN -la2na l = noAnnSrcSpan (locA l) - --- |Helper function (temporary) during transition of names --- Discards any annotations -la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 -la2la (L la a) = L (noAnnSrcSpan (locA la)) a - -l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = SrcSpanAnn EpAnnNotUsed (locA l) - --- |Helper function (temporary) during transition of names +-- |Helper function for converting annotation types. -- Discards any annotations -na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann -na2la l = noAnnSrcSpan (locA l) +la2la :: (HasLoc l, HasAnnotation l2) => GenLocated l a -> GenLocated l2 a +la2la (L la a) = L (noAnnSrcSpan (getHasLoc la)) a locA :: (HasLoc a) => a -> SrcSpan locA = getHasLoc ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1837,7 +1837,7 @@ instance DisambECP (HsExpr GhcPs) where mkHsParPV l lpar e rpar = do cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (HsPar (EpAnn (spanAsAnchor l) NoEpAnns cs) lpar e rpar) - mkHsVarPV v@(L l _) = return $ L (na2la l) (HsVar noExtField v) + mkHsVarPV v@(L l _) = return $ L (l2l l) (HsVar noExtField v) mkHsLitPV (L l a) = do cs <- getCommentsFor l return $ L l (HsLit (comment (realSrcSpan l) cs) a) @@ -1912,7 +1912,7 @@ instance DisambECP (PatBuilder GhcPs) where mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat mkHsDoPV l _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat mkHsParPV l lpar p rpar = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar) - mkHsVarPV v@(getLoc -> l) = return $ L (na2la l) (PatBuilderVar v) + mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v) mkHsLitPV lit@(L l a) = do checkUnboxedLitPat lit return $ L l (PatBuilderPat (LitPat noExtField a)) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -244,7 +244,7 @@ finishHsVar (L l name) = do { this_mod <- getModule ; when (nameIsLocalOrFrom this_mod name) $ checkThLocalName name - ; return (HsVar noExtField (L (la2na l) name), unitFV name) } + ; return (HsVar noExtField (L (l2l l) name), unitFV name) } rnUnboundVar :: RdrName -> RnM (HsExpr GhcRn, FreeVars) rnUnboundVar v = do @@ -280,7 +280,7 @@ rnExpr (HsVar _ (L l v)) -> rnExpr (ExplicitList noAnn []) | otherwise - -> finishHsVar (L (na2la l) nm) + -> finishHsVar (L (l2l l) nm) }}} rnExpr (HsIPVar x v) ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2539,7 +2539,7 @@ extendPatSynEnv dup_fields_ok has_sel val_decls local_fix_env thing = do { return ((PatSynName bnd_name, con_info) : names) | L bind_loc (PatSynBind _ (PSB { psb_id = L _ n, psb_args = as })) <- bind = do - bnd_name <- newTopSrcBinder (L (la2na bind_loc) n) + bnd_name <- newTopSrcBinder (L (l2l bind_loc) n) let con_info = mkConInfo (conDetailsArity length as) [] return ((PatSynName bnd_name, con_info) : names) | otherwise ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -869,10 +869,10 @@ getLocalNonValBinders fixity_env new_tc dup_fields_ok has_sel tc_decl -- NOT for type/data instances = do { let TyDeclBinders (main_bndr, tc_flav) at_bndrs sig_bndrs (LConsWithFields cons_with_flds flds) = hsLTyClDeclBinders tc_decl - ; tycon_name <- newTopSrcBinder $ l2n main_bndr - ; at_names <- mapM (newTopSrcBinder . l2n . fst) at_bndrs - ; sig_names <- mapM (newTopSrcBinder . l2n) sig_bndrs - ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; tycon_name <- newTopSrcBinder $ la2la main_bndr + ; at_names <- mapM (newTopSrcBinder . la2la . fst) at_bndrs + ; sig_names <- mapM (newTopSrcBinder . la2la) sig_bndrs + ; con_names_with_flds <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst con_names_with_flds) flds ; mapM_ (add_dup_fld_errs flds') con_names_with_flds ; let tc_gre = mkLocalTyConGRE (fmap (const tycon_name) tc_flav) tycon_name @@ -947,7 +947,7 @@ getLocalNonValBinders fixity_env new_di dup_fields_ok has_sel mb_cls dfid@(DataFamInstDecl { dfid_eqn = ti_decl }) = do { main_name <- unLoc <$> lookupFamInstName mb_cls (feqn_tycon ti_decl) ; let LConsWithFields cons_with_flds flds = hsDataFamInstBinders dfid - ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (l2n con)) cons_with_flds + ; sub_names <- mapM (\(con,flds) -> (,flds) <$> newTopSrcBinder (la2la con)) cons_with_flds ; flds' <- mapM (newRecordFieldLabel dup_fields_ok has_sel $ map fst sub_names) flds ; mapM_ (add_dup_fld_errs flds') sub_names ; let fld_env = mk_fld_env sub_names flds' @@ -2133,14 +2133,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (l2l l) n)) + | otherwise = L l (IEName noExtField (L (l2l l) n)) where occ = occName n {- ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -558,7 +558,7 @@ rnPatAndThen _ (NPat x (L l lit) mb_neg _eq) ; return (NPat x (L l lit') mb_neg' eq') } rnPatAndThen mk (NPlusKPat _ rdr (L l lit) _ _ _ ) - = do { new_name <- newPatName mk (l2n rdr) + = do { new_name <- newPatName mk (la2la rdr) ; (lit', _) <- liftCpsFV $ rnOverLit lit -- See Note [Negative zero] -- We skip negateName as -- negative zero doesn't make ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -391,12 +391,12 @@ mkQuasiQuoteExpr :: UntypedSpliceFlavour -> Name mkQuasiQuoteExpr flavour quoter (L q_span' quote) = L q_span $ HsApp noComments (L q_span $ HsApp noComments (L q_span - (HsVar noExtField (L (la2na q_span) quote_selector))) + (HsVar noExtField (L (l2l q_span) quote_selector))) quoterExpr) quoteExpr where q_span = noAnnSrcSpan (locA q_span') - quoterExpr = L q_span $! HsVar noExtField $! (L (la2na q_span) quoter) + quoterExpr = L q_span $! HsVar noExtField $! (L (l2l q_span) quoter) quoteExpr = L q_span $! HsLit noComments $! HsString NoSourceText quote quote_selector = case flavour of UntypedExpSplice -> quoteExpName ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -1241,7 +1241,7 @@ dynCompileExpr expr = do parsed_expr <- parseExpr expr -- > Data.Dynamic.toDyn expr let loc = getLoc parsed_expr - to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (la2na loc) $ getRdrName toDynName) + to_dyn_expr = mkHsApp (L loc . HsVar noExtField . L (l2l loc) $ getRdrName toDynName) parsed_expr hval <- compileParsedExpr to_dyn_expr return (unsafeCoerce hval :: Dynamic) ===================================== compiler/GHC/Tc/Deriv/Generate.hs ===================================== @@ -2292,7 +2292,7 @@ mkFunBindSE arity loc fun pats_and_exprs mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBind fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches) + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches) -- | Make a function binding. If no equations are given, produce a function -- with the given arity that uses an empty case expression for the last @@ -2320,7 +2320,7 @@ mkRdrFunBindEC :: Arity -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- fmap _ z = case z of {} @@ -2344,7 +2344,7 @@ mkRdrFunBindEC arity catch_all fun@(L loc _fun_rdr) matches mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs mkRdrFunBindSE arity fun@(L loc fun_rdr) matches - = L (na2la loc) (mkFunBind (Generated SkipPmc) fun matches') + = L (l2l loc) (mkFunBind (Generated SkipPmc) fun matches') where -- Catch-all eqn looks like -- compare _ _ = error "Void compare" ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -710,7 +710,7 @@ lookupChildrenExport spec_parent rdr_items = mapAndReportM doOne rdr_items do { ub <- reportUnboundName unboundName ; let l = getLoc n gre = mkLocalGRE UnboundGRE NoParent ub - ; return (L l (IEName noExtField (L (la2na l) ub)), gre)} + ; return (L l (IEName noExtField (L (l2l l) ub)), gre)} FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) -> do { checkPatSynParent spec_parent par child_nm ; return (replaceLWrappedName n child_nm, child) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1542,7 +1542,7 @@ splitHsAppTys hs_ty 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) + = ( L (l2l sp) (HsTyVar noAnn prom op) , HsValArg l : HsValArg r : as ) go f as = (f, as) ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -195,7 +195,7 @@ tcClassDecl2 (L _ (ClassDecl {tcdLName = class_name, tcdSigs = sigs, tcdMeths = default_binds})) = recoverM (return emptyLHsBinds) $ setSrcSpan (getLocA class_name) $ - do { clas <- tcLookupLocatedClass (n2l class_name) + do { clas <- tcLookupLocatedClass (la2la class_name) -- We make a separate binding for each default method. -- At one time I used a single AbsBinds for all of them, thus @@ -281,7 +281,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn local_dm_ty = instantiateMethod clas global_dm_id (mkTyVarTys tyvars) - lm_bind = dm_bind { fun_id = L (la2na bind_loc) local_dm_name } + lm_bind = dm_bind { fun_id = L (l2l bind_loc) local_dm_name } -- Substitute the local_meth_name for the binder -- NB: the binding is always a FunBind ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -610,7 +610,7 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) -- itself, so we make do with the location of family name ; (co_ax_branch, co_ax_validity_info) <- tcTyFamInstEqn fam_tc mb_clsinfo - (L (na2la $ getLoc fam_lname) eqn) + (L (l2l $ getLoc fam_lname) eqn) -- (2) check for validity ; checkConsistentFamInst mb_clsinfo fam_tc co_ax_branch ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -943,7 +943,7 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) mk_mg :: LHsExpr GhcRn -> MatchGroup GhcRn (LHsExpr GhcRn) mk_mg body = mkMatchGroup (Generated SkipPmc) (noLocA [builder_match]) where - builder_args = [L (na2la loc) (VarPat noExtField (L loc n)) + builder_args = [L (l2l loc) (VarPat noExtField (L loc n)) | L loc n <- args] builder_match = mkMatch (mkPrefixFunRhs ps_lname) builder_args body ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b75ff8a88bbdd0d60032a4e304d37ec65526c06b +Subproject commit 2cbf7f0a55898e0c2827ae9ad13727b34877e793 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8217acb8afe883659cdf6e9ccf7a3d6f943f8082 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8217acb8afe883659cdf6e9ccf7a3d6f943f8082 You're receiving 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 Nov 7 07:22:35 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 07 Nov 2023 02:22:35 -0500 Subject: [Git][ghc/ghc][master] JS: remove broken newIdents from JStg Monad Message-ID: <6549e5bb7f66d_2baaec1b3fc008183289@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 2 changed files: - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs Changes: ===================================== compiler/GHC/JS/JStg/Monad.hs ===================================== @@ -40,7 +40,6 @@ module GHC.JS.JStg.Monad , JSM , withTag , newIdent - , newIdents , initJSM ) where @@ -95,19 +94,6 @@ newIdent = do env <- get mk_ident :: FastString -> Unique -> Ident mk_ident t i = global (mconcat [t, "_", mkFastString (show i)]) - - --- | A special case optimization over @newIdent at . Given a number of @Ident@ to --- generate, generate all of them at one time and update the state once rather --- than n times. -newIdents :: Int -> JSM [Ident] -newIdents 0 = return [] -newIdents n = do env <- get - let is = take n (uniqsFromSupply $ ids env) - tag = prefix env - return $ fmap (mk_ident tag) is - - -- | Set the tag for @Ident at s for all remaining computations. tag_names :: FastString -> JSM () tag_names tag = modify' (\env -> env {prefix = tag}) ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -149,6 +149,7 @@ import GHC.JS.JStg.Monad import GHC.JS.Transform import Control.Arrow ((***)) +import Control.Monad (replicateM) import Data.Tuple import qualified Data.Map as M @@ -325,7 +326,7 @@ jFunctionSized -> ([JStgExpr] -> JSM JStgStat) -- ^ function body, input is locally unique generated variables -> JSM JStgStat jFunctionSized name arity body = do - func_args <- newIdents arity + func_args <- replicateM arity newIdent FuncStat name func_args <$> (body $ toJExpr <$> func_args) -- | Construct a top-level function subject to JS hoisting. Special case where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dd88a26052bdef0dd4c00e1a4781ec3ef532c5db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dd88a26052bdef0dd4c00e1a4781ec3ef532c5db You're receiving 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 Nov 7 10:26:44 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 05:26:44 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] 3 commits: testsuite: add the req_process predicate Message-ID: <654a10e45678d_2baaec203535ac19029c@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 9f73ab09 by Cheng Shao at 2023-11-07T15:56:35+05:30 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. (cherry picked from commit ce580426ce3052e3b3d2847d0312652ea9087994) - - - - - 6612e3a1 by Zubin Duggal at 2023-11-07T15:56:35+05:30 testsuite: add omit_ghci for use in process - - - - - d5ce95b6 by Zubin Duggal at 2023-11-07T15:56:35+05:30 Prepare release 9.4.8 - - - - - 23 changed files: - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/th/T21547.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/T18406b.stderr - testsuite/tests/typecheck/should_compile/T18529.stderr - testsuite/tests/typecheck/should_compile/T21023.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). ===================================== testsuite/driver/testglobals.py ===================================== @@ -134,6 +134,8 @@ class TestConfig: # Do we have interpreter support? self.have_interp = False + # Do we even have processes? + self.have_process = True # Does the platform support loading of dynamic shared libraries? e.g. # some musl-based environments do not. self.supports_dynamic_libs = True ===================================== testsuite/driver/testlib.py ===================================== @@ -274,6 +274,9 @@ def req_smp( name, opts ): if not config.have_smp: opts.expect = 'fail' +def req_process( name, opts ): + if not config.have_process: + opts.skip = True def ignore_stdout(name, opts): opts.ignore_stdout = True @@ -389,6 +392,8 @@ def _omit_ways( name: TestName, opts, ways: List[WayName] ): _lint_ways(name, ways) opts.omit_ways += ways +omit_ghci = omit_ways([WayName('ghci'), WayName('ghci-opt')]) + # ----- def only_ways( ways: List[WayName] ): ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9EeElPXCwbT1H2r14ZWyw3-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-CEUpXjWCty3JAbUU0c8zyO-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-6LFEauuQzmN1lhf9BsFCch-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-4pSe9cqTgej5hWlpsCk6Gx-sublib-unused) ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {k2} {c :: k1} {j :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/th/T21547.stderr ===================================== @@ -1,7 +1,7 @@ T21547.hs:9:14: error: • GHC stage restriction: - instance for ‘base-4.17.2.0:Data.Typeable.Internal.Typeable + instance for ‘base-4.17.2.1:Data.Typeable.Internal.Typeable T’ is used in a top-level splice, quasi-quote, or annotation, and must be imported, not defined locally • In the expression: foo [|| T () ||] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/T18406b.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> a Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T18529.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> b -> () Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T21023.stderr ===================================== @@ -2,4 +2,4 @@ TYPE SIGNATURES f :: forall {a}. a -> (a, Integer) x :: Integer Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89949c9f7bf79d2af47dc534201f0b0be9605949...d5ce95b66544896384e506370a3e1b64d3caba88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89949c9f7bf79d2af47dc534201f0b0be9605949...d5ce95b66544896384e506370a3e1b64d3caba88 You're receiving 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 Nov 7 10:57:52 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 05:57:52 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] Prepare release 9.4.8 Message-ID: <654a1830d21ff_2baaec20c0c464190763@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: b13143c2 by Zubin Duggal at 2023-11-07T16:27:43+05:30 Prepare release 9.4.8 - - - - - 22 changed files: - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/printer/T18052a.stderr - testsuite/tests/th/T21547.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/T18406b.stderr - testsuite/tests/typecheck/should_compile/T18529.stderr - testsuite/tests/typecheck/should_compile/T21023.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9EeElPXCwbT1H2r14ZWyw3-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-CEUpXjWCty3JAbUU0c8zyO-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-6LFEauuQzmN1lhf9BsFCch-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-4pSe9cqTgej5hWlpsCk6Gx-sublib-unused) ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {k2} {c :: k1} {j :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/th/T21547.stderr ===================================== @@ -1,7 +1,7 @@ T21547.hs:9:14: error: • GHC stage restriction: - instance for ‘base-4.17.2.0:Data.Typeable.Internal.Typeable + instance for ‘base-4.17.2.1:Data.Typeable.Internal.Typeable T’ is used in a top-level splice, quasi-quote, or annotation, and must be imported, not defined locally • In the expression: foo [|| T () ||] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/T18406b.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> a Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T18529.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> b -> () Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T21023.stderr ===================================== @@ -2,4 +2,4 @@ TYPE SIGNATURES f :: forall {a}. a -> (a, Integer) x :: Integer Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13143c2ce6e4093df60b8d4317383759bd65f1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13143c2ce6e4093df60b8d4317383759bd65f1b You're receiving 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 Nov 7 10:58:29 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 05:58:29 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] 20 commits: driver: Check transitive closure of haskell package dependencies when deciding whether to relink Message-ID: <654a1855ed49d_2baaec20c0c4641911af@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 89b0c2bc by Matthew Pickering at 2023-11-07T16:28:12+05:30 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 (cherry picked from commit 291d81aef8083290da0d2ce430fbc5e5a33bdb6e) - - - - - adf9c778 by Andreas Klebinger at 2023-11-07T16:28:12+05:30 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 (cherry picked from commit e5c00092a13f1a8cf53df2469e027012743cf59a) - - - - - 76fd8599 by Andreas Klebinger at 2023-11-07T16:28:12+05:30 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 0447ecaa by Ben Gamari at 2023-11-07T16:28:12+05:30 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. (cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496) - - - - - 8e7a2065 by Moritz Angermann at 2023-11-07T16:28:12+05:30 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. (cherry picked from commit dafc47091c9107dcf81e1e80a105f59211927c89) - - - - - fdc5f65d by Moritz Angermann at 2023-11-07T16:28:12+05:30 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. (cherry picked from commit df81536f2e53abf521a05eb1e482a076f5849c21) - - - - - b2a03315 by Ilias Tsitsimpis at 2023-11-07T16:28:12+05:30 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 (cherry picked from commit 257c2807587624592813a42e06a05c5fc34cb38c) - - - - - 0af2b8ef by Moritz Angermann at 2023-11-07T16:28:12+05:30 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. (cherry picked from commit 34f06334025521c2440ebedb0237697fbcc3c6de) - - - - - 9227c6df by Ben Gamari at 2023-11-07T16:28:12+05:30 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. (cherry picked from commit 3ece9856d157c85511d59f9f862ab351bbd9b38b) - - - - - 689f04e7 by Ben Gamari at 2023-11-07T16:28:12+05:30 nativeGen: Set explicit section types on all platforms (cherry picked from commit db7f7240b53c01447e44d2790ee37eacaabfbcf3) - - - - - 76240051 by Moritz Angermann at 2023-11-07T16:28:12+05:30 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ (cherry picked from commit e99cf237f84db34be0468a893b10394d6b364bce) - - - - - 89cc99fc by Matthew Craven at 2023-11-07T16:28:12+05:30 Bump bytestring submodule to 0.11.5.3 (cherry picked from commit 97a187bfd713663fccb8bc4f4f0c92792547f9c2) - - - - - 68bebf3e by Zubin Duggal at 2023-11-07T16:28:12+05:30 Bump process submodule to 1.6.18.0 - - - - - adc0996f by Matthew Pickering at 2023-11-07T16:28:12+05:30 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) - - - - - d2dd0db2 by Matthew Pickering at 2023-11-07T16:28:12+05:30 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) - - - - - 66987a9b by Cheng Shao at 2023-11-07T16:28:12+05:30 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. (cherry picked from commit ce580426ce3052e3b3d2847d0312652ea9087994) - - - - - 72619e9a by Zubin Duggal at 2023-11-07T16:28:12+05:30 testsuite: add omit_ghci for use in process - - - - - 3e6b6c24 by Simon Peyton Jones at 2023-11-07T16:28:12+05:30 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. (cherry picked from commit 6840012e5bb8f5c13e4bf7a4e4cbba0b06420aaa) - - - - - b26db194 by Sylvain Henry at 2023-11-07T16:28:12+05:30 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 (cherry picked from commit 5126a2fef0385e206643b6af0543d10ff0c219d8) - - - - - 95e59db7 by Zubin Duggal at 2023-11-07T16:28:12+05:30 Prepare release 9.4.8 - - - - - 30 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/StgToCmm/CgUtils.hs - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - + hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - hadrian/src/Settings/Packages.hs - libraries/base/GHC/Float.hs - libraries/base/base.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b13143c2ce6e4093df60b8d4317383759bd65f1b...95e59db73eaa8a555dfc17610311b13fa784217a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b13143c2ce6e4093df60b8d4317383759bd65f1b...95e59db73eaa8a555dfc17610311b13fa784217a You're receiving 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 Nov 7 11:41:48 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 06:41:48 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] 3 commits: Add missing int64/word64-to-double/float rules (#23907) Message-ID: <654a227cee41a_2baaec22071d28193091@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 0d758dc3 by Sylvain Henry at 2023-11-07T17:11:37+05:30 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 (cherry picked from commit 5126a2fef0385e206643b6af0543d10ff0c219d8) - - - - - 9c4e994b by Simon Peyton Jones at 2023-11-07T17:11:37+05:30 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. (cherry picked from commit 6840012e5bb8f5c13e4bf7a4e4cbba0b06420aaa) - - - - - 002b54bf by Zubin Duggal at 2023-11-07T17:11:37+05:30 Prepare release 9.4.8 - - - - - 29 changed files: - compiler/GHC/Core/Utils.hs - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - libraries/base/GHC/Float.hs - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - + testsuite/tests/numeric/should_compile/T23907.hs - + testsuite/tests/numeric/should_compile/T23907.stderr - testsuite/tests/numeric/should_compile/all.T - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/printer/T18052a.stderr - + testsuite/tests/simplCore/should_compile/T23922a.hs - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/th/T21547.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/T18406b.stderr - testsuite/tests/typecheck/should_compile/T18529.stderr - testsuite/tests/typecheck/should_compile/T21023.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr Changes: ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2464,17 +2464,22 @@ tryEtaReduce rec_ids bndrs body ok_fun (App fun (Type {})) = ok_fun fun ok_fun (Cast fun _) = ok_fun fun ok_fun (Tick _ expr) = ok_fun expr - ok_fun (Var fun_id) = ok_fun_id fun_id || all ok_lam bndrs + ok_fun (Var fun_id) = ok_fun_id fun_id ok_fun _fun = False --------------- - ok_fun_id fun = - -- Don't eta-reduce in fun in its own recursive RHSs - not (fun `elemUnVarSet` rec_ids) && -- criterion (R) - -- There are arguments to reduce... - fun_arity fun >= incoming_arity && - -- ... and the function can be eta reduced to arity 0 - canEtaReduceToArity fun 0 0 + ok_fun_id fun + | fun `elemUnVarSet` rec_ids -- Criterion (R) + = False -- Don't eta-reduce in fun in its own recursive RHSs + + | canEtaReduceToArity fun 0 0 -- Criteria (L), (J), (W), (B) + = False -- Function can't be eta reduced to arity 0 + -- without violating invariants of Core and GHC + | otherwise + = -- Check that eta-reduction won't make the program stricter... + fun_arity fun >= incoming_arity -- Criterion (A) and (E) + || all ok_lam bndrs -- Criterion (T) + --------------- fun_arity fun -- See Note [Arity care] | arity > 0 = arity ===================================== 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/GHC/Float.hs ===================================== @@ -1613,3 +1613,22 @@ foreign import prim "stg_doubleToWord64zh" "Word# -> Natural -> Double#" forall x. naturalToDouble# (NS x) = word2Double# x #-} + +-- We don't have word64ToFloat/word64ToDouble primops (#23908), only +-- word2Float/word2Double, so we can only perform these transformations when +-- word-size is 64-bit. +#if WORD_SIZE_IN_BITS == 64 +{-# RULES + +"Int64# -> Integer -> Float#" + forall x. integerToFloat# (integerFromInt64# x) = int2Float# (int64ToInt# x) + +"Int64# -> Integer -> Double#" + forall x. integerToDouble# (integerFromInt64# x) = int2Double# (int64ToInt# x) + +"Word64# -> Integer -> Float#" + forall x. integerToFloat# (integerFromWord64# x) = word2Float# (word64ToWord# x) + +"Word64# -> Integer -> Double#" + forall x. integerToDouble# (integerFromWord64# x) = word2Double# (word64ToWord# x) #-} +#endif ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9EeElPXCwbT1H2r14ZWyw3-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-CEUpXjWCty3JAbUU0c8zyO-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-6LFEauuQzmN1lhf9BsFCch-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-4pSe9cqTgej5hWlpsCk6Gx-sublib-unused) ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {k2} {c :: k1} {j :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/numeric/should_compile/T23907.hs ===================================== @@ -0,0 +1,67 @@ +module T23907 (loop) where + +import Data.Word +import Data.Bits + +{-# NOINLINE loop #-} +loop :: Int -> Double -> SMGen -> (Double, SMGen) +loop 0 !a !s = (a, s) +loop n !a !s = loop (n - 1) (a + b) t where (b, t) = nextDouble s + +mix64 :: Word64 -> Word64 +mix64 z0 = + -- MurmurHash3Mixer + let z1 = shiftXorMultiply 33 0xff51afd7ed558ccd z0 + z2 = shiftXorMultiply 33 0xc4ceb9fe1a85ec53 z1 + z3 = shiftXor 33 z2 + in z3 + +shiftXor :: Int -> Word64 -> Word64 +shiftXor n w = w `xor` (w `shiftR` n) + +shiftXorMultiply :: Int -> Word64 -> Word64 -> Word64 +shiftXorMultiply n k w = shiftXor n w * k + +nextWord64 :: SMGen -> (Word64, SMGen) +nextWord64 (SMGen seed gamma) = (mix64 seed', SMGen seed' gamma) + where + seed' = seed + gamma + +nextDouble :: SMGen -> (Double, SMGen) +nextDouble g = case nextWord64 g of + (w64, g') -> (fromIntegral (w64 `shiftR` 11) * doubleUlp, g') + +data SMGen = SMGen !Word64 !Word64 -- seed and gamma; gamma is odd + +mkSMGen :: Word64 -> SMGen +mkSMGen s = SMGen (mix64 s) (mixGamma (s + goldenGamma)) + +goldenGamma :: Word64 +goldenGamma = 0x9e3779b97f4a7c15 + +floatUlp :: Float +floatUlp = 1.0 / fromIntegral (1 `shiftL` 24 :: Word32) + +doubleUlp :: Double +doubleUlp = 1.0 / fromIntegral (1 `shiftL` 53 :: Word64) + +mix64variant13 :: Word64 -> Word64 +mix64variant13 z0 = + -- Better Bit Mixing - Improving on MurmurHash3's 64-bit Finalizer + -- http://zimbry.blogspot.fi/2011/09/better-bit-mixing-improving-on.html + -- + -- Stafford's Mix13 + let z1 = shiftXorMultiply 30 0xbf58476d1ce4e5b9 z0 -- MurmurHash3 mix constants + z2 = shiftXorMultiply 27 0x94d049bb133111eb z1 + z3 = shiftXor 31 z2 + in z3 + +mixGamma :: Word64 -> Word64 +mixGamma z0 = + let z1 = mix64variant13 z0 .|. 1 -- force to be odd + n = popCount (z1 `xor` (z1 `shiftR` 1)) + -- see: http://www.pcg-random.org/posts/bugs-in-splitmix.html + -- let's trust the text of the paper, not the code. + in if n >= 24 + then z1 + else z1 `xor` 0xaaaaaaaaaaaaaaaa ===================================== testsuite/tests/numeric/should_compile/T23907.stderr ===================================== @@ -0,0 +1,57 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 90, types: 62, coercions: 0, joins: 0/3} + +$WSMGen + = \ conrep conrep -> + case conrep of { W64# unbx -> + case conrep of { W64# unbx -> SMGen unbx unbx } + } + +Rec { +$wloop + = \ ww ww1 ww2 ww3 -> + case ww of ds { + __DEFAULT -> + let { seed' = plusWord64# ww2 ww3 } in + let { + x# + = timesWord64# + (xor64# seed' (uncheckedShiftRL64# seed' 33#)) + 18397679294719823053##64 } in + let { + x#1 + = timesWord64# + (xor64# x# (uncheckedShiftRL64# x# 33#)) + 14181476777654086739##64 } in + $wloop + (-# ds 1#) + (+## + ww1 + (*## + (word2Double# + (word64ToWord# + (uncheckedShiftRL64# + (xor64# x#1 (uncheckedShiftRL64# x#1 33#)) 11#))) + 1.1102230246251565e-16##)) + seed' + ww3; + 0# -> (# ww1, ww2, ww3 #) + } +end Rec } + +loop + = \ ds a s -> + case ds of { I# ww -> + case a of { D# ww1 -> + case s of { SMGen ww2 ww3 -> + case $wloop ww ww1 ww2 ww3 of { (# ww4, ww5, ww6 #) -> + (D# ww4, SMGen ww5 ww6) + } + } + } + } + + + ===================================== testsuite/tests/numeric/should_compile/all.T ===================================== @@ -20,3 +20,4 @@ test('T20448', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-b test('T19641', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) test('T15547', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) test('T23019', normal, compile, ['-O']) +test('T23907', [ when(wordsize(32), expect_broken(23908))], compile, ['-ddump-simpl -O2 -dsuppress-all -dno-typeable-binds -dsuppress-uniques']) ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/simplCore/should_compile/T23922a.hs ===================================== @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -O -fworker-wrapper-cbv -dcore-lint -Wno-simplifiable-class-constraints #-} +{-# LANGUAGE ScopedTypeVariables #-} + +-- It is very tricky to tickle this bug in 9.6/9.8! +-- (It came up in a complicated program due to Mikolaj.) +-- +-- We need a join point, with only dictionary arguments +-- whose RHS is just another join-point application, which +-- can be eta-reduced. +-- +-- The -fworker-wrapper-cbv makes a wrapper whose RHS looks eta-reducible. + +module T23922a where + +f :: forall a. Eq a => [a] -> Bool +f x = let {-# NOINLINE j #-} + j :: Eq [a] => Bool + j = x==x + in j ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -403,3 +403,4 @@ test('T23012', normal, compile, ['-O']) test('T21391', normal, compile, ['-O -dcore-lint']) test('T21391a', normal, compile, ['-O -dcore-lint']) test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) +test('T23922a', normal, compile, ['-O']) ===================================== testsuite/tests/th/T21547.stderr ===================================== @@ -1,7 +1,7 @@ T21547.hs:9:14: error: • GHC stage restriction: - instance for ‘base-4.17.2.0:Data.Typeable.Internal.Typeable + instance for ‘base-4.17.2.1:Data.Typeable.Internal.Typeable T’ is used in a top-level splice, quasi-quote, or annotation, and must be imported, not defined locally • In the expression: foo [|| T () ||] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/T18406b.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> a Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T18529.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> b -> () Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T21023.stderr ===================================== @@ -2,4 +2,4 @@ TYPE SIGNATURES f :: forall {a}. a -> (a, Integer) x :: Integer Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95e59db73eaa8a555dfc17610311b13fa784217a...002b54bf0fc660827ff9ab6a4e5c51c0135f814f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95e59db73eaa8a555dfc17610311b13fa784217a...002b54bf0fc660827ff9ab6a4e5c51c0135f814f You're receiving 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 Nov 7 11:42:10 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 Nov 2023 06:42:10 -0500 Subject: [Git][ghc/ghc][wip/andreask/unpack_unboxed_tuples] 1499 commits: hadrian: add hi_core flavour transformer Message-ID: <654a22926b588_2baaec22071d2819356b@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/unpack_unboxed_tuples at Glasgow Haskell Compiler / GHC Commits: 1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add hi_core flavour transformer The hi_core flavour transformer enables -fwrite-if-simplified-core for stage1 libraries, which emit core into interface files to make it possible to restart code generation. Building boot libs with it makes it easier to use GHC API to prototype experimental backends that needs core/stg at link time. - - - - - 317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add missing docs for recently added flavour transformers - - - - - 658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00 gitlab-ci: Add Rocky8 jobs Addresses #22268. - - - - - a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00 Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture These flags did not make it into the 9.6 release series, so the "since" annotations must be corrected. - - - - - fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00 EPA: Add SourceText to HsOverLabel To be able to capture string literals with possible escape codes as labels. Close #22771 - - - - - 3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00 template-haskell: Bump version to 2.20.0.0 Updates `text` and `exceptions` submodules for bounds bumps. Addresses #22767. - - - - - 0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00 hadrian: disable alloca for in-tree GMP on wasm32 When building in-tree GMP for wasm32, disable its alloca usage, since it may potentially cause stack overflow (e.g. #22602). - - - - - db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00 Bump process submodule Includes a critical fix for wasm32, see https://github.com/haskell/process/pull/272 for details. Also changes the existing cross test to include process stuff and avoid future regression here. - - - - - 9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Fix subdir for windows bindist - - - - - 9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Remove viPostRemove field from generated metadata This has been removed from the downstream metadata. - - - - - 82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00 Fix #22742 runtimeRepLevity_maybe was panicing unnecessarily; and the error printing code made use of the case when it should return Nothing rather than panicing. For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime peak-megagbytes-used, on a single architecture (alpine). See !9753 for commentary, but I'm going to accept it. Metric Increase: T21839r - - - - - 2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00 codeowners: Add Ben, Matt, and Bryan to CI - - - - - eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00 Do not collect compile-time metrics for T21839r ...the testsuite doesn't handle this properly since it also collects run-time metrics. Compile-time metrics for this test are already tracked via T21839c. Metric Decrease: T21839r - - - - - 1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00 Fix recompilation checking for multiple home units The key part of this change is to store a UnitId in the `UsageHomeModule` and `UsageHomeModuleInterface`. * Fine-grained dependency tracking is used if the dependency comes from any home unit. * We actually look up the right module when checking whether we need to recompile in the `UsageHomeModuleInterface` case. These scenarios are both checked by the new tests ( multipleHomeUnits_recomp and multipleHomeUnits_recomp_th ) Fixes #22675 - - - - - 7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Augment target filepath by working directory when checking if module satisfies target This fixes a spurious warning in -Wmissing-home-modules. This is a simple oversight where when looking for the target in the first place we augment the search by the -working-directory flag but then fail to do so when checking this warning. Fixes #22676 - - - - - 69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Use NodeKey rather than ModuleName in pruneCache The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true: * In normal compilation, the same module name can appear for a file and it's boot file. * In multiple home unit compilation the same ModuleName can appear in different units The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`. Fixes #22677 - - - - - 336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo In interactive mode we don't produce any linkables for hs-boot files. So we also need to not going looking for them when we check to see if we have all the right objects needed for recompilation. Ticket #22669 - - - - - 6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Don't write o-boot files in Interactive mode We should not be producing object files when in interactive mode but we still produced the dummy o-boot files. These never made it into a `Linkable` but then confused the recompilation checker. Fixes #22669 - - - - - 06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Improve driver diagnostic messages by including UnitId in message Currently the driver diagnostics don't give any indication about which unit they correspond to. For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about. Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message. Fixes #22678 - - - - - 4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00 Key ModSummary cache by UnitId as well as FilePath Multiple units can refer to the same files without any problem. Just another assumption which needs to be updated when we may have multiple home units. However, there is the invariant that within each unit each file only maps to one module, so as long as we also key the cache by UnitId then we are all good. This led to some confusing behaviour in GHCi when reloading, multipleHomeUnits_shared distils the essence of what can go wrong. Fixes #22679 - - - - - ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Finder: Look in current unit before looking in any home package dependencies In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component. This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around. Fixes #22680 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp -------------------------p - - - - - be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Debug: Print full NodeKey when pretty printing ModuleGraphNode This is helpful when debugging multiple component issues. - - - - - 34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00 Fix Lint check for duplicate external names Lint was checking for duplicate external names by calling removeDups, which needs a comparison function that is passed to Data.List.sortBy. But the comparison was not a valid ordering - it returned LT if one of the names was not external. For example, the previous implementation won't find a duplicate in [M.x, y, M.x]. Instead, we filter out non-external names before looking for duplicates. - - - - - 1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00 Add test for T22671 This was fixed by b13c6ea5 Closes #22671 - - - - - 05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00 Clarify where `f` is defined - - - - - d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00 CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target We used to print the offset value to a platform word sized integer. This is incorrect when the offset is negative (e.g. output of cmm constant folding) and the register is 64-bit but on a 32-bit target, and may lead to incorrect runtime result (e.g. #22607). The fix is simple: just treat it as a proper MO_Add, with the correct width info inferred from the register itself. Metric Increase: T12707 T13379 T4801 T5321FD T5321Fun - - - - - e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00 Allow waiting for timerfd to be interrupted during rts shutdown - - - - - 1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00 Restore Compose's Read/Show behavior to match Read1/Show1 instances Fixes #22816. - - - - - 30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00 docs: Update INSTALL.md Removes references to make. Fixes #22480 - - - - - bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00 compiler: fix handling of MO_F_Neg in wasm NCG In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an oversight, there actually exists f32.neg/f64.neg opcodes in the wasm spec and those should be used instead! The old behavior almost works, expect when GHC compiles the -0.0 literal, which will incorrectly become 0.0. - - - - - e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: correctly detect AR at-file support Stage0's ar may not support at-files. Take it into account. Found while cross-compiling from Darwin to Windows. - - - - - 48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: fix Windows cross-compilation Decision to build either unix or Win32 package must be stage specific for cross-compilation to be supported. - - - - - 288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Fix RTS build on Windows This change fixes a cross-compilation issue from ArchLinux to Windows because these symbols weren't found. - - - - - 2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00 configure: support "windows" as an OS - - - - - 13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00 Fix in-scope set in specImports Nothing deep here; I had failed to bring some floated dictionary binders into scope. Exposed by -fspecialise-aggressively Fixes #22715. - - - - - b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00 ci: Disable HLint job due to excessive runtime The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91 Now the CI job will build the stage0 compiler before it generates the necessary RTS headers. We either need to: * Fix the linting rules so they take much less time * Revert the commit * Remove the linting of base from the hlint job * Remove the hlint job This is highest priority as it is affecting all CI pipelines. For now I am just disabling the job because there are many more pressing matters at hand. Ticket #22830 - - - - - 1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00 Factorize hptModulesBelow Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that doesn't need anything from the driver to be used. - - - - - 1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Store dehydrated data structures in CgModBreaks This fixes a tricky leak in GHCi where we were retaining old copies of HscEnvs when reloading. If not all modules were recompiled then these hydrated fields in break points would retain a reference to the old HscEnv which could double memory usage. Fixes #22530 - - - - - e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force more in NFData Name instance Doesn't force the lazy `OccName` field (#19619) which is already known as a really bad source of leaks. When we slam the hammer storing Names on disk (in interface files or the like), all this should be forced as otherwise a `Name` can easily retain an `Id` and hence the entire world. Fixes #22833 - - - - - 3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force OccName in tidyTopName This occname has just been derived from an `Id`, so need to force it promptly so we can release the Id back to the world. Another symptom of the bug caused by #19619 - - - - - f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Strict fields in ModNodeKey (otherwise retains HomeModInfo) Towards #22530 - - - - - 5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00 Hadrian: fix doc generation Was missing dependencies on files generated by templates (e.g. ghc.cabal) - - - - - 3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. Close #22519. - - - - - b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00 tryFillBuffer: strictify more speculative bangs - - - - - d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00 base: NoImplicitPrelude in Data.Void and Data.Kind This change removes an unnecessary dependency on Prelude from two modules in the base package. - - - - - fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00 ci: Add ubuntu18_04 nightly and release jobs This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is older than the 2.28 which is used by Rocky8 bindists. Ticket #22268 - - - - - 807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00 rel-eng: Add missing rocky8 bindist We intend to release rocky8 bindist so the fetching script needs to know about them. - - - - - c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00 base: Make changelog proposal references more consistent Addresses #22773. - - - - - 6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00 Fix spurious change from !9568 - - - - - e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00 rts: Use C11-compliant static assertion syntax Previously we used `static_assert` which is only available in C23. By contrast, C11 only provides `_Static_assert`. Fixes #22777 - - - - - 2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00 Replace errors from badOrigBinding with new one (#22839) Problem: in 02279a9c the type-level [] syntax was changed from a built-in name to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if a name is not built-in then it must have come from TH quotation, but this is not necessarily the case with []. The outdated assumption in badOrigBinding leads to incorrect error messages. This code: data [] Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []" Unfortunately, there is not enough information in RdrName to directly determine if the name was constructed via TH or by the parser, so this patch changes the error message instead. It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote into a new error TcRnBindingOfExistingName and changes its wording to avoid guessing the origin of the name. - - - - - 545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00 Revert "base: NoImplicitPrelude in Data.Void and Data.Kind" Fixes CI errors of the form. ``` ===> Command failed with error code: 1 ghc: panic! (the 'impossible' happened) GHC version 9.7.20230127: lookupGlobal Failed to load interface for ‘GHC.Num.BigNat’ There are files missing in the ‘ghc-bignum’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd. The module now lacks a dependency on GHC.Num.BigNat which it implicitly depends on. It is causing all CI jobs to fail so we revert without haste whilst the patch can be fixed. Fixes #22848 - - - - - 638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Detect family instance orphans correctly We were treating a type-family instance as a non-orphan if there was a type constructor on its /right-hand side/ that was local. Boo! Utterly wrong. With this patch, we correctly check the /left-hand side/ instead! Fixes #22717 - - - - - 46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Report family instance orphans correctly This fixes the fact that we were not reporting orphan family instances at all. The fix here is easy, but touches a bit of code. I refactored the code to be much more similar to the way that class instances are done: - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst - Make newFamInst initialise this field, just like newClsInst - And make newFamInst report a warning for an orphan, just like newClsInst - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate, just like newClsInst. - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised over class instances vs type/data family instances. Fixes #19773 - - - - - faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in STG This patch removes some orphan instances in the STG namespace by introducing the GHC.Stg.Lift.Types module, which allows various type family instances to be moved to GHC.Stg.Syntax, avoiding orphan instances. - - - - - 0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in the parser This moves Anno instances for PatBuilder from GHC.Parser.PostProcess to GHC.Parser.Types to avoid orphans. - - - - - 15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Accept an orphan declaration (sadly) This accepts the orphan type family instance type instance DsForeignHook = ... in GHC.HsToCore.Types. See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks - - - - - c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00 bindist configure: Fail if find not found (#22691) - - - - - ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00 Put hadrian bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. - - - - - d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Introduce threaded2_sanity way Incredibly, we previously did not have a single way which would test the threaded RTS with multiple capabilities and the sanity-checker enabled. - - - - - 38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00 rts: Relax Messages assertion `doneWithMsgThrowTo` was previously too strict in asserting that the `Message` is locked. Specifically, it failed to consider that the `Message` may not be locked if we are deleting all threads during RTS shutdown. - - - - - a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Fix race in UnliftedTVar2 Previously UnliftedTVar2 would fail when run with multiple capabilities (and possibly even with one capability) as it would assume that `killThread#` would immediately kill the "increment" thread. Also, refactor the the executable to now succeed with no output and fails with an exit code. - - - - - 8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Make listThreads more robust Previously it was sensitive to the labels of threads which it did not create (e.g. the IO manager event loop threads). Fix this. - - - - - 55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix C++ compilation issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Drop long-dead fallback definitions for INFINITY & NAN These are no longer necessary since we now compile as C99. - - - - - 56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00 Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)" This reverts commit 99aca26b652603bc62953157a48e419f737d352d. - - - - - b3a3534b by nineonine at 2023-01-28T02:57:59-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types 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. - - - - - 082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00 Add Foldable1 Solo instance - - - - - 50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00 Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind module. Instead, these TcRnMessage messages were introduced: TcRnMultipleFixityDecls TcRnIllegalPatternSynonymDecl TcRnIllegalClassBiding TcRnOrphanCompletePragma TcRnEmptyCase TcRnNonStdGuards TcRnDuplicateSigDecl TcRnMisplacedSigDecl TcRnUnexpectedDefaultSig TcRnBindInBootFile TcRnDuplicateMinimalSig - - - - - 3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00 hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files Previously we were just throwing away the contents of the library-dirs fields but really we have to do the same thing as for include-dirs, relativise the paths into the current working directory and maintain any extra libraries the user has specified. Now the relevant section of the rts.conf file looks like: ``` library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib library-dirs-static: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib dynamic-library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib ``` Fixes #22209 - - - - - c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00 Document differences between Data.{Monoid,Semigroup}.{First,Last} - - - - - 7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00 compiler: fix subword literal narrowing logic in the wasm NCG This patch fixes the W8/W16 literal narrowing logic in the wasm NCG, which used to lower it to something like i32.const -1, without properly zeroing-out the unused higher bits. Fixes #22608. - - - - - 6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00 compiler: fix lowering of CmmBlock in the wasm NCG The CmmBlock datacon was not handled in lower_CmmLit, since I thought it would have been eliminated after proc-point splitting. Turns out it still occurs in very rare occasions, and this patch is needed to fix T9329 for wasm. - - - - - 2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00 Assorted changes to avoid Data.List.{head,tail} - - - - - 78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00 compiler: properly handle ForeignHints in the wasm NCG Properly handle ForeignHints of ccall arguments/return value, insert sign extends and truncations when handling signed subwords. Fixes #22852. - - - - - 8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00 nativeGen: Disable asm-shortcutting on Darwin Asm-shortcutting may produce relative references to symbols defined in other compilation units. This is not something that MachO relocations support (see #21972). For this reason we disable the optimisation on Darwin. We do so without a warning since this flag is enabled by `-O2`. Another way to address this issue would be to rather implement a PLT-relocatable jump-table strategy. However, this would only benefit Darwin and does not seem worth the effort. Closes #21972. - - - - - da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00 compiler: fix data section alignment in the wasm NCG Previously we tried to lower the alignment requirement as far as possible, based on the section kind inferred from the CLabel. For info tables, .p2align 1 was applied given the GC should only need the lowest bit to tag forwarding pointers. But this would lead to unaligned loads/stores, which has a performance penalty even if the wasm spec permits it. Furthermore, the test suite has shown memory corruption in a few cases when compacting gc is used. This patch takes a more conservative approach: all data sections except C strings align to word size. - - - - - 08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00 ghc-the-library: Retain cafs in both static in dynamic builds. We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a __attribute__((constructor)) function. This broke for static builds where the linker discarded the object file since it was not reverenced from any exported code. We fix this by asserting that the flag is enabled using a function in the same module as the constructor. Which causes the object file to be retained by the linker, which in turn causes the constructor the be run in static builds. This changes nothing for dynamic builds using the ghc library. But causes static to also retain CAFs (as we expect them to). Fixes #22417. ------------------------- Metric Decrease: T21839r ------------------------- - - - - - 20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00 Handle `type data` properly in tyThingParent_maybe Unlike most other data constructors, data constructors declared with `type data` are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon` case in `tyThingParent_maybe` previously did not consider the possibility of the underlying `TyCon` being a promoted data constructor, which led to the oddities observed in #22817. This patch adds a dedicated special case in `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix these oddities. Fixes #22817. - - - - - 2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00 Fix two bugs in TypeData TH reification This patch fixes two issues in the way that `type data` declarations were reified with Template Haskell: * `type data` data constructors are now properly reified using `DataConI`. This is accomplished with a special case in `reifyTyCon`. Fixes #22818. * `type data` type constructors are now reified in `reifyTyCon` using `TypeDataD` instead of `DataD`. Fixes #22819. - - - - - d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00 Take account of loop breakers in specLookupRule The key change is that in GHC.Core.Opt.Specialise.specLookupRule we were using realIdUnfolding, which ignores the loop-breaker flag. When given a loop breaker, rule matching therefore looped infinitely -- #22802. In fixing this I refactored a bit. * Define GHC.Core.InScopeEnv as a data type, and use it. (Previously it was a pair: hard to grep for.) * Put several functions returning an IdUnfoldingFun into GHC.Types.Id, namely idUnfolding alwaysActiveUnfoldingFun, whenActiveUnfoldingFun, noUnfoldingFun and use them. (The are all loop-breaker aware.) - - - - - de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00 ci: Remove FreeBSD job from release pipelines We no longer attempt to build or distribute this release - - - - - f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab This check makes sure that if a job is a prefixed by "release-" then the script downloads it and understands how to map the job name to the platform. - - - - - 7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Fix the name of the ubuntu-* jobs These were not uploaded for alpha1 Fixes #22844 - - - - - 68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00 gen_ci: Only consider release jobs for job metadata In particular we do not have a release job for FreeBSD so the generation of the platform mapping was failing. - - - - - b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00 User's guide: Clarify overlapping instance candidate elimination This commit updates the user's guide section on overlapping instance candidate elimination to use "or" verbiage instead of "either/or" in regards to the current pair of candidates' being overlappable or overlapping. "Either IX is overlappable, or IY is overlapping" can cause confusion as it suggests "Either IX is overlappable, or IY is overlapping, but not both". This was initially discussed on this Discourse topic: https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677 - - - - - 7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00 Fixes for cabal-reinstall CI job * Allow filepath to be reinstalled * Bump some version bounds to allow newer versions of libraries * Rework testing logic to avoid "install --lib" and package env files Fixes #22344 - - - - - fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00 rts: prevent potential divide-by-zero when tickInterval=0 This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603. - - - - - 085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00 Update note at beginning of GHC.Builtin.NAmes some things have been renamed since it was written, it seems. - - - - - 7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00 testsuite: use tgamma for cg007 gamma is a glibc-only deprecated function, use tgamma instead. It's required for fixing cg007 when testing the wasm unregisterised codegen. - - - - - 19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00 InfoTableProv: ShortText --> ShortByteString - - - - - 765fab98 by doyougnu at 2023-01-31T13:08:03-05:00 FastString: add fastStringToShorText - - - - - a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00 Improve exprOkForSpeculation for classops This patch fixes #22745 and #15205, which are about GHC's failure to discard unnecessary superclass selections that yield coercions. See GHC.Core.Utils Note [exprOkForSpeculation and type classes] The main changes are: * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it * Define new function isTerminatingType, to identify those guaranteed-terminating dictionary types. * exprOkForSpeculation has a new (very simple) case for ClassOpId * ClassOpId has a new field that says if the return type is an unlifted type, or a terminating type. This was surprisingly tricky to get right. In particular note that unlifted types are not terminating types; you can write an expression of unlifted type, that diverges. Not so for dictionaries (or, more precisely, for the dictionaries that GHC constructs). Metric Decrease: LargeRecord - - - - - f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00 Support "unusable UNPACK pragma" warning with -O0 Fixes #11270 - - - - - a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00 configure: Always create the VERSION file Teach the `configure` script to create the `VERSION` file. This will serve as the stable interface to allow the user to determine the version number of a working tree. Fixes #22322. - - - - - 5618fc21 by sheaf at 2023-01-31T15:51:06-05:00 Cmm: track the type of global registers This patch tracks the type of Cmm global registers. This is needed in order to lint uses of polymorphic registers, such as SIMD vector registers that can be used both for floating-point and integer values. This changes allows us to refactor VanillaReg to not store VGcPtr, as that information is instead stored in the type of the usage of the register. Fixes #22297 - - - - - 78b99430 by sheaf at 2023-01-31T15:51:06-05:00 Revert "Cmm Lint: relax SIMD register assignment check" This reverts commit 3be48877, which weakened a Cmm Lint check involving SIMD vectors. Now that we keep track of the type a global register is used at, we can restore the original stronger check. - - - - - be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix debugging output Previously various panics would rely on a half-written Show instance, leading to very unhelpful errors. Fix this. See #22798. - - - - - 30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen: Teach graph-colouring allocator that x18 is unusable Previously trivColourable for AArch64 claimed that at 18 registers were trivially-colourable. This is incorrect as x18 is reserved by the platform on AArch64/Darwin. See #22798. - - - - - 7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix graph-colouring allocator Previously various `Instr` queries used by the graph-colouring allocator failed to handle a few pseudo-instructions. This manifested in compiler panicks while compiling `SHA`, which uses `-fregs-graph`. Fixes #22798. - - - - - 2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00 testsuite: Add regression test for #22798 - - - - - 03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00 Revert "Hadrian: fix doc generation" This is too large of a hammer. This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f. - - - - - f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Sphinx docs require templated cabal files The package-version discovery logic in `doc/users_guide/package_versions.py` uses packages' cabal files to determine package versions. Teach Sphinx about these dependencies in cases where the cabal files are generated by templates. - - - - - 2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Refactor templating logic This refactors Hadrian's autoconf-style templating logic to be explicit about which interpolation variables should be substituted in which files. This clears the way to fix #22714 without incurring rule cycles. - - - - - 93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00 hadrian: Substitute LIBRARY_*_VERSION variables This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714. - - - - - 22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00 Bump transformers submodule to 0.6.0.6 Fixes #22862. - - - - - f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00 compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG Currently, the wasm NCG has an implicit assumption: all CmmSwitch scrutinees are 32-bit integers. This is not always true; #22864 is one counter-example with a 64-bit scrutinee. This patch fixes the logic by explicitly converting the scrutinee to a word that can be used as a br_table operand. Fixes #22871. Also includes a regression test. - - - - - 9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00 Improve treatment of type applications in patterns This patch fixes a subtle bug in the typechecking of type applications in patterns, e.g. f (MkT @Int @a x y) = ... See Note [Type applications in patterns] in GHC.Tc.Gen.Pat. This fixes #19847, #22383, #19577, #21501 - - - - - 955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00 Treat existentials correctly in dubiousDataConInstArgTys Consider (#22849) data T a where MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a Then dubiousDataConInstArgTys MkT [Type, Foo] should return [Foo (ix::Type)] NOT [Foo (ix::k)] A bit of an obscure case, but it's an outright bug, and the fix is easy. - - - - - 0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump supported LLVM range from 10 through 15 to 11 through 16 LLVM 15 turns on the new pass manager by default, which we have yet to migrate to so for new we pass the `-enable-new-pm-0` flag in our llvm-passes flag. LLVM 11 was the first version to support the `-enable-new-pm` flag so we bump the lowest supported version to 11. Our CI jobs are using LLVM 12 so they should continue to work despite this bump to the lower bound. Fixes #21936 - - - - - f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump DOCKER_REV to use alpine image without LLVM installed alpine_3_12 only supports LLVM 10, which is now outside the supported version range. - - - - - 083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00 Remove tracing OPTIONS_GHC These were accidentally left over from !9542 - - - - - 354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00 doc: fix gcdetails_block_fragmentation_bytes since annotation - - - - - 61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00 compiler: Implement higher order patterns in the rule matcher This implements proposal 555 and closes ticket #22465. See the proposal and ticket for motivation. The core changes of this patch are in the GHC.Core.Rules.match function and they are explained in the Note [Matching higher order patterns]. - - - - - 394b91ce by doyougnu at 2023-02-02T00:16:10-05:00 CI: JavaScript backend runs testsuite This MR runs the testsuite for the JS backend. Note that this is a temporary solution until !9515 is merged. Key point: The CI runs hadrian on the built cross compiler _but not_ on the bindist. Other Highlights: - stm submodule gets a bump to mark tests as broken - several tests are marked as broken or are fixed by adding more - conditions to their test runner instance. List of working commit messages: CI: test cross target _and_ emulator CI: JS: Try run testsuite with hadrian JS.CI: cleanup and simplify hadrian invocation use single bracket, print info JS CI: remove call to test_compiler from hadrian don't build haddock JS: mark more tests as broken Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576 JS testsuite: don't skip sum_mod test Its expected to fail, yet we skipped it which automatically makes it succeed leading to an unexpected success, JS testsuite: don't mark T12035j as skip leads to an unexpected pass JS testsuite: remove broken on T14075 leads to unexpected pass JS testsuite: mark more tests as broken JS testsuite: mark T11760 in base as broken JS testsuite: mark ManyUnbSums broken submodules: bump process and hpc for JS tests Both submodules has needed tests skipped or marked broken for th JS backend. This commit now adds these changes to GHC. See: HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21 Process: https://github.com/haskell/process/pull/268 remove js_broken on now passing tests separate wasm and js backend ci test: T11760: add threaded, non-moving only_ways test: T10296a add req_c T13894: skip for JS backend tests: jspace, T22333: mark as js_broken(22573) test: T22513i mark as req_th stm submodule: mark stm055, T16707 broken for JS tests: js_broken(22374) on unpack_sums_6, T12010 dont run diff on JS CI, cleanup fixup: More CI cleanup fix: align text to master fix: align exceptions submodule to master CI: Bump DOCKER_REV Bump to ci-images commit that has a deb11 build with node. Required for !9552 testsuite: mark T22669 as js_skip See #22669 This test tests that .o-boot files aren't created when run in using the interpreter backend. Thus this is not relevant for the JS backend. testsuite: mark T22671 as broken on JS See #22835 base.testsuite: mark Chan002 fragile for JS see #22836 revert: submodule process bump bump stm submodule New hash includes skips for the JS backend. testsuite: mark RnPatternSynonymFail broken on JS Requires TH: - see !9779 - and #22261 compiler: GHC.hs ifdef import Utils.Panic.Plain - - - - - 1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00 docs: 9.6 release notes for wasm backend - - - - - 0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00 Disable unfolding sharing for interface files with core definitions Ticket #22807 pointed out that the RHS sharing was not compatible with -fignore-interface-pragmas because the flag would remove unfoldings from identifiers before the `extra-decls` field was populated. For the 9.6 timescale the only solution is to disable this sharing, which will make interface files bigger but this is acceptable for the first release of `-fwrite-if-simplified-core`. For 9.8 it would be good to fix this by implementing #20056 due to the large number of other bugs that would fix. I also improved the error message in tc_iface_binding to avoid the "no match in record selector" error but it should never happen now as the entire sharing logic is disabled. Also added the currently broken test for #22807 which could be fixed by !6080 Fixes #22807 - - - - - 7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00 Enable tables next to code for LoongArch64 - - - - - 2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00 Move pthread and timerfd ticker implementations to separate files - - - - - 41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00 base: Fix Note references in GHC.IO.Handle.Types - - - - - 31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00 Bump submodule containers to 0.6.7 Metric Decrease: ManyConstructors T10421 T12425 T12707 T13035 T13379 T15164 T1969 T783 T9198 T9961 WWRec - - - - - 8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00 gitlab-ci: Eliminate redundant ghc --info output Previously ci.sh would emit the output of `ghc --info` every time it ran when using the nix toolchain. This produced a significant amount of noise. See #22861. - - - - - de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05: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 ``` - - - - - 48e39195 by Tamar Christina at 2023-02-03T14:07:30-05: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. - - - - - b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00 Bump Windows toolchain Updates to LLVM 14, hopefully fixing #21964. - - - - - bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00 Fix CallerCC potentially shadowing other cost centres. Add a CallerCC cost centre flavour for cost centres added by the CallerCC pass. This avoids potential accidental shadowing between CCs added by user annotations and ones added by CallerCC. - - - - - faea4bcd by j at 2023-02-03T14:08:47-05:00 Disable several ignore-warning flags in genapply. - - - - - 25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00 Revert "Use fix-sized bit-fiddling primops for fixed size boxed types" This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674. This was never applied to master/9.6 originally. (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a) - - - - - 7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00 Minor refactor * Introduce refactorDupsOn f = refactorDups (comparing f) * Make mkBigTupleCase and coreCaseTuple monadic. Every call to those functions was preceded by calling newUniqueSupply. * Use mkUserLocalOrCoVar, which is equivalent to combining mkLocalIdOrCoVar with mkInternalName. - - - - - 5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00 Fix colors in emacs terminal - - - - - 3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00 base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section - - - - - b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00 Update JavaScript fileStat to match Emscripten layout - - - - - 6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00 JS: replace "js" architecture with "javascript" Despite Cabal supporting any architecture name, `cabal --check` only supports a few built-in ones. Sadly `cabal --check` is used by Hackage hence using any non built-in name in a package (e.g. `arch(js)`) is rejected and the package is prevented from being uploaded on Hackage. Luckily built-in support for the `javascript` architecture was added for GHCJS a while ago. In order to allow newer `base` to be uploaded on Hackage we make the switch from `js` to `javascript` architecture. Fixes #22740. Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - 77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00 Fix marking async exceptions in the JS backend Async exceptions are posted as a pair of the exception and the thread object. This fixes the marking pass to correctly follow the two elements of the pair. Potentially fixes #22836 - - - - - 3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00 Remove extraneous word in Roles user guide - - - - - b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00 Don't allow . in overloaded labels This patch removes . from the list of allowed characters in a non-quoted overloaded label, as it was realised this steals syntax, e.g. (#.). Users who want this functionality will have to add quotes around the label, e.g. `#"17.28"`. Fixes #22821 - - - - - 5dce04ee by romes at 2023-02-07T10:52:10-05:00 Update kinds in comments in GHC.Core.TyCon Use `Type` instead of star kind (*) Fix comment with incorrect kind * to have kind `Constraint` - - - - - 92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00 Revert "Use fix-sized equality primops for fixed size boxed types" This reverts commit 024020c38126f3ce326ff56906d53525bc71690c. This was never applied to master/9.6 originally. See #20405 for why using these primops is a bad idea. (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865) - - - - - c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00 JS: avoid head/tail and unpackFS - - - - - a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00 testsuite: Fix Python warnings (#22856) - - - - - 9ee761bf by sheaf at 2023-02-08T14:40:40-05:00 Fix tyvar scoping within class SPECIALISE pragmas Type variables from class/instance headers scope over class/instance method type signatures, but DO NOT scope over the type signatures in SPECIALISE and SPECIALISE instance pragmas. The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for SPECIALISE inline pragmas, but forgot to apply the same treatment to method SPECIALISE pragmas, which lead to a Core Lint failure with an out-of-scope type variable. This patch makes sure we apply the same logic for both cases. Fixes #22913 - - - - - 7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00 Revert "Don't keep exit join points so much" This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 ------------------------- - - - - - 633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: remove config.use_threads This patch simplifies the testsuite driver by removing the use_threads config field. It's just a degenerate case of threads=1. - - - - - ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: use concurrent.futures.ThreadPoolExecutor in the driver The testsuite driver used to create one thread per test case, and explicitly use semaphore and locks for rate limiting and synchronization. This is a bad practice in any language, and occasionally may result in livelock conditions (e.g. #22889). This patch uses concurrent.futures.ThreadPoolExecutor for scheduling test case runs, which is simpler and more robust. - - - - - f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00 EPA: Comment between module and where should be in header comments Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919 - - - - - d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00 JS generated refs: update testsuite conditions - - - - - 2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00 Bump transformers to 0.6.1.0 This allows us to avoid orphans for Foldable1 instances, fixing #22898. Updates transformers submodule. - - - - - d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00 Update `Data.List.singleton` doc comment - - - - - fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00 gitlab-template: Emphasize `user facing` label My sense is that the current mention of the ~"user facing" label is overlooked by many MR authors. Let's move this point up in the list to make it more likely that it is seen. Also rephrase some of the points. - - - - - e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00 Refactor the simplifier a bit to fix #22761 The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now. - - - - - 11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00 Detect the `mold` linker Enables support for the `mold` linker by rui314. - - - - - 59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00 Add Lift instance for Fixed - - - - - c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00 Testsuite: decrease length001 timeout for JS (#22921) - - - - - 133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00 compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData` instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf` - - - - - 1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00 Refresh profiling docs I went through the whole of the profiling docs and tried to amend them to reflect current best practices and tooling. In particular I removed some old references to tools such as hp2any and replaced them with references to eventlog2html. - - - - - da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00 docs: Add section about profiling and foreign calls Previously there was no documentation for how foreign calls interacted with the profiler. This can be quite confusing for users so getting it into the user guide is the first step to a potentially better solution. See the ticket for more insightful discussion. Fixes #21764 - - - - - 081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00 Document that -fproc-alignment was introduced only in GHC 8.6 - - - - - 16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00 Add clangd flag to include generated header files This enables clangd to correctly check C files that import Rts.h. (The added include directory contains ghcautoconf.h et. al.) - - - - - c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00 Mention new `Foreign.Marshal.Pool` implementation in User's Guide - - - - - b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00 upload_ghc_libs: More control over which packages to operate on Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to limit which packages to upload. This is often necessary when one package is not uploadable (e.g. see #22740). - - - - - aa3a262d by PHO at 2023-02-14T11:28:29-05:00 Assume platforms support rpaths if they use either ELF or Mach-O Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability of rpaths based on the object format, not on OS. - - - - - 47716024 by PHO at 2023-02-14T11:29:09-05:00 RTS linker: Improve compatibility with NetBSD 1. Hint address to NetBSD mmap(2) has a different semantics from that of Linux. When a hint address is provided, mmap(2) searches for a free region at or below the hint but *never* above it. This means we can't reliably search for free regions incrementally on the userland, especially when ASLR is enabled. Let the kernel do it for us if we don't care where the mapped address is going to be. 2. NetBSD not only hates to map pages as rwx, but also disallows to switch pages from rw- to r-x unless the intention is declared when pages are initially requested. This means we need a new MemoryAccess mode for pages that are going to be changed to r-x. - - - - - 11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00 base: Move changelog entry to its place - - - - - 75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00 nativeGen/AArch64: Emit Atomic{Read,Write} inline Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115. - - - - - d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00 Fix some correctness issues around tag inference when targeting the bytecode generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840 - - - - - 9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00 Introduce warning for loopy superclass solve Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905 - - - - - 1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00 rts: make it possible to change mblock size on 32-bit targets The MBLOCK_SHIFT macro must be the single source of truth for defining the mblock size, and changing it should only affect performance, not correctness. This patch makes it truly possible to reconfigure mblock size, at least on 32-bit targets, by fixing places which implicitly relied on the previous MBLOCK_SHIFT constant. Fixes #22901. - - - - - 78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00 Update outdated references to notes - - - - - e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00 Documentation: Improve Foldable1 documentation * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater detail, the text is mostly adapted from documentation of Foldable. * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above functions instead of redoing the full explanation. * Small updates to documentation of fold1, foldMap1 and toNonEmpty, again adapting from Foldable. * Update the foldMap1 example to lists instead of Sum since this is recommended for lazy right-associative folds. Fixes #22847 - - - - - 85a1a575 by romes at 2023-02-14T11:34:25-05:00 fix: Mark ghci Prelude import as implicit Fixes #22829 In GHCi, we were creating an import declaration for Prelude but we were not setting it as an implicit declaration. Therefore, ghci's import of Prelude triggered -Wmissing-import-lists. Adds regression test T22829 to testsuite - - - - - 3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00 compiler: fix generateCgIPEStub for no-tables-next-to-code builds generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896. - - - - - 08c0822c by doyougnu at 2023-02-15T00:16:39-05:00 docs: release notes, user guide: add js backend Follow up from #21078 - - - - - 79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00 Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate See #22343 - - - - - 9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00 rts: add the rts_clearMemory function This patch adds the rts_clearMemory function that does its best to zero out unused RTS memory for a wasm backend use case. See the comment above rts_clearMemory() prototype declaration for more detailed explanation. Closes #22920. - - - - - 26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00 Add -single-threaded flag to force single threaded rts This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240 - - - - - 631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00 docs: add a section for the wasm backend Fixes #22658 - - - - - 1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00 tests: Mark T12903 fragile everywhere See #21184 - - - - - b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00 Mark all T5435 variants as fragile See #22970. - - - - - df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00 Testsuite: mark T13167 as fragile for JS (#22921) - - - - - 324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00 JS: disable debugging info for heap objects - - - - - 518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00 Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching - - - - - 34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00 base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog Fixes #22883. - - - - - 12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00 Narrow the dont-decompose-newtype test Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae at cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary - - - - - 5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00 Documentation: add an example of SPEC usage - - - - - 681e0e8c by sheaf at 2023-02-16T14:09:56-05:00 No default finalizer exception handler Commit cfc8e2e2 introduced a mechanism for handling of exceptions that occur during Handle finalization, and 372cf730 set the default handler to print out the error to stderr. However, #21680 pointed out we might not want to set this by default, as it might pollute users' terminals with unwanted information. So, for the time being, the default handler discards the exception. Fixes #21680 - - - - - b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00 unicode: Don't inline bitmap in generalCategory generalCategory contains a huge literal string but is marked INLINE, this will duplicate the string into any use site of generalCategory. In particular generalCategory is used in functions like isSpace and the literal gets inlined into this function which makes it massive. https://github.com/haskell/core-libraries-committee/issues/130 Fixes #22949 ------------------------- Metric Decrease: T4029 T18304 ------------------------- - - - - - 8988eeef by sheaf at 2023-02-16T20:32:27-05:00 Expand synonyms in RoughMap We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985 - - - - - 3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Add test artifact Add the released testsuite tarball to the generated ghcup metadata. - - - - - c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Use Ubuntu and Rocky bindists Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu and Linux Mint. Prefer to use the Rocky 8 binary distribution on unknown distributions. - - - - - be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00 Add INLINABLE pragmas to `generic*` functions in Data.OldList These functions are * recursive * overloaded So it's important to add an `INLINABLE` pragma to each so that they can be specialised at the use site when the specific numeric type is known. Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020) https://github.com/haskell/core-libraries-committee/issues/129 - - - - - a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00 Merge libiserv with ghci `libiserv` serves no purpose. As it depends on `ghci` and doesn't have more dependencies than the `ghci` package, its code could live in the `ghci` package too. This commit also moves most of the code from the `iserv` program into the `ghci` package as well so that it can be reused. This is especially useful for the implementation of TH for the JS backend (#22261, !9779). - - - - - 7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00 Improve GHC.Tc.Gen.App.tcInstFun It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447 - - - - - 2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00 compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. - - - - - 26243de1 by Alexis King at 2023-02-20T15:27:17-05:00 Handle top-level Addr# literals in the bytecode compiler Fixes #22376. - - - - - 0196cc2b by romes at 2023-02-20T15:27:52-05:00 fix: Explicitly flush stdout on plugin Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed. - - - - - 4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00 Don't generate datacon wrappers for `type data` declarations Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948. - - - - - 96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00 Treat type data declarations as empty when checking pattern-matching coverage The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964. - - - - - ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00 Disallow `tagToEnum#` on `type data` types We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level. - - - - - 8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00 Bump submodule text to 2.0.2 - - - - - 172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00 GHC proposal 496 - Nullary record wildcards This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161 - - - - - f70a0239 by sheaf at 2023-02-21T18:36:35-05:00 ghc-prim: levity-polymorphic array equality ops This patch changes the pointer-equality comparison operations in GHC.Prim.PtrEq to work with arrays of unlifted values, e.g. sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# Fixes #22976 - - - - - 9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00 base: Correct @since annotation for FP<->Integral bit cast operations. Fixes #22708 - - - - - f11d9c27 by romes at 2023-02-21T23:58:42-05:00 fix: Update documentation links Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note. - - - - - fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-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. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-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. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-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. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-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. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-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. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 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: ...lots of lines omitted... 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. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04: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. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04: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. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - b2cf942f by Andreas Klebinger at 2023-11-07T12:30:30+01:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Base unpacking under -funpack-small-strict-fields on the rep size of the unpacked constructor instead of the number of reps it's represented by. Fixes #22309 - - - - - 20 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/toolchain.nix - − .gitlab/gen-ci.cabal - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - .gitlab/hie.yaml → .gitlab/generate-ci/hie.yaml - − .gitlab/generate_job_metadata - − .gitlab/generate_jobs - .gitlab/hello.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1bd1cdbde9c5345602f595d9688c3a1e0b9b510a...b2cf942f12582f606dab61df80dd2998ae1b8dbf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1bd1cdbde9c5345602f595d9688c3a1e0b9b510a...b2cf942f12582f606dab61df80dd2998ae1b8dbf You're receiving 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 Nov 7 11:55:28 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 Nov 2023 06:55:28 -0500 Subject: [Git][ghc/ghc][wip/andreask/unpack_unboxed_tuples] Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <654a25b011146_2baaec2280a134197181@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/unpack_unboxed_tuples at Glasgow Haskell Compiler / GHC Commits: 49d70f09 by Andreas Klebinger at 2023-11-07T12:43:54+01:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Base unpacking under -funpack-small-strict-fields on the rep size of the unpacked constructor instead of the number of reps it's represented by. Fixes #22309 - - - - - 7 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -127,8 +127,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1678,9 +1678,40 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + LiftedRep -> 8 + UnliftedRep -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -71,6 +71,7 @@ import GHC.Types.RepType ( countFunRepArgs ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.RepType import GHC.Types.ForeignCall import GHC.Types.Id import GHC.Types.Id.Info @@ -1517,15 +1518,28 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] - where - (rep_tys, _) = dataConArgUnpack arg_ty + && is_small_rep rep_tys) -- See Note [Unpack one-wide fields] + + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + where + (rep_tys, _) = dataConArgUnpack ty + + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep rep_tys = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons @@ -1585,6 +1599,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -486,6 +486,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49d70f09889874da47b59e849fbeface42c3a647 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49d70f09889874da47b59e849fbeface42c3a647 You're receiving 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 Nov 7 12:09:05 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 07:09:05 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] Prepare release 9.4.8 Message-ID: <654a28e159239_2baaec22d150ac2074fa@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 6f38c253 by Zubin Duggal at 2023-11-07T17:38:56+05:30 Prepare release 9.4.8 - - - - - 22 changed files: - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/printer/T18052a.stderr - testsuite/tests/th/T21547.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/T18406b.stderr - testsuite/tests/typecheck/should_compile/T18529.stderr - testsuite/tests/typecheck/should_compile/T21023.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr 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.4.7], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.8], [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 ===================================== docs/users_guide/9.4.7-notes.rst ===================================== @@ -1,4 +1,4 @@ -.. _release-9-4-6: +.. _release-9-4-7: Version 9.4.7 ============== ===================================== docs/users_guide/9.4.8-notes.rst ===================================== @@ -0,0 +1,99 @@ +.. _release-9-4-8: + +Version 9.4.8 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +10, 11, 12, 13, or 14. + +Significant Changes +~~~~~~~~~~~~~~~~~~~~ + +Issues fixed in this release include: + +Compiler +-------- + +- Fix a recompilation checking bug where GHC may miss changes in transitive + dependencies when deciding to relink a program (:ghc-ticket:`23724`). +- Fix a compiler panic resulting from incorrect eta-reduction of join points + (:ghc-ticket:`23922`). +- Fix a code generator bug on AArch64 platforms resulting in invalid conditional + jumps (:ghc-ticket:`23746`). +- Improve STG code generation in certain scenarios (:ghc-ticket:`23783`). +- Fix a bug where we could silently truncate 64 bit values to 32 bit on + 32 bit architectures. +- Fix ``-split-sections`` on Windows (:ghc-ticket:`22834`). + +Runtime system +-------------- + +- Remove an assertion prone to race conditions (:ghc-ticket:`22563`). +- Fix some crashes and loops with the non-moving GC (:ghc-ticket:`24042, :ghc-ticket:`23003`). +- Properly escape characters when writing JSON profiles (``-pJ``) (:ghc-ticket:`23924`). + +Build system and packaging +-------------------------- + +- Ensure ``-split-sections`` is enabled while building binary distributions for + all platforms where this is supported (:ghc-ticket:`21135`). +- Make the configure script use ``AC_PATH_TOOL`` instead of ``AC_PATH_PROG`` to + detect tools, making cross-compilation easier (:ghc-ticket:`21601`). +- Fix a bug where ``-DNOSMP`` wasn't being passed to the C compiler even if the + target doesn't support SMP (:ghc-ticket:`24082`). + +Core libraries +-------------- + +- Bump ``base`` to 4.17.2.1 +- Bump ``bytestring`` to 0.11.5.3 +- Bump ``process`` to 1.6.18.0 + +Included libraries +------------------ + +The package database provided with this distribution also contains a number of +packages other than GHC itself. See the changelogs provided with these packages +for further change information. + +.. ghc-package-list:: + + libraries/array/array.cabal: Dependency of ``ghc`` library + libraries/base/base.cabal: Core library + libraries/binary/binary.cabal: Dependency of ``ghc`` library + libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library + libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility + libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility + libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library + libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library + libraries/directory/directory.cabal: Dependency of ``ghc`` library + libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library + libraries/filepath/filepath.cabal: Dependency of ``ghc`` library + compiler/ghc.cabal: The compiler itself + libraries/ghci/ghci.cabal: The REPL interface + libraries/ghc-boot/ghc-boot.cabal: Internal compiler library + libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library + libraries/ghc-compact/ghc-compact.cabal: Core library + libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library + libraries/ghc-prim/ghc-prim.cabal: Core library + libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable + libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable + libraries/integer-gmp/integer-gmp.cabal: Core library + libraries/libiserv/libiserv.cabal: Internal compiler library + libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library + libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library + libraries/pretty/pretty.cabal: Dependency of ``ghc`` library + libraries/process/process.cabal: Dependency of ``ghc`` library + libraries/stm/stm.cabal: Dependency of ``haskeline`` library + libraries/template-haskell/template-haskell.cabal: Core library + libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library + libraries/text/text.cabal: Dependency of ``Cabal`` library + libraries/time/time.cabal: Dependency of ``ghc`` library + libraries/transformers/transformers.cabal: Dependency of ``ghc`` library + libraries/unix/unix.cabal: Dependency of ``ghc`` library + libraries/Win32/Win32.cabal: Dependency of ``ghc`` library + libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable + ===================================== docs/users_guide/release-notes.rst ===================================== @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 1 + 9.4.8-notes 9.4.7-notes 9.4.6-notes 9.4.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.2.0 +version: 4.17.2.1 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,11 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.17.2.1 *November 2023* + + * Add missing int64/word64-to-double/float rules ([CLC Proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)) + + * Improve String & IsString documentation. + ## 4.17.2.0 *August 2023* * Restore `mingwex` dependency on Windows (#23309). ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9EeElPXCwbT1H2r14ZWyw3-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-CEUpXjWCty3JAbUU0c8zyO-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-6LFEauuQzmN1lhf9BsFCch-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-4pSe9cqTgej5hWlpsCk6Gx-sublib-unused) ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {k2} {c :: k1} {j :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/th/T21547.stderr ===================================== @@ -1,7 +1,7 @@ T21547.hs:9:14: error: • GHC stage restriction: - instance for ‘base-4.17.2.0:Data.Typeable.Internal.Typeable + instance for ‘base-4.17.2.1:Data.Typeable.Internal.Typeable T’ is used in a top-level splice, quasi-quote, or annotation, and must be imported, not defined locally • In the expression: foo [|| T () ||] ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/T18406b.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> a Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T18529.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Bug.N:C :: forall a b. C a b = a -> b -> () Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ==================== Typechecker ==================== Bug.$tcC ===================================== testsuite/tests/typecheck/should_compile/T21023.stderr ===================================== @@ -2,4 +2,4 @@ TYPE SIGNATURES f :: forall {a}. a -> (a, Integer) x :: Integer Dependent modules: [] -Dependent packages: [base-4.17.2.0] +Dependent packages: [base-4.17.2.1] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.17.2.0:Data.OldList’)) + (and originally defined in ‘base-4.17.2.1:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f38c2539974127b5b60724988afd0f6f9090c0d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f38c2539974127b5b60724988afd0f6f9090c0d You're receiving 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 Nov 7 12:48:23 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 Nov 2023 07:48:23 -0500 Subject: [Git][ghc/ghc][wip/andreask/unpack_unboxed_tuples] Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <654a32176a2b9_2baaec23d5a2c82116f0@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/unpack_unboxed_tuples at Glasgow Haskell Compiler / GHC Commits: 51feb423 by Andreas Klebinger at 2023-11-07T13:32:06+01:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - 7 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -127,8 +127,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1678,9 +1678,40 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + LiftedRep -> 8 + UnliftedRep -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -71,6 +71,7 @@ import GHC.Types.RepType ( countFunRepArgs ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.RepType import GHC.Types.ForeignCall import GHC.Types.Id import GHC.Types.Id.Info @@ -1517,15 +1518,28 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] - where - (rep_tys, _) = dataConArgUnpack arg_ty + && is_small_rep rep_tys) -- See Note [Unpack one-wide fields] + + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + where + (rep_tys, _) = dataConArgUnpack ty + + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep rep_tys = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons @@ -1585,6 +1599,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -486,6 +486,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51feb42306cdee5fab982d1efe54a6c8456e265b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51feb42306cdee5fab982d1efe54a6c8456e265b You're receiving 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 Nov 7 12:48:59 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 07 Nov 2023 07:48:59 -0500 Subject: [Git][ghc/ghc][wip/andreask/unpack_unboxed_tuples] Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <654a323b6c291_2baaec23d4fdb4212191@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/unpack_unboxed_tuples at Glasgow Haskell Compiler / GHC Commits: 5e62daab by Andreas Klebinger at 2023-11-07T13:37:44+01:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - 7 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -127,8 +127,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1678,9 +1678,39 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + BoxedRep{} -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -71,6 +71,7 @@ import GHC.Types.RepType ( countFunRepArgs ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env +import GHC.Types.RepType import GHC.Types.ForeignCall import GHC.Types.Id import GHC.Types.Id.Info @@ -1517,16 +1518,29 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + && is_small_rep) -- See Note [Unpack one-wide fields] where (rep_tys, _) = dataConArgUnpack arg_ty + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + + -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons -- iff ty is of the form @@ -1585,6 +1599,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -486,6 +486,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e62daab393ef906fe6479827941e51e3e8ccce4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e62daab393ef906fe6479827941e51e3e8ccce4 You're receiving 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 Nov 7 14:58:52 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 07 Nov 2023 09:58:52 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 7 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <654a50ac57ecf_2baaec272c52b4249149@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 4a7953ac by Apoorv Ingle at 2023-11-07T15:45:08+01:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - c3602f80 by Gergő Érdi at 2023-11-07T15:45:12+01:00 push the `match_ctxt` business inside `tcMatchLambda` - - - - - 3c9b762d by Apoorv Ingle at 2023-11-07T15:45:13+01:00 - Note changes. Making expansion example a bit more complex - - - - - 30 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - + compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7742deacd8eaa5d52b5f774139c54308b6f923f9...3c9b762d7be8c8c07f798279f33da93790e6eb02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7742deacd8eaa5d52b5f774139c54308b6f923f9...3c9b762d7be8c8c07f798279f33da93790e6eb02 You're receiving 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 Nov 7 16:32:42 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 Nov 2023 11:32:42 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24167 Message-ID: <654a66aab7668_2baaec297630d028481@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24167 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24167 You're receiving 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 Nov 7 16:55:16 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 07 Nov 2023 11:55:16 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/fix-no-fixup-chains Message-ID: <654a6bf418984_2baaec2a08ccb02899f4@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/fix-no-fixup-chains at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/fix-no-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 Tue Nov 7 17:07:32 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 12:07:32 -0500 Subject: [Git][ghc/ghc][wip/9.4.8-backports] Add bootstrap plans Message-ID: <654a6ed43e55f_2baaec2a54b0582918b@gitlab.mail> Zubin pushed to branch wip/9.4.8-backports at Glasgow Haskell Compiler / GHC Commits: 8e9ea0f9 by Zubin Duggal at 2023-11-07T22:36:50+05:30 Add bootstrap plans - - - - - 6 changed files: - + hadrian/bootstrap/plan-9_2_5.json - + hadrian/bootstrap/plan-9_2_6.json - + hadrian/bootstrap/plan-9_2_7.json - + hadrian/bootstrap/plan-9_2_8.json - + hadrian/bootstrap/plan-9_4_3.json - + hadrian/bootstrap/plan-9_4_4.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e9ea0f91305d9e4bb9df3d89f6a9e223ecb4dd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e9ea0f91305d9e4bb9df3d89f6a9e223ecb4dd3 You're receiving 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 Nov 7 17:49:34 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Tue, 07 Nov 2023 12:49:34 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-bytestring-0.12.1-dev Message-ID: <654a78aea56fb_2baaec2b648fb83081c5@gitlab.mail> Matthew Craven pushed new branch wip/bump-bytestring-0.12.1-dev at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-bytestring-0.12.1-dev You're receiving 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 Nov 7 19:00:21 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 07 Nov 2023 14:00:21 -0500 Subject: [Git][ghc/ghc][wip/add-ddump-specialisations] Current call stack ids Message-ID: <654a8945434e3_2baaec2d2d80ac3269b5@gitlab.mail> Finley McIlwaine pushed to branch wip/add-ddump-specialisations at Glasgow Haskell Compiler / GHC Commits: ef43e134 by Finley McIlwaine at 2023-11-07T11:00:09-08:00 Current call stack ids - - - - - 3 changed files: - libraries/base/GHC/Exts.hs - libraries/base/GHC/Stack.hs - libraries/base/GHC/Stack/CCS.hsc Changes: ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -103,6 +103,7 @@ module GHC.Exts -- ** The call stack currentCallStack, + currentCallStackIds, -- * Ids with special behaviour inline, noinline, lazy, oneShot, considerAccessible, ===================================== libraries/base/GHC/Stack.hs ===================================== @@ -23,6 +23,7 @@ module GHC.Stack ( -- * Profiling call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * HasCallStack call stacks ===================================== libraries/base/GHC/Stack/CCS.hsc ===================================== @@ -19,6 +19,7 @@ module GHC.Stack.CCS ( -- * Call stacks currentCallStack, + currentCallStackIds, whoCreated, -- * Internals @@ -29,6 +30,7 @@ module GHC.Stack.CCS ( clearCCS, ccsCC, ccsParent, + ccId, ccLabel, ccModule, ccSrcSpan, @@ -83,6 +85,9 @@ ccsCC p = peekByteOff p 4 ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = peekByteOff p 8 +ccId :: Ptr CostCentre -> IO Word32 +ccId p = peekByteOff p 0 + ccLabel :: Ptr CostCentre -> IO CString ccLabel p = peekByteOff p 4 @@ -99,6 +104,10 @@ ccsCC p = (# peek CostCentreStack, cc) p ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) ccsParent p = (# peek CostCentreStack, prevStack) p +-- | Get the id of a 'CostCentre'. +ccId :: Ptr CostCentre -> IO Word32 +ccId p = (# peek CostCentre, ccID) p + -- | Get the label of a 'CostCentre'. ccLabel :: Ptr CostCentre -> IO CString ccLabel p = (# peek CostCentre, label) p @@ -125,6 +134,19 @@ ccSrcSpan p = (# peek CostCentre, srcloc) p currentCallStack :: IO [String] currentCallStack = ccsToStrings =<< getCurrentCCS () +-- | Returns a @[Word32]@ representing the current call stack. This +-- can be useful for debugging. +-- +-- The implementation uses the call-stack simulation maintained by the +-- profiler, so it only works if the program was compiled with @-prof@ +-- and contains suitable SCC annotations (e.g. by using @-fprof-auto@). +-- Otherwise, the list returned is likely to be empty or +-- uninformative. +-- +-- @since 4.5.0.0 +currentCallStackIds :: IO [Word32] +currentCallStackIds = ccsToIds =<< getCurrentCCS () + -- | Format a 'CostCentreStack' as a list of lines. ccsToStrings :: Ptr CostCentreStack -> IO [String] ccsToStrings ccs0 = go ccs0 [] @@ -141,6 +163,22 @@ ccsToStrings ccs0 = go ccs0 [] then return acc else go parent ((mdl ++ '.':lbl ++ ' ':'(':loc ++ ")") : acc) +-- | Format a 'CostCentreStack' as a list of cost centre IDs. +ccsToIds :: Ptr CostCentreStack -> IO [Word32] +ccsToIds ccs0 = go ccs0 [] + where + go ccs acc + | ccs == nullPtr = return acc + | otherwise = do + cc <- ccsCC ccs + cc_id <- ccId cc + lbl <- GHC.peekCString utf8 =<< ccLabel cc + mdl <- GHC.peekCString utf8 =<< ccModule cc + parent <- ccsParent ccs + if (mdl == "MAIN" && lbl == "MAIN") + then return acc + else go parent (cc_id : acc) + -- | Get the stack trace attached to an object. -- -- @since 4.5.0.0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef43e1342591ea537ff315c6008766312fa3fbf6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef43e1342591ea537ff315c6008766312fa3fbf6 You're receiving 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 Nov 7 19:57:16 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 07 Nov 2023 14:57:16 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-remove-glrr-et-al Message-ID: <654a969ce9f92_2baaec2e76239c330559@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-remove-glrr-et-al at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-remove-glrr-et-al You're receiving 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 Nov 7 20:59:56 2023 From: gitlab at gitlab.haskell.org (Peter Trommler (@trommler)) Date: Tue, 07 Nov 2023 15:59:56 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24145 Message-ID: <654aa54c6941a_2baaec3001792833757d@gitlab.mail> Peter Trommler pushed new branch wip/T24145 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24145 You're receiving 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 Nov 7 22:23:00 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 07 Nov 2023 17:23:00 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 21 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <654ab8c4485a3_2baaec32158164349883@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - f088d21b by Alan Zimmerman at 2023-11-07T19:45:29+00:00 EPA: get rid of glRR and friends With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead - - - - - 4a5ee777 by Alan Zimmerman at 2023-11-07T20:32:06+00:00 EPA: harmonise acsa and acsA [2023-10-01 Sun] Failing tests HsDocTy - - - - - 3d5501f2 by Alan Zimmerman at 2023-11-07T21:27:07+00:00 EPA: Replace Anchor with EpaLocation [2023-09-21 Thu] Only test failing is HsDocTy - - - - - 7c59c801 by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: get rid of AnchorOperation [2023-09-21 Thu] Only error is HsDocTy - - - - - 2546626f by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: splitLHsForAllTyInvis no ann returned - - - - - 3c5bef2a by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: Replace Monoid with NoAnn [2023-08-19 Sat] AddClassMethod fails - - - - - 53b59e99 by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - c03d21f2 by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: Present no longer has annotation - - - - - 8c3eca13 by Alan Zimmerman at 2023-11-07T21:27:08+00:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 6d560a6d by Alan Zimmerman at 2023-11-07T21:27:09+00:00 EPA: Remove parenthesizeHsType - - - - - 629e6cc7 by Alan Zimmerman at 2023-11-07T21:27:09+00:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - 2b9825fa by Alan Zimmerman at 2023-11-07T21:27:09+00:00 EPA: Remove SrcSpanAnn [2023-10-12 Thu] Failures HsDocTy T15242 - - - - - 7a95bdbb by Alan Zimmerman at 2023-11-07T21:27:09+00:00 EPA: Remove SrcSpanAnn completely - - - - - d7c92ebf by Alan Zimmerman at 2023-11-07T21:27:09+00:00 Clean up mkScope - - - - - 05cbec0f by Alan Zimmerman at 2023-11-07T21:27:10+00:00 EPA: Clean up TC Monad Utils - - - - - 392a4371 by Alan Zimmerman at 2023-11-07T21:27:10+00:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - e94b94df by Alan Zimmerman at 2023-11-07T21:27:10+00:00 Semigroup instances for AnnList and AnnContext - - - - - 30 changed files: - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Parser/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd4d3911ad2c88a8f07bc5158b703d4d15942bd2...e94b94dfc15619d32f54af8e4ebe22d2b183ee28 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd4d3911ad2c88a8f07bc5158b703d4d15942bd2...e94b94dfc15619d32f54af8e4ebe22d2b183ee28 You're receiving 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 Nov 7 22:53:56 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 07 Nov 2023 17:53:56 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24083 Message-ID: <654ac004b6686_2baaec32ee1c683502f2@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24083 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24083 You're receiving 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 Nov 8 03:54:24 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 07 Nov 2023 22:54:24 -0500 Subject: [Git][ghc/ghc][ghc-9.4] 25 commits: configure: Use AC_PATH_TOOL to detect tools Message-ID: <654b06708927d_2baaec39bd4cbc3750f0@gitlab.mail> Zubin pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: ca4d7241 by Ben Gamari at 2023-11-06T13:34:42+05:30 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. (cherry picked from commit bd92182cd56140ffb2f68ec01492e5aa6333a8fc) - - - - - e5ad89f6 by Ben Gamari at 2023-11-06T13:36:37+05:30 Revert "rts: Drop racy assertion" The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1. (cherry picked from commit db11f3586085901e89705f69aff472e027c0748f) - - - - - 2f966098 by Ben Gamari at 2023-11-06T13:36:47+05:30 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. (cherry picked from commit 3242139fbd18df324460e22619c1a1fb3b258a07) - - - - - 86554c92 by Profpatsch at 2023-11-06T13:37:36+05:30 base: Improve String & IsString documentation (cherry picked from commit d751c583d29460f033fefb45e685fa40fb3487ad) - - - - - c7c0a035 by Jaro Reinders at 2023-11-06T13:39:31+05:30 Make STG rewriter produce updatable closures (cherry picked from commit 3930d793901d72f42b1535c85b746f32d5f3b677) - - - - - 89b0c2bc by Matthew Pickering at 2023-11-07T16:28:12+05:30 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 (cherry picked from commit 291d81aef8083290da0d2ce430fbc5e5a33bdb6e) - - - - - adf9c778 by Andreas Klebinger at 2023-11-07T16:28:12+05:30 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 (cherry picked from commit e5c00092a13f1a8cf53df2469e027012743cf59a) - - - - - 76fd8599 by Andreas Klebinger at 2023-11-07T16:28:12+05:30 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 0447ecaa by Ben Gamari at 2023-11-07T16:28:12+05:30 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. (cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496) - - - - - 8e7a2065 by Moritz Angermann at 2023-11-07T16:28:12+05:30 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. (cherry picked from commit dafc47091c9107dcf81e1e80a105f59211927c89) - - - - - fdc5f65d by Moritz Angermann at 2023-11-07T16:28:12+05:30 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. (cherry picked from commit df81536f2e53abf521a05eb1e482a076f5849c21) - - - - - b2a03315 by Ilias Tsitsimpis at 2023-11-07T16:28:12+05:30 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 (cherry picked from commit 257c2807587624592813a42e06a05c5fc34cb38c) - - - - - 0af2b8ef by Moritz Angermann at 2023-11-07T16:28:12+05:30 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. (cherry picked from commit 34f06334025521c2440ebedb0237697fbcc3c6de) - - - - - 9227c6df by Ben Gamari at 2023-11-07T16:28:12+05:30 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. (cherry picked from commit 3ece9856d157c85511d59f9f862ab351bbd9b38b) - - - - - 689f04e7 by Ben Gamari at 2023-11-07T16:28:12+05:30 nativeGen: Set explicit section types on all platforms (cherry picked from commit db7f7240b53c01447e44d2790ee37eacaabfbcf3) - - - - - 76240051 by Moritz Angermann at 2023-11-07T16:28:12+05:30 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ (cherry picked from commit e99cf237f84db34be0468a893b10394d6b364bce) - - - - - 89cc99fc by Matthew Craven at 2023-11-07T16:28:12+05:30 Bump bytestring submodule to 0.11.5.3 (cherry picked from commit 97a187bfd713663fccb8bc4f4f0c92792547f9c2) - - - - - 68bebf3e by Zubin Duggal at 2023-11-07T16:28:12+05:30 Bump process submodule to 1.6.18.0 - - - - - adc0996f by Matthew Pickering at 2023-11-07T16:28:12+05:30 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) - - - - - d2dd0db2 by Matthew Pickering at 2023-11-07T16:28:12+05:30 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) - - - - - 66987a9b by Cheng Shao at 2023-11-07T16:28:12+05:30 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. (cherry picked from commit ce580426ce3052e3b3d2847d0312652ea9087994) - - - - - 72619e9a by Zubin Duggal at 2023-11-07T16:28:12+05:30 testsuite: add omit_ghci for use in process - - - - - 0d758dc3 by Sylvain Henry at 2023-11-07T17:11:37+05:30 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 (cherry picked from commit 5126a2fef0385e206643b6af0543d10ff0c219d8) - - - - - 6f38c253 by Zubin Duggal at 2023-11-07T17:38:56+05:30 Prepare release 9.4.8 - - - - - 8e9ea0f9 by Zubin Duggal at 2023-11-07T22:36:50+05:30 Add bootstrap plans - - - - - 24 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/CgUtils.hs - configure.ac - docs/users_guide/9.4.7-notes.rst - + docs/users_guide/9.4.8-notes.rst - docs/users_guide/release-notes.rst - + hadrian/bootstrap/plan-9_2_5.json - + hadrian/bootstrap/plan-9_2_6.json - + hadrian/bootstrap/plan-9_2_7.json - + hadrian/bootstrap/plan-9_2_8.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00920f176b0235d5bb52a8e054d89a664f8938fe...8e9ea0f91305d9e4bb9df3d89f6a9e223ecb4dd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00920f176b0235d5bb52a8e054d89a664f8938fe...8e9ea0f91305d9e4bb9df3d89f6a9e223ecb4dd3 You're receiving 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 Nov 8 09:25:29 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 08 Nov 2023 04:25:29 -0500 Subject: [Git][ghc/ghc][wip/romes/24167] 22 commits: More robust checking for DataKinds Message-ID: <654b5409929a5_2baaec414cf608402791@gitlab.mail> Matthew Pickering pushed to branch wip/romes/24167 at Glasgow Haskell Compiler / GHC Commits: 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 7359293d by Rodrigo Mesquita at 2023-11-08T09:25:25+00:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Deriv/Generate.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb955194a8358d4ef9ca1add70ab9310ab782541...7359293d8963c9e184a1125a9acb9f259e7141c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb955194a8358d4ef9ca1add70ab9310ab782541...7359293d8963c9e184a1125a9acb9f259e7141c2 You're receiving 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 Nov 8 11:48:40 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 08 Nov 2023 06:48:40 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/24161 Message-ID: <654b75982e5ca_2baaec44d2cba4422986@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/24161 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/24161 You're receiving 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 Nov 8 14:09:10 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 08 Nov 2023 09:09:10 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/fix-single-module-warning Message-ID: <654b9686965b1_2baaec480446b845082e@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/fix-single-module-warning at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/fix-single-module-warning You're receiving 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 Nov 8 14:18:28 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 08 Nov 2023 09:18:28 -0500 Subject: [Git][ghc/ghc][wip/romes/24161] darwin: Fix single_module is obsolete warning Message-ID: <654b98b4841f6_2baaec4865500c45267d@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24161 at Glasgow Haskell Compiler / GHC Commits: b6fef652 by Rodrigo Mesquita at 2023-11-08T14:03:35+00:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 12 changed files: - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - + m4/fp_prog_ld_single_module.m4 - m4/prep_target_file.m4 - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -11,6 +11,7 @@ where import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Settings (ToolSettings(toolSettings_ldSupportsSingleModule)) import GHC.Driver.Config.Linker import GHC.Driver.Session @@ -152,6 +153,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- dynamic binding nonsense when referring to symbols from -- within the library. The NCG assumes that this option is -- specified (on i386, at least). + -- In XCode 15, -single_module is the default and passing the + -- flag is now obsolete and raises a warning (#24168). We encode + -- this information into the toolchain field ...SupportsSingleModule. -- -install_name -- Mac OS/X stores the path where a dynamic library is (to -- be) installed in the library itself. It's called the @@ -177,8 +181,11 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages ] ++ map Option o_files ++ [ Option "-undefined", - Option "dynamic_lookup", - Option "-single_module" ] + Option "dynamic_lookup" + ] + ++ (if toolSettings_ldSupportsSingleModule (toolSettings dflags) + then [ Option "-single_module" ] + else [ ]) ++ (if platformArch platform `elem` [ ArchX86_64, ArchAArch64 ] then [ ] else [ Option "-Wl,-read_only_relocs,suppress" ]) ===================================== compiler/GHC/Settings.hs ===================================== @@ -86,6 +86,7 @@ data Settings = Settings data ToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind :: Bool , toolSettings_ldSupportsFilelist :: Bool + , toolSettings_ldSupportsSingleModule :: Bool , toolSettings_mergeObjsSupportsResponseFiles :: Bool , toolSettings_ldIsGnuLd :: Bool , toolSettings_ccSupportsNoPie :: Bool ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -107,6 +107,7 @@ initSettings top_dir = do ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind" ldSupportsFilelist <- getBooleanSetting "ld supports filelist" + ldSupportsSingleModule <- getBooleanSetting "ld supports single module" mergeObjsSupportsResponseFiles <- getBooleanSetting "Merge objects supports response files" ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" @@ -171,6 +172,7 @@ initSettings top_dir = do , sToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind , toolSettings_ldSupportsFilelist = ldSupportsFilelist + , toolSettings_ldSupportsSingleModule = ldSupportsSingleModule , toolSettings_mergeObjsSupportsResponseFiles = mergeObjsSupportsResponseFiles , toolSettings_ldIsGnuLd = ldIsGnuLd , toolSettings_ccSupportsNoPie = gccSupportsNoPie ===================================== configure.ac ===================================== @@ -452,6 +452,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** Which nm to use? ===================================== distrib/configure.ac.in ===================================== @@ -136,6 +136,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** which strip to use? dnl -------------------------------------------------------------- ===================================== hadrian/bindist/Makefile ===================================== @@ -104,6 +104,7 @@ lib/settings : config.mk @echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@ @echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@ @echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@ + @echo ',("ld supports single module", "$(LdHasSingleModule)")' >> $@ @echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@ @echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@ @echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@ ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = False , ccLinkSupportsCompactUnwind = False , ccLinkSupportsFilelist = False +, ccLinkSupportsSingleModule = True , ccLinkIsGnu = False } ===================================== hadrian/cfg/default.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = @CONF_GCC_SUPPORTS_NO_PIEBool@ , ccLinkSupportsCompactUnwind = @LdHasNoCompactUnwindBool@ , ccLinkSupportsFilelist = @LdHasFilelistBool@ +, ccLinkSupportsSingleModule = @LdHasSingleModuleBool@ , ccLinkIsGnu = @LdIsGNULdBool@ } ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -373,6 +373,7 @@ generateSettings = do , ("Haskell CPP flags", queryTarget hsCppFlags) , ("ld supports compact unwind", queryTarget linkSupportsCompactUnwind) , ("ld supports filelist", queryTarget linkSupportsFilelist) + , ("ld supports single module", queryTarget linkSupportsSingleModule) , ("ld is GNU ld", queryTarget linkIsGnu) , ("Merge objects command", queryTarget mergeObjsPath) , ("Merge objects flags", queryTarget mergeObjsFlags) @@ -431,6 +432,7 @@ generateSettings = do hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink ===================================== m4/fp_prog_ld_single_module.m4 ===================================== @@ -0,0 +1,30 @@ +# FP_PROG_LD_SINGLE_MODULE +# ---------------------------- +# Sets the output variable LdHasSingleModule to YES if the darwin ld supports +# -single_module, or NO otherwise. +# +# In XCode 15, -single_module is a default and passing it as a flag raises a +# warning. +AC_DEFUN([FP_PROG_LD_SINGLE_MODULE], +[ +AC_CACHE_CHECK([whether ld supports -single_module], [fp_cv_ld_single_module], +[ +case $build in + *-darwin) + echo 'int foo(int x) { return x*x; }' > conftest.c + echo 'extern int foo(int); int main() { return foo(5); }' > conftestmain.c + "$CC" -c -o conftestmain.o conftestmain.c + "$CC" -shared -o conftest.dylib conftest.c + if "$CC" -Wl,-single_module -o conftest conftestmain.o conftest.dylib 2>&1 | grep obsolete > /dev/null; then + fp_cv_ld_single_module=no + else + fp_cv_ld_single_module=yes + fi + rm -rf conftest* ;; + *) + fp_cv_ld_single_module=no ;; +esac +]) +FP_CAPITALIZE_YES_NO(["$fp_cv_ld_single_module"], [LdHasSingleModule]) +AC_SUBST([LdHasSingleModule]) +])# FP_PROG_LD_SINGLE_MODULE ===================================== m4/prep_target_file.m4 ===================================== @@ -131,6 +131,7 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_BOOLEAN([TargetHasIdentDirective]) PREP_BOOLEAN([CONF_GCC_SUPPORTS_NO_PIE]) PREP_BOOLEAN([LdHasFilelist]) + PREP_BOOLEAN([LdHasSingleModule]) PREP_BOOLEAN([LdIsGNULd]) PREP_BOOLEAN([LdHasNoCompactUnwind]) PREP_BOOLEAN([TargetHasSubsectionsViaSymbols]) ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -22,6 +22,7 @@ data CcLink = CcLink { ccLinkProgram :: Program , ccLinkSupportsNoPie :: Bool -- See Note [No PIE when linking] in GHC.Driver.Session , ccLinkSupportsCompactUnwind :: Bool , ccLinkSupportsFilelist :: Bool + , ccLinkSupportsSingleModule :: Bool , ccLinkIsGnu :: Bool } deriving (Read, Eq, Ord) @@ -34,6 +35,7 @@ instance Show CcLink where , ", ccLinkSupportsNoPie = " ++ show ccLinkSupportsNoPie , ", ccLinkSupportsCompactUnwind = " ++ show ccLinkSupportsCompactUnwind , ", ccLinkSupportsFilelist = " ++ show ccLinkSupportsFilelist + , ", ccLinkSupportsSingleModule = " ++ show ccLinkSupportsSingleModule , ", ccLinkIsGnu = " ++ show ccLinkIsGnu , "}" ] @@ -66,12 +68,13 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram + ccLinkSupportsSingleModule <- checkSupportsSingleModule archOs cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram checkBfdCopyBug archOs cc readelf ccLinkProgram ccLinkProgram <- addPlatformDepLinkFlags archOs cc ccLinkProgram let ccLink = CcLink {ccLinkProgram, ccLinkSupportsNoPie, ccLinkSupportsCompactUnwind, ccLinkSupportsFilelist, - ccLinkIsGnu} + ccLinkSupportsSingleModule, ccLinkIsGnu} ccLink <- linkRequiresNoFixupChains archOs cc ccLink ccLink <- linkRequiresNoWarnDuplicateLibraries archOs cc ccLink return ccLink @@ -164,6 +167,34 @@ checkSupportsFilelist cc ccLink = checking "whether the cc linker understands -f return (isSuccess exitCode) +-- | Check that the (darwin) linker supports @-single_module at . +-- +-- In XCode 15, the linker warns when @-single_module@ is passed as the flag +-- became the default and is now obsolete to pass. +-- +-- We assume non-darwin linkers don't support this flag. +checkSupportsSingleModule :: ArchOS -> Cc -> Program -> M Bool +checkSupportsSingleModule archOs cc link + | ArchOS _ OSDarwin <- archOs + = checking "whether the darwin linker supports -single_module" $ do + withTempDir $ \dir -> do + let test_dylib = dir "test.dylib" + test_c = dir "test.c" + testmain_o = dir "testmain.o" + + -- Main + compileC cc testmain_o "extern int foo(int); int main() { return foo(5); }" + + -- Dynamic library + writeFile test_c "int foo(int x) { return x*x; }" + _ <- runProgram (ccProgram cc) ["-shared", "-o", test_dylib, test_c] + + (_, out, err) <- readProgram link ["-Wl,-single_module", "-o", "testmain", test_dylib, testmain_o] + + return $ not $ "obsolete" `isInfixOf` err || "obsolete" `isInfixOf` out + | otherwise + = return False + -- | Check whether linking works. checkLinkWorks :: Cc -> Program -> M () checkLinkWorks cc ccLink = withTempDir $ \dir -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6fef65255e7e633a8d409516ae4b25df038810c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6fef65255e7e633a8d409516ae4b25df038810c You're receiving 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 Nov 8 16:12:17 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 08 Nov 2023 11:12:17 -0500 Subject: [Git][ghc/ghc][wip/romes/24161] darwin: Fix single_module is obsolete warning Message-ID: <654bb3617d53f_2baaec4af19f7447106a@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24161 at Glasgow Haskell Compiler / GHC Commits: c2e13e18 by Rodrigo Mesquita at 2023-11-08T16:12:07+00:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 13 changed files: - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - + m4/fp_prog_ld_single_module.m4 - m4/prep_target_file.m4 - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -11,6 +11,7 @@ where import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Settings (ToolSettings(toolSettings_ldSupportsSingleModule)) import GHC.Driver.Config.Linker import GHC.Driver.Session @@ -152,6 +153,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- dynamic binding nonsense when referring to symbols from -- within the library. The NCG assumes that this option is -- specified (on i386, at least). + -- In XCode 15, -single_module is the default and passing the + -- flag is now obsolete and raises a warning (#24168). We encode + -- this information into the toolchain field ...SupportsSingleModule. -- -install_name -- Mac OS/X stores the path where a dynamic library is (to -- be) installed in the library itself. It's called the @@ -177,8 +181,11 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages ] ++ map Option o_files ++ [ Option "-undefined", - Option "dynamic_lookup", - Option "-single_module" ] + Option "dynamic_lookup" + ] + ++ (if toolSettings_ldSupportsSingleModule (toolSettings dflags) + then [ Option "-single_module" ] + else [ ]) ++ (if platformArch platform `elem` [ ArchX86_64, ArchAArch64 ] then [ ] else [ Option "-Wl,-read_only_relocs,suppress" ]) ===================================== compiler/GHC/Settings.hs ===================================== @@ -86,6 +86,7 @@ data Settings = Settings data ToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind :: Bool , toolSettings_ldSupportsFilelist :: Bool + , toolSettings_ldSupportsSingleModule :: Bool , toolSettings_mergeObjsSupportsResponseFiles :: Bool , toolSettings_ldIsGnuLd :: Bool , toolSettings_ccSupportsNoPie :: Bool ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -107,6 +107,7 @@ initSettings top_dir = do ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind" ldSupportsFilelist <- getBooleanSetting "ld supports filelist" + ldSupportsSingleModule <- getBooleanSetting "ld supports single module" mergeObjsSupportsResponseFiles <- getBooleanSetting "Merge objects supports response files" ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" @@ -171,6 +172,7 @@ initSettings top_dir = do , sToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind , toolSettings_ldSupportsFilelist = ldSupportsFilelist + , toolSettings_ldSupportsSingleModule = ldSupportsSingleModule , toolSettings_mergeObjsSupportsResponseFiles = mergeObjsSupportsResponseFiles , toolSettings_ldIsGnuLd = ldIsGnuLd , toolSettings_ccSupportsNoPie = gccSupportsNoPie ===================================== configure.ac ===================================== @@ -452,6 +452,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** Which nm to use? ===================================== distrib/configure.ac.in ===================================== @@ -136,6 +136,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** which strip to use? dnl -------------------------------------------------------------- ===================================== hadrian/bindist/Makefile ===================================== @@ -104,6 +104,7 @@ lib/settings : config.mk @echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@ @echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@ @echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@ + @echo ',("ld supports single module", "$(LdHasSingleModule)")' >> $@ @echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@ @echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@ @echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -191,6 +191,7 @@ LdHasBuildId = @LdHasBuildId@ LdHasFilelist = @LdHasFilelist@ LdIsGNULd = @LdIsGNULd@ LdHasNoCompactUnwind = @LdHasNoCompactUnwind@ +LdHasSingleModule = @LdHasSingleModule@ ArArgs = @ArArgs@ ArSupportsAtFile = @ArSupportsAtFile@ ArSupportsDashL = @ArSupportsDashL@ ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = False , ccLinkSupportsCompactUnwind = False , ccLinkSupportsFilelist = False +, ccLinkSupportsSingleModule = True , ccLinkIsGnu = False } ===================================== hadrian/cfg/default.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = @CONF_GCC_SUPPORTS_NO_PIEBool@ , ccLinkSupportsCompactUnwind = @LdHasNoCompactUnwindBool@ , ccLinkSupportsFilelist = @LdHasFilelistBool@ +, ccLinkSupportsSingleModule = @LdHasSingleModuleBool@ , ccLinkIsGnu = @LdIsGNULdBool@ } ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -373,6 +373,7 @@ generateSettings = do , ("Haskell CPP flags", queryTarget hsCppFlags) , ("ld supports compact unwind", queryTarget linkSupportsCompactUnwind) , ("ld supports filelist", queryTarget linkSupportsFilelist) + , ("ld supports single module", queryTarget linkSupportsSingleModule) , ("ld is GNU ld", queryTarget linkIsGnu) , ("Merge objects command", queryTarget mergeObjsPath) , ("Merge objects flags", queryTarget mergeObjsFlags) @@ -431,6 +432,7 @@ generateSettings = do hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink ===================================== m4/fp_prog_ld_single_module.m4 ===================================== @@ -0,0 +1,30 @@ +# FP_PROG_LD_SINGLE_MODULE +# ---------------------------- +# Sets the output variable LdHasSingleModule to YES if the darwin ld supports +# -single_module, or NO otherwise. +# +# In XCode 15, -single_module is a default and passing it as a flag raises a +# warning. +AC_DEFUN([FP_PROG_LD_SINGLE_MODULE], +[ +AC_CACHE_CHECK([whether ld supports -single_module], [fp_cv_ld_single_module], +[ +case $build in + *-darwin) + echo 'int foo(int x) { return x*x; }' > conftest.c + echo 'extern int foo(int); int main() { return foo(5); }' > conftestmain.c + "$CC" -c -o conftestmain.o conftestmain.c + "$CC" -shared -o conftest.dylib conftest.c + if "$CC" -Wl,-single_module -o conftest conftestmain.o conftest.dylib 2>&1 | grep obsolete > /dev/null; then + fp_cv_ld_single_module=no + else + fp_cv_ld_single_module=yes + fi + rm -rf conftest* ;; + *) + fp_cv_ld_single_module=no ;; +esac +]) +FP_CAPITALIZE_YES_NO(["$fp_cv_ld_single_module"], [LdHasSingleModule]) +AC_SUBST([LdHasSingleModule]) +])# FP_PROG_LD_SINGLE_MODULE ===================================== m4/prep_target_file.m4 ===================================== @@ -131,6 +131,7 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_BOOLEAN([TargetHasIdentDirective]) PREP_BOOLEAN([CONF_GCC_SUPPORTS_NO_PIE]) PREP_BOOLEAN([LdHasFilelist]) + PREP_BOOLEAN([LdHasSingleModule]) PREP_BOOLEAN([LdIsGNULd]) PREP_BOOLEAN([LdHasNoCompactUnwind]) PREP_BOOLEAN([TargetHasSubsectionsViaSymbols]) ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -22,6 +22,7 @@ data CcLink = CcLink { ccLinkProgram :: Program , ccLinkSupportsNoPie :: Bool -- See Note [No PIE when linking] in GHC.Driver.Session , ccLinkSupportsCompactUnwind :: Bool , ccLinkSupportsFilelist :: Bool + , ccLinkSupportsSingleModule :: Bool , ccLinkIsGnu :: Bool } deriving (Read, Eq, Ord) @@ -34,6 +35,7 @@ instance Show CcLink where , ", ccLinkSupportsNoPie = " ++ show ccLinkSupportsNoPie , ", ccLinkSupportsCompactUnwind = " ++ show ccLinkSupportsCompactUnwind , ", ccLinkSupportsFilelist = " ++ show ccLinkSupportsFilelist + , ", ccLinkSupportsSingleModule = " ++ show ccLinkSupportsSingleModule , ", ccLinkIsGnu = " ++ show ccLinkIsGnu , "}" ] @@ -66,12 +68,13 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram + ccLinkSupportsSingleModule <- checkSupportsSingleModule archOs cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram checkBfdCopyBug archOs cc readelf ccLinkProgram ccLinkProgram <- addPlatformDepLinkFlags archOs cc ccLinkProgram let ccLink = CcLink {ccLinkProgram, ccLinkSupportsNoPie, ccLinkSupportsCompactUnwind, ccLinkSupportsFilelist, - ccLinkIsGnu} + ccLinkSupportsSingleModule, ccLinkIsGnu} ccLink <- linkRequiresNoFixupChains archOs cc ccLink ccLink <- linkRequiresNoWarnDuplicateLibraries archOs cc ccLink return ccLink @@ -164,6 +167,35 @@ checkSupportsFilelist cc ccLink = checking "whether the cc linker understands -f return (isSuccess exitCode) +-- | Check that the (darwin) linker supports @-single_module at . +-- +-- In XCode 15, the linker warns when @-single_module@ is passed as the flag +-- became the default and is now obsolete to pass. +-- +-- We assume non-darwin linkers don't support this flag. +checkSupportsSingleModule :: ArchOS -> Cc -> Program -> M Bool +checkSupportsSingleModule archOs cc link + | ArchOS _ OSDarwin <- archOs + = checking "whether the darwin linker supports -single_module" $ do + withTempDir $ \dir -> do + let test_dylib = dir "test.dylib" + test_c = dir "test.c" + testmain_o = dir "testmain.o" + testmain = dir "testmain" + + -- Main + compileC cc testmain_o "extern int foo(int); int main() { return foo(5); }" + + -- Dynamic library + writeFile test_c "int foo(int x) { return x*x; }" + _ <- runProgram (ccProgram cc) ["-shared", "-o", test_dylib, test_c] + + (_, out, err) <- readProgram link ["-Wl,-single_module", "-o", testmain, test_dylib, testmain_o] + + return $ not $ "obsolete" `isInfixOf` err || "obsolete" `isInfixOf` out + | otherwise + = return False + -- | Check whether linking works. checkLinkWorks :: Cc -> Program -> M () checkLinkWorks cc ccLink = withTempDir $ \dir -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2e13e18da59206352f857865a66182969b9e545 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2e13e18da59206352f857865a66182969b9e545 You're receiving 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 Nov 8 18:23:22 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Wed, 08 Nov 2023 13:23:22 -0500 Subject: [Git][ghc/ghc][wip/romes/24161] 25 commits: More robust checking for DataKinds Message-ID: <654bd21a7f59d_2baaec4e14f1384794b8@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24161 at Glasgow Haskell Compiler / GHC Commits: 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - a9a2688e by Rodrigo Mesquita at 2023-11-08T18:23:19+00:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - 2c1c0cf0 by Rodrigo Mesquita at 2023-11-08T18:23:19+00:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - f8c8c55c by Rodrigo Mesquita at 2023-11-08T18:23:19+00:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - f48fe8b2 by Rodrigo Mesquita at 2023-11-08T18:23:19+00:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2e13e18da59206352f857865a66182969b9e545...f48fe8b2a3e08e6050cbd6d63e039d8bd6eb58aa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2e13e18da59206352f857865a66182969b9e545...f48fe8b2a3e08e6050cbd6d63e039d8bd6eb58aa You're receiving 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 Nov 8 20:57:34 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 08 Nov 2023 15:57:34 -0500 Subject: [Git][ghc/ghc][wip/T24083] Wibbles Message-ID: <654bf63ec43c0_2baaec51a382385029cf@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24083 at Glasgow Haskell Compiler / GHC Commits: af9ff593 by Simon Peyton Jones at 2023-11-08T20:57:22+00:00 Wibbles - - - - - 2 changed files: - compiler/GHC/Tc/Gen/HsType.hs - testsuite/tests/polykinds/T24083.stderr Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2608,7 +2608,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars sig_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars skol_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2622,11 +2622,11 @@ kcCheckDeclHeader_sig sig_kind name flav all_tv_prs = mkTyVarNamePairs (binderVars swizzled_tcbs) ; traceTc "kcCheckDeclHeader swizzle" $ vcat - [ text "implicit_prs = " <+> ppr implicit_prs - , text "implicit_nms = " <+> ppr implicit_nms - , text "hs_tv_bndrs = " <+> ppr hs_tv_bndrs - , text "all_tcbs = " <+> pprTyVars (binderVars all_tcbs) - , text "swizzled_tcbs = " <+> pprTyVars (binderVars swizzled_tcbs) + [ text "sig_tcbs =" <+> ppr sig_tcbs + , text "implicit_prs =" <+> ppr implicit_prs + , text "hs_tv_bndrs =" <+> ppr hs_tv_bndrs + , text "all_tcbs =" <+> pprTyVars (binderVars all_tcbs) + , text "swizzled_tcbs =" <+> pprTyVars (binderVars swizzled_tcbs) , text "tycon_res_kind =" <+> ppr tycon_res_kind , text "swizzled_kind =" <+> ppr swizzled_kind ] ===================================== testsuite/tests/polykinds/T24083.stderr ===================================== @@ -0,0 +1,6 @@ + +T24083.hs:13:14: error: [GHC-59738] + • Scoped type variable only appears non-injectively in declaration header: + ‘t’ bound at T24083.hs:13:14 + • In the class declaration for ‘IsSum’ + Suggested fix: bind ‘t’ explicitly with ‘@t’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af9ff5937b971780a29c8516b89c503e675e563f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af9ff5937b971780a29c8516b89c503e675e563f You're receiving 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 Nov 8 22:04:03 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 08 Nov 2023 17:04:03 -0500 Subject: [Git][ghc/ghc][wip/az/epa-remove-glrr-et-al] EPA: get rid of glRR and friends in GHC/Parser.y Message-ID: <654c05d3a9120_2baaec533c59e45052ed@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-remove-glrr-et-al at Glasgow Haskell Compiler / GHC Commits: 96d697e5 by Alan Zimmerman at 2023-11-08T22:03:48+00:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1417,7 +1417,7 @@ opt_injective_info :: { Located ([AddEpAnn], Maybe (LInjectivityAnn GhcPs)) } injectivity_cond :: { LInjectivityAnn GhcPs } : tyvarid '->' inj_varids - {% acsA (\cs -> sLL $1 $> (InjectivityAnn (EpAnn (glNR $1) [mu AnnRarrow $2] cs) $1 (reverse (unLoc $3)))) } + {% acsA (\cs -> sLL $1 $> (InjectivityAnn (EpAnn (glR $1) [mu AnnRarrow $2] cs) $1 (reverse (unLoc $3)))) } inj_varids :: { Located [LocatedN RdrName] } : inj_varids tyvarid { sLL $1 $> ($2 : unLoc $1) } @@ -2259,9 +2259,9 @@ tyop :: { (LocatedN RdrName, PromotionFlag) } ; return (op, IsPromoted) } } atype :: { LHsType GhcPs } - : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glNR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples + : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples -- See Note [%shift: atype -> tyvar] - | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glNR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) + | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) | '*' {% do { warnStarIsType (getLoc $1) ; return $ sL1a $1 (HsStarTy noExtField (isUnicode $1)) } } @@ -2347,7 +2347,7 @@ tv_bndr :: { LHsTyVarBndr Specificity GhcPs } | '{' tyvar '::' kind '}' {% acsA (\cs -> sLL $1 $> (KindedTyVar (EpAnn (glEE $1 $>) [moc $1,mu AnnDcolon $3 ,mcc $5] cs) InferredSpec $2 $4)) } tv_bndr_no_braces :: { LHsTyVarBndr Specificity GhcPs } - : tyvar {% acsA (\cs -> (sL1 $1 (UserTyVar (EpAnn (glNR $1) [] cs) SpecifiedSpec $1))) } + : tyvar {% acsA (\cs -> (sL1 $1 (UserTyVar (EpAnn (glR $1) [] cs) SpecifiedSpec $1))) } | '(' tyvar '::' kind ')' {% acsA (\cs -> (sLL $1 $> (KindedTyVar (EpAnn (glEE $1 $>) [mop $1,mu AnnDcolon $3 ,mcp $5] cs) SpecifiedSpec $2 $4))) } fds :: { Located ([AddEpAnn],[LHsFunDep GhcPs]) } @@ -2616,7 +2616,7 @@ sigdecl :: { LHsDecl GhcPs } | var ',' sig_vars '::' sigtype {% do { v <- addTrailingCommaN $1 (gl $2) - ; let sig cs = TypeSig (EpAnn (glNR $1) (AnnSig (mu AnnDcolon $4) []) cs) (v : reverse (unLoc $3)) + ; let sig cs = TypeSig (EpAnn (glR $1) (AnnSig (mu AnnDcolon $4) []) cs) (v : reverse (unLoc $3)) (mkHsWildCardBndrs $5) ; acsA (\cs -> sLL $1 $> $ SigD noExtField (sig cs) ) }} @@ -2917,14 +2917,14 @@ aexp :: { ECP } mkHsDoPV (comb2 $1 $2) (fmap mkModuleNameFS (getDO $1)) $2 - (AnnList (Just $ glAR $2) Nothing Nothing [mj AnnDo $1] []) } + (AnnList (Just $ glR $2) Nothing Nothing [mj AnnDo $1] []) } | MDO stmtlist {% hintQualifiedDo $1 >> runPV $2 >>= \ $2 -> fmap ecpFromExp $ acsA (\cs -> L (comb2 $1 $2) (mkHsDoAnns (MDoExpr $ fmap mkModuleNameFS (getMDO $1)) $2 - (EpAnn (glEE $1 $>) (AnnList (Just $ glAR $2) Nothing Nothing [mj AnnMdo $1] []) cs) )) } + (EpAnn (glEE $1 $>) (AnnList (Just $ glR $2) Nothing Nothing [mj AnnMdo $1] []) cs) )) } | 'proc' aexp '->' exp {% (checkPattern <=< runPV) (unECP $2) >>= \ p -> runPV (unECP $4) >>= \ $4 at cmd -> @@ -3467,13 +3467,13 @@ fbinds1 :: { forall b. DisambECP b => PV ([Fbind b], Maybe SrcSpan) } fbind :: { forall b. DisambECP b => PV (Fbind b) } : qvar '=' texp { unECP $3 >>= \ $3 -> - fmap Left $ acsA (\cs -> sLL $1 $> $ HsFieldBind (EpAnn (glNR $1) [mj AnnEqual $2] cs) (sL1a $1 $ mkFieldOcc $1) $3 False) } + fmap Left $ acsA (\cs -> sLL $1 $> $ HsFieldBind (EpAnn (glR $1) [mj AnnEqual $2] cs) (sL1a $1 $ mkFieldOcc $1) $3 False) } -- RHS is a 'texp', allowing view patterns (#6038) -- and, incidentally, sections. Eg -- f (R { x = show -> s }) = ... | qvar { placeHolderPunRhs >>= \rhs -> - fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glNR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } + fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } -- In the punning case, use a place-holder -- The renamer fills in the final value @@ -3514,7 +3514,7 @@ fieldToUpdate : fieldToUpdate TIGHT_INFIX_PROJ field {% getCommentsFor (getLocA $3) >>= \cs -> return (sLL $1 $> ((sLLa $2 $> (DotFieldOcc (EpAnn (glR $2) (AnnFieldLabel $ Just $ glAA $2) cs) $3)) : unLoc $1)) } | field {% getCommentsFor (getLocA $1) >>= \cs -> - return (sL1 $1 [sL1a $1 (DotFieldOcc (EpAnn (glNR $1) (AnnFieldLabel Nothing) cs) $1)]) } + return (sL1 $1 [sL1a $1 (DotFieldOcc (EpAnn (glR $1) (AnnFieldLabel Nothing) cs) $1)]) } ----------------------------------------------------------------------------- -- Implicit Parameter Bindings @@ -3599,12 +3599,12 @@ qcon :: { LocatedN RdrName } gen_qcon :: { LocatedN RdrName } : qconid { $1 } | '(' qconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } con :: { LocatedN RdrName } : conid { $1 } | '(' consym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | sysdcon { L (getLoc $1) $ nameRdrName (dataConName (unLoc $1)) } con_list :: { Located (NonEmpty (LocatedN RdrName)) } @@ -3633,12 +3633,12 @@ sysdcon :: { LocatedN DataCon } conop :: { LocatedN RdrName } : consym { $1 } | '`' conid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qconop :: { LocatedN RdrName } : qconsym { $1 } | '`' qconid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } ---------------------------------------------------------------------------- -- Type constructors @@ -3672,7 +3672,7 @@ oqtycon :: { LocatedN RdrName } -- An "ordinary" qualified tycon; -- These can appear in export lists : qtycon { $1 } | '(' qtyconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } oqtycon_no_varcon :: { LocatedN RdrName } -- Type constructor which cannot be mistaken -- for variable constructor in export lists @@ -3712,7 +3712,7 @@ qtyconop :: { LocatedN RdrName } -- Qualified or unqualified -- See Note [%shift: qtyconop -> qtyconsym] : qtyconsym %shift { $1 } | '`' qtycon '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qtycon :: { LocatedN RdrName } -- Qualified or unqualified : QCONID { sL1n $1 $! mkQual tcClsName (getQCONID $1) } @@ -3738,7 +3738,7 @@ tyconsym :: { LocatedN RdrName } otycon :: { LocatedN RdrName } : tycon { $1 } | '(' tyconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } ----------------------------------------------------------------------------- -- Operators @@ -3752,7 +3752,7 @@ op :: { LocatedN RdrName } -- used in infix decls varop :: { LocatedN RdrName } : varsym { $1 } | '`' varid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qop :: { forall b. DisambInfixOp b => PV (LocatedN b) } -- used in sections : qvarop { mkHsVarOpPV $1 } @@ -3771,12 +3771,12 @@ hole_op : '`' '_' '`' { mkHsInfixHolePV (comb2 $1 $>) qvarop :: { LocatedN RdrName } : qvarsym { $1 } | '`' qvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qvaropm :: { LocatedN RdrName } : qvarsym_no_minus { $1 } | '`' qvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } ----------------------------------------------------------------------------- -- Type variables @@ -3786,7 +3786,7 @@ tyvar : tyvarid { $1 } tyvarop :: { LocatedN RdrName } tyvarop : '`' tyvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } tyvarid :: { LocatedN RdrName } : VARID { sL1n $1 $! mkUnqual tvName (getVARID $1) } @@ -3804,14 +3804,14 @@ tyvarid :: { LocatedN RdrName } var :: { LocatedN RdrName } : varid { $1 } | '(' varsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } qvar :: { LocatedN RdrName } : qvarid { $1 } | '(' varsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '(' qvarsym1 ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } -- We've inlined qvarsym here so that the decision about -- whether it's a qvar or a var can be postponed until -- *after* we see the close paren. @@ -4265,7 +4265,7 @@ mj :: AnnKeywordId -> Located e -> AddEpAnn mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (srcSpan2e $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glA l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width @@ -4295,17 +4295,19 @@ toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a toUnicode :: Located Token -> IsUnicodeSyntax toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax +-- ------------------------------------- + gl :: GenLocated l a -> l gl = getLoc -glA :: LocatedAn t a -> SrcSpan -glA = getLocA +glA :: HasLoc a => a -> SrcSpan +glA = getHasLoc -glN :: LocatedN a -> SrcSpan -glN = getLocA +glRR :: Located a -> RealSrcSpan +glRR = realSrcSpan . getLoc -glR :: Located a -> Anchor -glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor +glR :: HasLoc a => a -> Anchor +glR la = Anchor (realSrcSpan $ getHasLoc la) UnchangedAnchor glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4314,30 +4316,18 @@ glMR _ la = glR la glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y +anc :: RealSrcSpan -> Anchor +anc r = Anchor r UnchangedAnchor + glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l -glAA :: Located a -> EpaLocation -glAA = srcSpan2e . getLoc - -glRR :: Located a -> RealSrcSpan -glRR = realSrcSpan . getLoc - -glAR :: LocatedAn t a -> Anchor -glAR la = Anchor (realSrcSpan $ getLocA la) UnchangedAnchor - -glNR :: LocatedN a -> Anchor -glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor - -glNRR :: LocatedN a -> EpaLocation -glNRR = srcSpan2e . getLocA +glAA :: HasLoc a => a -> EpaLocation +glAA = srcSpan2e . getHasLoc n2l :: LocatedN a -> LocatedA a n2l (L la a) = L (l2l la) a -anc :: RealSrcSpan -> Anchor -anc r = Anchor r UnchangedAnchor - acs :: MonadP m => (EpAnnComments -> Located a) -> m (Located a) acs a = do let (L l _) = a emptyComments @@ -4356,7 +4346,6 @@ acsFinal a = do Strict.Just (pos `Strict.And` gap) -> Just (pos,gap) return (a (cs Semi.<> csf) ce) - acsa :: MonadP m => (EpAnnComments -> LocatedAn t a) -> m (LocatedAn t a) acsa a = do let (L l _) = a emptyComments View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96d697e51d442e25a455d03919d098c8fc464ded -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96d697e51d442e25a455d03919d098c8fc464ded You're receiving 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 Nov 9 09:26:57 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 09 Nov 2023 04:26:57 -0500 Subject: [Git][ghc/ghc][wip/T24083] Another wibble Message-ID: <654ca5e122a8a_2baaec6318dba853652d@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24083 at Glasgow Haskell Compiler / GHC Commits: 426d22b7 by Simon Peyton Jones at 2023-11-09T09:26:45+00:00 Another wibble - - - - - 1 changed file: - compiler/GHC/Tc/Gen/HsType.hs Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2608,7 +2608,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars skol_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/426d22b7eb0859df2730383148f474abf167b5fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/426d22b7eb0859df2730383148f474abf167b5fe You're receiving 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 Nov 9 11:11:52 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 06:11:52 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Elaborate on the quantified superclass of Bifunctor Message-ID: <654cbe78d22b3_2baaec65c104ac55305a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 1522520c by Matthew Craven at 2023-11-09T06:11:47-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 91edc4ed by Alan Zimmerman at 2023-11-09T06:11:48-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.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/1163a38a2fabddf037afd705218b5c74e7c34e3c...91edc4ed1f1b26c5f875892af0f51f00565ebe92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1163a38a2fabddf037afd705218b5c74e7c34e3c...91edc4ed1f1b26c5f875892af0f51f00565ebe92 You're receiving 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 Nov 9 13:42:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 08:42:42 -0500 Subject: [Git][ghc/ghc][master] Create specially-solved DataToTag class Message-ID: <654ce1d28dca4_2baaec68f8d334568845@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Validity.hs - docs/users_guide/9.10.1-notes.rst - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-prim/GHC/Magic.hs - libraries/ghc-prim/changelog.md - + testsuite/tests/backpack/should_run/T15379-DataToTag.bkp - + testsuite/tests/backpack/should_run/T15379-DataToTag.stderr - testsuite/tests/backpack/should_run/all.T - testsuite/tests/codeGen/should_compile/cg006.hs - testsuite/tests/deriving/should_compile/T17240.stderr - testsuite/tests/deriving/should_compile/all.T - + testsuite/tests/deriving/should_compile/drv023.hs - + testsuite/tests/gadt/T23023.stderr - testsuite/tests/gadt/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/455524a261ae64249017583928010472bece5c08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/455524a261ae64249017583928010472bece5c08 You're receiving 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 Nov 9 13:43:16 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 08:43:16 -0500 Subject: [Git][ghc/ghc][master] EPA: get rid of glRR and friends in GHC/Parser.y Message-ID: <654ce1f4714d2_2baaec694e26b85727b1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1417,7 +1417,7 @@ opt_injective_info :: { Located ([AddEpAnn], Maybe (LInjectivityAnn GhcPs)) } injectivity_cond :: { LInjectivityAnn GhcPs } : tyvarid '->' inj_varids - {% acsA (\cs -> sLL $1 $> (InjectivityAnn (EpAnn (glNR $1) [mu AnnRarrow $2] cs) $1 (reverse (unLoc $3)))) } + {% acsA (\cs -> sLL $1 $> (InjectivityAnn (EpAnn (glR $1) [mu AnnRarrow $2] cs) $1 (reverse (unLoc $3)))) } inj_varids :: { Located [LocatedN RdrName] } : inj_varids tyvarid { sLL $1 $> ($2 : unLoc $1) } @@ -2259,9 +2259,9 @@ tyop :: { (LocatedN RdrName, PromotionFlag) } ; return (op, IsPromoted) } } atype :: { LHsType GhcPs } - : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glNR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples + : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples -- See Note [%shift: atype -> tyvar] - | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glNR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) + | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) | '*' {% do { warnStarIsType (getLoc $1) ; return $ sL1a $1 (HsStarTy noExtField (isUnicode $1)) } } @@ -2347,7 +2347,7 @@ tv_bndr :: { LHsTyVarBndr Specificity GhcPs } | '{' tyvar '::' kind '}' {% acsA (\cs -> sLL $1 $> (KindedTyVar (EpAnn (glEE $1 $>) [moc $1,mu AnnDcolon $3 ,mcc $5] cs) InferredSpec $2 $4)) } tv_bndr_no_braces :: { LHsTyVarBndr Specificity GhcPs } - : tyvar {% acsA (\cs -> (sL1 $1 (UserTyVar (EpAnn (glNR $1) [] cs) SpecifiedSpec $1))) } + : tyvar {% acsA (\cs -> (sL1 $1 (UserTyVar (EpAnn (glR $1) [] cs) SpecifiedSpec $1))) } | '(' tyvar '::' kind ')' {% acsA (\cs -> (sLL $1 $> (KindedTyVar (EpAnn (glEE $1 $>) [mop $1,mu AnnDcolon $3 ,mcp $5] cs) SpecifiedSpec $2 $4))) } fds :: { Located ([AddEpAnn],[LHsFunDep GhcPs]) } @@ -2616,7 +2616,7 @@ sigdecl :: { LHsDecl GhcPs } | var ',' sig_vars '::' sigtype {% do { v <- addTrailingCommaN $1 (gl $2) - ; let sig cs = TypeSig (EpAnn (glNR $1) (AnnSig (mu AnnDcolon $4) []) cs) (v : reverse (unLoc $3)) + ; let sig cs = TypeSig (EpAnn (glR $1) (AnnSig (mu AnnDcolon $4) []) cs) (v : reverse (unLoc $3)) (mkHsWildCardBndrs $5) ; acsA (\cs -> sLL $1 $> $ SigD noExtField (sig cs) ) }} @@ -2917,14 +2917,14 @@ aexp :: { ECP } mkHsDoPV (comb2 $1 $2) (fmap mkModuleNameFS (getDO $1)) $2 - (AnnList (Just $ glAR $2) Nothing Nothing [mj AnnDo $1] []) } + (AnnList (Just $ glR $2) Nothing Nothing [mj AnnDo $1] []) } | MDO stmtlist {% hintQualifiedDo $1 >> runPV $2 >>= \ $2 -> fmap ecpFromExp $ acsA (\cs -> L (comb2 $1 $2) (mkHsDoAnns (MDoExpr $ fmap mkModuleNameFS (getMDO $1)) $2 - (EpAnn (glEE $1 $>) (AnnList (Just $ glAR $2) Nothing Nothing [mj AnnMdo $1] []) cs) )) } + (EpAnn (glEE $1 $>) (AnnList (Just $ glR $2) Nothing Nothing [mj AnnMdo $1] []) cs) )) } | 'proc' aexp '->' exp {% (checkPattern <=< runPV) (unECP $2) >>= \ p -> runPV (unECP $4) >>= \ $4 at cmd -> @@ -3467,13 +3467,13 @@ fbinds1 :: { forall b. DisambECP b => PV ([Fbind b], Maybe SrcSpan) } fbind :: { forall b. DisambECP b => PV (Fbind b) } : qvar '=' texp { unECP $3 >>= \ $3 -> - fmap Left $ acsA (\cs -> sLL $1 $> $ HsFieldBind (EpAnn (glNR $1) [mj AnnEqual $2] cs) (sL1a $1 $ mkFieldOcc $1) $3 False) } + fmap Left $ acsA (\cs -> sLL $1 $> $ HsFieldBind (EpAnn (glR $1) [mj AnnEqual $2] cs) (sL1a $1 $ mkFieldOcc $1) $3 False) } -- RHS is a 'texp', allowing view patterns (#6038) -- and, incidentally, sections. Eg -- f (R { x = show -> s }) = ... | qvar { placeHolderPunRhs >>= \rhs -> - fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glNR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } + fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } -- In the punning case, use a place-holder -- The renamer fills in the final value @@ -3514,7 +3514,7 @@ fieldToUpdate : fieldToUpdate TIGHT_INFIX_PROJ field {% getCommentsFor (getLocA $3) >>= \cs -> return (sLL $1 $> ((sLLa $2 $> (DotFieldOcc (EpAnn (glR $2) (AnnFieldLabel $ Just $ glAA $2) cs) $3)) : unLoc $1)) } | field {% getCommentsFor (getLocA $1) >>= \cs -> - return (sL1 $1 [sL1a $1 (DotFieldOcc (EpAnn (glNR $1) (AnnFieldLabel Nothing) cs) $1)]) } + return (sL1 $1 [sL1a $1 (DotFieldOcc (EpAnn (glR $1) (AnnFieldLabel Nothing) cs) $1)]) } ----------------------------------------------------------------------------- -- Implicit Parameter Bindings @@ -3599,12 +3599,12 @@ qcon :: { LocatedN RdrName } gen_qcon :: { LocatedN RdrName } : qconid { $1 } | '(' qconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } con :: { LocatedN RdrName } : conid { $1 } | '(' consym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | sysdcon { L (getLoc $1) $ nameRdrName (dataConName (unLoc $1)) } con_list :: { Located (NonEmpty (LocatedN RdrName)) } @@ -3633,12 +3633,12 @@ sysdcon :: { LocatedN DataCon } conop :: { LocatedN RdrName } : consym { $1 } | '`' conid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qconop :: { LocatedN RdrName } : qconsym { $1 } | '`' qconid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } ---------------------------------------------------------------------------- -- Type constructors @@ -3672,7 +3672,7 @@ oqtycon :: { LocatedN RdrName } -- An "ordinary" qualified tycon; -- These can appear in export lists : qtycon { $1 } | '(' qtyconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } oqtycon_no_varcon :: { LocatedN RdrName } -- Type constructor which cannot be mistaken -- for variable constructor in export lists @@ -3712,7 +3712,7 @@ qtyconop :: { LocatedN RdrName } -- Qualified or unqualified -- See Note [%shift: qtyconop -> qtyconsym] : qtyconsym %shift { $1 } | '`' qtycon '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qtycon :: { LocatedN RdrName } -- Qualified or unqualified : QCONID { sL1n $1 $! mkQual tcClsName (getQCONID $1) } @@ -3738,7 +3738,7 @@ tyconsym :: { LocatedN RdrName } otycon :: { LocatedN RdrName } : tycon { $1 } | '(' tyconsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } ----------------------------------------------------------------------------- -- Operators @@ -3752,7 +3752,7 @@ op :: { LocatedN RdrName } -- used in infix decls varop :: { LocatedN RdrName } : varsym { $1 } | '`' varid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qop :: { forall b. DisambInfixOp b => PV (LocatedN b) } -- used in sections : qvarop { mkHsVarOpPV $1 } @@ -3771,12 +3771,12 @@ hole_op : '`' '_' '`' { mkHsInfixHolePV (comb2 $1 $>) qvarop :: { LocatedN RdrName } : qvarsym { $1 } | '`' qvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } qvaropm :: { LocatedN RdrName } : qvarsym_no_minus { $1 } | '`' qvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } ----------------------------------------------------------------------------- -- Type variables @@ -3786,7 +3786,7 @@ tyvar : tyvarid { $1 } tyvarop :: { LocatedN RdrName } tyvarop : '`' tyvarid '`' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameBackquotes (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameBackquotes (glAA $1) (glAA $2) (glAA $3) []) } tyvarid :: { LocatedN RdrName } : VARID { sL1n $1 $! mkUnqual tvName (getVARID $1) } @@ -3804,14 +3804,14 @@ tyvarid :: { LocatedN RdrName } var :: { LocatedN RdrName } : varid { $1 } | '(' varsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } qvar :: { LocatedN RdrName } : qvarid { $1 } | '(' varsym ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '(' qvarsym1 ')' {% amsrn (sLL $1 $> (unLoc $2)) - (NameAnn NameParens (glAA $1) (glNRR $2) (glAA $3) []) } + (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } -- We've inlined qvarsym here so that the decision about -- whether it's a qvar or a var can be postponed until -- *after* we see the close paren. @@ -4265,7 +4265,7 @@ mj :: AnnKeywordId -> Located e -> AddEpAnn mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (srcSpan2e $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glA l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width @@ -4295,17 +4295,19 @@ toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a toUnicode :: Located Token -> IsUnicodeSyntax toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax +-- ------------------------------------- + gl :: GenLocated l a -> l gl = getLoc -glA :: LocatedAn t a -> SrcSpan -glA = getLocA +glA :: HasLoc a => a -> SrcSpan +glA = getHasLoc -glN :: LocatedN a -> SrcSpan -glN = getLocA +glRR :: Located a -> RealSrcSpan +glRR = realSrcSpan . getLoc -glR :: Located a -> Anchor -glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor +glR :: HasLoc a => a -> Anchor +glR la = Anchor (realSrcSpan $ getHasLoc la) UnchangedAnchor glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4314,30 +4316,18 @@ glMR _ la = glR la glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y +anc :: RealSrcSpan -> Anchor +anc r = Anchor r UnchangedAnchor + glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l -glAA :: Located a -> EpaLocation -glAA = srcSpan2e . getLoc - -glRR :: Located a -> RealSrcSpan -glRR = realSrcSpan . getLoc - -glAR :: LocatedAn t a -> Anchor -glAR la = Anchor (realSrcSpan $ getLocA la) UnchangedAnchor - -glNR :: LocatedN a -> Anchor -glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor - -glNRR :: LocatedN a -> EpaLocation -glNRR = srcSpan2e . getLocA +glAA :: HasLoc a => a -> EpaLocation +glAA = srcSpan2e . getHasLoc n2l :: LocatedN a -> LocatedA a n2l (L la a) = L (l2l la) a -anc :: RealSrcSpan -> Anchor -anc r = Anchor r UnchangedAnchor - acs :: MonadP m => (EpAnnComments -> Located a) -> m (Located a) acs a = do let (L l _) = a emptyComments @@ -4356,7 +4346,6 @@ acsFinal a = do Strict.Just (pos `Strict.And` gap) -> Just (pos,gap) return (a (cs Semi.<> csf) ce) - acsa :: MonadP m => (EpAnnComments -> LocatedAn t a) -> m (LocatedAn t a) acsa a = do let (L l _) = a emptyComments View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a05f4554d9c7e18e73bbc7bd8110cef485347c38 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a05f4554d9c7e18e73bbc7bd8110cef485347c38 You're receiving 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 Nov 9 14:47:25 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Thu, 09 Nov 2023 09:47:25 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/deprecate-wsemigroup Message-ID: <654cf0fdb0c69_2baaec6b3e7dc45787f5@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/deprecate-wsemigroup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/deprecate-wsemigroup You're receiving 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 Nov 9 15:15:55 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 09 Nov 2023 10:15:55 -0500 Subject: [Git][ghc/ghc][wip/T24083] 3 commits: Create specially-solved DataToTag class Message-ID: <654cf7ab6b0ea_2baaec6bfb0ae858683c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24083 at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 713bcdc7 by Simon Peyton Jones at 2023-11-09T15:13:56+00:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Module.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/9.10.1-notes.rst - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-prim/GHC/Magic.hs - libraries/ghc-prim/changelog.md - + testsuite/tests/backpack/should_run/T15379-DataToTag.bkp - + testsuite/tests/backpack/should_run/T15379-DataToTag.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/426d22b7eb0859df2730383148f474abf167b5fe...713bcdc7fe951ac06bedea3e24a525036e6e13f3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/426d22b7eb0859df2730383148f474abf167b5fe...713bcdc7fe951ac06bedea3e24a525036e6e13f3 You're receiving 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 Nov 9 18:45:47 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 13:45:47 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Create specially-solved DataToTag class Message-ID: <654d28dbe764_2baaec70c7c9e461555d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 56ba3cfd by PHO at 2023-11-09T16:01:46+00:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - c6d11886 by PHO at 2023-11-09T13:45:13-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - eb9a8b96 by Simon Peyton Jones at 2023-11-09T13:45:13-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Module.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/9.10.1-notes.rst - hadrian/src/Builder.hs - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/ghc-prim/GHC/Magic.hs - libraries/ghc-prim/changelog.md - rts/configure.ac The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91edc4ed1f1b26c5f875892af0f51f00565ebe92...eb9a8b969590358fa718fe9e7d4626ac29932074 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91edc4ed1f1b26c5f875892af0f51f00565ebe92...eb9a8b969590358fa718fe9e7d4626ac29932074 You're receiving 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 Nov 9 20:14:06 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 09 Nov 2023 15:14:06 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-harmonise-acsa Message-ID: <654d3d8eda448_2baaec72fe7780622736@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-harmonise-acsa at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-harmonise-acsa You're receiving 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 Nov 9 21:45:45 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 16:45:45 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: ci: bump ci-images for wasi-sdk upgrade Message-ID: <654d5309215f9_2baaec7551f2c8636015@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - e72d2c02 by PHO at 2023-11-09T16:45:33-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 1b41d4e3 by PHO at 2023-11-09T16:45:34-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - b00fd698 by Simon Peyton Jones at 2023-11-09T16:45:35-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 13 changed files: - .gitlab-ci.yml - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - hadrian/src/Builder.hs - rts/configure.ac - + testsuite/tests/polykinds/T24083.hs - + testsuite/tests/polykinds/T24083.stderr - testsuite/tests/polykinds/all.T - utils/genprimopcode/Main.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: a55d4ae0f9da0a2fb3bc72a13f356e2511a4c4fd + DOCKER_REV: cf2ba8e205bd41ac36f39e1a12b4727f899ded75 # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -999,6 +999,12 @@ instance Diagnostic TcRnMessage where -- Note [Swizzling the tyvars before generaliseTcTyCon] = vcat [ quotes (ppr n1) <+> text "bound at" <+> ppr (getSrcLoc n1) , quotes (ppr n2) <+> text "bound at" <+> ppr (getSrcLoc n2) ] + + TcRnDisconnectedTyVar n + -> mkSimpleDecorated $ + hang (text "Scoped type variable only appears non-injectively in declaration header:") + 2 (quotes (ppr n) <+> text "bound at" <+> ppr (getSrcLoc n)) + TcRnInvalidReturnKind data_sort allowed_kind kind _suggested_ext -> mkSimpleDecorated $ sep [ ppDataSort data_sort <+> @@ -2201,6 +2207,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDifferentNamesForTyVar{} -> ErrorWithoutFlag + TcRnDisconnectedTyVar{} + -> ErrorWithoutFlag TcRnInvalidReturnKind{} -> ErrorWithoutFlag TcRnClassKindNotConstraint{} @@ -2842,6 +2850,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnDifferentNamesForTyVar{} -> noHints + TcRnDisconnectedTyVar n + -> [SuggestBindTyVarExplicitly n] TcRnInvalidReturnKind _ _ _ mb_suggest_unlifted_ext -> case mb_suggest_unlifted_ext of Nothing -> noHints ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2276,6 +2276,13 @@ data TcRnMessage where -} TcRnDifferentNamesForTyVar :: !Name -> !Name -> TcRnMessage + {-| TcRnDisconnectedTyVar is an error for a data declaration that has a kind signature, + where the implicitly-bound type type variables can't be matched up unambiguously + with the ones from the signature. See Note [Disconnected type variables] in + GHC.Tc.Gen.HsType. + -} + TcRnDisconnectedTyVar :: !Name -> TcRnMessage + {-| TcRnInvalidReturnKind is an error for a data declaration that has a kind signature with an invalid result kind. ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2608,6 +2608,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs + ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2621,11 +2622,11 @@ kcCheckDeclHeader_sig sig_kind name flav all_tv_prs = mkTyVarNamePairs (binderVars swizzled_tcbs) ; traceTc "kcCheckDeclHeader swizzle" $ vcat - [ text "implicit_prs = " <+> ppr implicit_prs - , text "implicit_nms = " <+> ppr implicit_nms - , text "hs_tv_bndrs = " <+> ppr hs_tv_bndrs - , text "all_tcbs = " <+> pprTyVars (binderVars all_tcbs) - , text "swizzled_tcbs = " <+> pprTyVars (binderVars swizzled_tcbs) + [ text "sig_tcbs =" <+> ppr sig_tcbs + , text "implicit_prs =" <+> ppr implicit_prs + , text "hs_tv_bndrs =" <+> ppr hs_tv_bndrs + , text "all_tcbs =" <+> pprTyVars (binderVars all_tcbs) + , text "swizzled_tcbs =" <+> pprTyVars (binderVars swizzled_tcbs) , text "tycon_res_kind =" <+> ppr tycon_res_kind , text "swizzled_kind =" <+> ppr swizzled_kind ] @@ -2963,6 +2964,22 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} +checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +-- See Note [Disconnected type variables] +-- `scoped_prs` is the mapping gotten by unifying +-- - the standalone kind signature for T, with +-- - the header of the type/class declaration for T +checkForDisconnectedScopedTyVars sig_tcbs scoped_prs + = mapM_ report_disconnected (filterOut ok scoped_prs) + where + sig_tvs = mkVarSet (binderVars sig_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + + report_disconnected :: (Name,TcTyVar) -> TcM () + report_disconnected (nm, _) + = setSrcSpan (getSrcSpan nm) $ + addErrTc $ TcRnDisconnectedTyVar nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -2993,6 +3010,45 @@ checkForDuplicateScopedTyVars scoped_prs addErrTc $ TcRnDifferentNamesForTyVar n1 n2 +{- Note [Disconnected type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This note applies when kind-checking the header of a type/class decl that has +a separate, standalone kind signature. See #24083. + +Consider: + type S a = Type + + type C :: forall k. S k -> Constraint + class C (a :: S kk) where + op :: ...kk... + +Note that the class has a separate kind signature, so the elaborated decl should +look like + class C @kk (a :: S kk) where ... + +But how can we "connect up" the scoped variable `kk` with the skolem kind from the +standalone kind signature for `C`? In general we do this by unifying the two. +For example + type T k = (k,Type) + type W :: forall k. T k -> Type + data W (a :: (x,Type)) = ..blah blah.. + +When we encounter (a :: (x,Type)) we unify the kind (x,Type) with the kind (T k) +from the standalone kind signature. Of course, unification looks through synonyms +so we end up with the mapping [x :-> k] that connects the scoped type variable `x` +with the kind from the signature. + +But in our earlier example this unification is ineffective -- because `S` is a +phantom synonym that just discards its argument. So our plan is this: + + if matchUpSigWithDecl fails to connect `kk with `k`, by unification, + we give up and complain about a "disconnected" type variable. + +See #24083 for dicussion of alternatives, none satisfactory. Also the fix is +easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` +explicitly, rather than binding it implicitly via unification. +-} + {- ********************************************************************* * * Bringing type variables into scope ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -477,6 +477,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvalidVisibleKindArgument" = 20967 GhcDiagnosticCode "TcRnTooManyBinders" = 05989 GhcDiagnosticCode "TcRnDifferentNamesForTyVar" = 17370 + GhcDiagnosticCode "TcRnDisconnectedTyVar" = 59738 GhcDiagnosticCode "TcRnInvalidReturnKind" = 55233 GhcDiagnosticCode "TcRnClassKindNotConstraint" = 80768 GhcDiagnosticCode "TcRnMatchesHaveDiffNumArgs" = 91938 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -480,6 +480,10 @@ data GhcHint {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} | SuggestExplicitQuantification RdrName + + {-| Suggest binding explicitly; e.g data T @k (a :: F k) = .... -} + | SuggestBindTyVarExplicitly Name + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -271,6 +271,9 @@ instance Outputable GhcHint where SuggestExplicitQuantification tv -> hsep [ text "Use an explicit", quotes (text "forall") , text "to quantify over", quotes (ppr tv) ] + SuggestBindTyVarExplicitly tv + -> text "bind" <+> quotes (ppr tv) + <+> text "explicitly with" <+> quotes (char '@' <> ppr tv) perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== hadrian/src/Builder.hs ===================================== @@ -333,8 +333,8 @@ instance H.Builder Builder where GenApply -> captureStdout GenPrimopCode -> do - stdin <- readFile' input - Stdout stdout <- cmd' (Stdin stdin) [path] buildArgs buildOptions + need [input] + Stdout stdout <- cmd' (FileStdin input) [path] buildArgs buildOptions -- see Note [Capture stdout as a ByteString] writeFileChangedBS output stdout ===================================== rts/configure.ac ===================================== @@ -408,7 +408,7 @@ dnl See Note [Undefined symbols in the RTS] [ symbolExtraDefs='' -if [[ "$CABAL_FLAG_find_ptr" = 1 ]]; then +if [ "$CABAL_FLAG_find_ptr" = 1 ]; then symbolExtraDefs+=' -DFIND_PTR' fi @@ -418,7 +418,7 @@ cat $srcdir/external-symbols.list.in \ > external-symbols.list \ || exit 1 -if [[ "$CABAL_FLAG_leading_underscore" = 1 ]]; then +if [ "$CABAL_FLAG_leading_underscore" = 1 ]; then sedExpr='s/^(.*)$/ "-Wl,-u,_\1"/' else sedExpr='s/^(.*)$/ "-Wl,-u,\1"/' ===================================== testsuite/tests/polykinds/T24083.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} + +module T24083 where +import Data.Kind (Constraint, Type) + +data family Pi t :: Type + +type FunctionSymbol :: Type -> Type +type FunctionSymbol t = Type + +type IsSum :: forall s. FunctionSymbol s -> Constraint +class IsSum (sumf :: FunctionSymbol t) where + sumConNames :: Pi t ===================================== testsuite/tests/polykinds/T24083.stderr ===================================== @@ -0,0 +1,6 @@ + +T24083.hs:13:14: error: [GHC-59738] + • Scoped type variable only appears non-injectively in declaration header: + ‘t’ bound at T24083.hs:13:14 + • In the class declaration for ‘IsSum’ + Suggested fix: bind ‘t’ explicitly with ‘@t’ ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -243,3 +243,4 @@ test('T22379b', normal, compile, ['']) test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) +test('T24083', normal, compile_fail, ['']) ===================================== utils/genprimopcode/Main.hs ===================================== @@ -13,6 +13,7 @@ import Data.Char import Data.List (union, intersperse, intercalate, nub) import Data.Maybe ( catMaybes ) import System.Environment ( getArgs ) +import System.IO ( hSetEncoding, stdin, stdout, utf8 ) vecOptions :: Entry -> [(String,String,Int)] vecOptions i = @@ -116,7 +117,9 @@ main = getArgs >>= \args -> ++ unlines (map (" "++) known_args) ) else - do s <- getContents + do hSetEncoding stdin utf8 -- The input file is in UTF-8. Set the encoding explicitly. + hSetEncoding stdout utf8 + s <- getContents case parse s of Left err -> error ("parse error at " ++ (show err)) Right p_o_specs@(Info _ _) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb9a8b969590358fa718fe9e7d4626ac29932074...b00fd69815e01806fc591203a2ac25733ee1dc71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb9a8b969590358fa718fe9e7d4626ac29932074...b00fd69815e01806fc591203a2ac25733ee1dc71 You're receiving 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 Nov 10 00:16:12 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 19:16:12 -0500 Subject: [Git][ghc/ghc][master] ci: bump ci-images for wasi-sdk upgrade Message-ID: <654d764c8c834_2baaec78ea56f06582a5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: a55d4ae0f9da0a2fb3bc72a13f356e2511a4c4fd + DOCKER_REV: cf2ba8e205bd41ac36f39e1a12b4727f899ded75 # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/184985389db646ff92b1b6f0f242241bf1da75d8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/184985389db646ff92b1b6f0f242241bf1da75d8 You're receiving 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 Nov 10 00:17:01 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 19:17:01 -0500 Subject: [Git][ghc/ghc][master] Don't assume the current locale is *.UTF-8, set the encoding explicitly Message-ID: <654d767d91733_2baaec78ea56f0661567@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 2 changed files: - hadrian/src/Builder.hs - utils/genprimopcode/Main.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -333,8 +333,8 @@ instance H.Builder Builder where GenApply -> captureStdout GenPrimopCode -> do - stdin <- readFile' input - Stdout stdout <- cmd' (Stdin stdin) [path] buildArgs buildOptions + need [input] + Stdout stdout <- cmd' (FileStdin input) [path] buildArgs buildOptions -- see Note [Capture stdout as a ByteString] writeFileChangedBS output stdout ===================================== utils/genprimopcode/Main.hs ===================================== @@ -13,6 +13,7 @@ import Data.Char import Data.List (union, intersperse, intercalate, nub) import Data.Maybe ( catMaybes ) import System.Environment ( getArgs ) +import System.IO ( hSetEncoding, stdin, stdout, utf8 ) vecOptions :: Entry -> [(String,String,Int)] vecOptions i = @@ -116,7 +117,9 @@ main = getArgs >>= \args -> ++ unlines (map (" "++) known_args) ) else - do s <- getContents + do hSetEncoding stdin utf8 -- The input file is in UTF-8. Set the encoding explicitly. + hSetEncoding stdout utf8 + s <- getContents case parse s of Left err -> error ("parse error at " ++ (show err)) Right p_o_specs@(Info _ _) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52c0fc691e6501e99a96693ec1fc02e3c93a4fbc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52c0fc691e6501e99a96693ec1fc02e3c93a4fbc You're receiving 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 Nov 10 00:17:44 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 19:17:44 -0500 Subject: [Git][ghc/ghc][master] Use '[' instead of '[[' because the latter is a Bash-ism Message-ID: <654d76a8627c6_2baaec78d9856466484f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 1 changed file: - rts/configure.ac Changes: ===================================== rts/configure.ac ===================================== @@ -408,7 +408,7 @@ dnl See Note [Undefined symbols in the RTS] [ symbolExtraDefs='' -if [[ "$CABAL_FLAG_find_ptr" = 1 ]]; then +if [ "$CABAL_FLAG_find_ptr" = 1 ]; then symbolExtraDefs+=' -DFIND_PTR' fi @@ -418,7 +418,7 @@ cat $srcdir/external-symbols.list.in \ > external-symbols.list \ || exit 1 -if [[ "$CABAL_FLAG_leading_underscore" = 1 ]]; then +if [ "$CABAL_FLAG_leading_underscore" = 1 ]; then sedExpr='s/^(.*)$/ "-Wl,-u,_\1"/' else sedExpr='s/^(.*)$/ "-Wl,-u,\1"/' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7233b3b1f88cdc8bc9b4e2c0235ab158ecbe9913 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7233b3b1f88cdc8bc9b4e2c0235ab158ecbe9913 You're receiving 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 Nov 10 00:18:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 09 Nov 2023 19:18:32 -0500 Subject: [Git][ghc/ghc][master] Add an extra check in kcCheckDeclHeader_sig Message-ID: <654d76d826885_2baaec78d68d00668115@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 9 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - + testsuite/tests/polykinds/T24083.hs - + testsuite/tests/polykinds/T24083.stderr - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -999,6 +999,12 @@ instance Diagnostic TcRnMessage where -- Note [Swizzling the tyvars before generaliseTcTyCon] = vcat [ quotes (ppr n1) <+> text "bound at" <+> ppr (getSrcLoc n1) , quotes (ppr n2) <+> text "bound at" <+> ppr (getSrcLoc n2) ] + + TcRnDisconnectedTyVar n + -> mkSimpleDecorated $ + hang (text "Scoped type variable only appears non-injectively in declaration header:") + 2 (quotes (ppr n) <+> text "bound at" <+> ppr (getSrcLoc n)) + TcRnInvalidReturnKind data_sort allowed_kind kind _suggested_ext -> mkSimpleDecorated $ sep [ ppDataSort data_sort <+> @@ -2201,6 +2207,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDifferentNamesForTyVar{} -> ErrorWithoutFlag + TcRnDisconnectedTyVar{} + -> ErrorWithoutFlag TcRnInvalidReturnKind{} -> ErrorWithoutFlag TcRnClassKindNotConstraint{} @@ -2842,6 +2850,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnDifferentNamesForTyVar{} -> noHints + TcRnDisconnectedTyVar n + -> [SuggestBindTyVarExplicitly n] TcRnInvalidReturnKind _ _ _ mb_suggest_unlifted_ext -> case mb_suggest_unlifted_ext of Nothing -> noHints ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2276,6 +2276,13 @@ data TcRnMessage where -} TcRnDifferentNamesForTyVar :: !Name -> !Name -> TcRnMessage + {-| TcRnDisconnectedTyVar is an error for a data declaration that has a kind signature, + where the implicitly-bound type type variables can't be matched up unambiguously + with the ones from the signature. See Note [Disconnected type variables] in + GHC.Tc.Gen.HsType. + -} + TcRnDisconnectedTyVar :: !Name -> TcRnMessage + {-| TcRnInvalidReturnKind is an error for a data declaration that has a kind signature with an invalid result kind. ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2608,6 +2608,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs + ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2621,11 +2622,11 @@ kcCheckDeclHeader_sig sig_kind name flav all_tv_prs = mkTyVarNamePairs (binderVars swizzled_tcbs) ; traceTc "kcCheckDeclHeader swizzle" $ vcat - [ text "implicit_prs = " <+> ppr implicit_prs - , text "implicit_nms = " <+> ppr implicit_nms - , text "hs_tv_bndrs = " <+> ppr hs_tv_bndrs - , text "all_tcbs = " <+> pprTyVars (binderVars all_tcbs) - , text "swizzled_tcbs = " <+> pprTyVars (binderVars swizzled_tcbs) + [ text "sig_tcbs =" <+> ppr sig_tcbs + , text "implicit_prs =" <+> ppr implicit_prs + , text "hs_tv_bndrs =" <+> ppr hs_tv_bndrs + , text "all_tcbs =" <+> pprTyVars (binderVars all_tcbs) + , text "swizzled_tcbs =" <+> pprTyVars (binderVars swizzled_tcbs) , text "tycon_res_kind =" <+> ppr tycon_res_kind , text "swizzled_kind =" <+> ppr swizzled_kind ] @@ -2963,6 +2964,22 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} +checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +-- See Note [Disconnected type variables] +-- `scoped_prs` is the mapping gotten by unifying +-- - the standalone kind signature for T, with +-- - the header of the type/class declaration for T +checkForDisconnectedScopedTyVars sig_tcbs scoped_prs + = mapM_ report_disconnected (filterOut ok scoped_prs) + where + sig_tvs = mkVarSet (binderVars sig_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + + report_disconnected :: (Name,TcTyVar) -> TcM () + report_disconnected (nm, _) + = setSrcSpan (getSrcSpan nm) $ + addErrTc $ TcRnDisconnectedTyVar nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -2993,6 +3010,45 @@ checkForDuplicateScopedTyVars scoped_prs addErrTc $ TcRnDifferentNamesForTyVar n1 n2 +{- Note [Disconnected type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This note applies when kind-checking the header of a type/class decl that has +a separate, standalone kind signature. See #24083. + +Consider: + type S a = Type + + type C :: forall k. S k -> Constraint + class C (a :: S kk) where + op :: ...kk... + +Note that the class has a separate kind signature, so the elaborated decl should +look like + class C @kk (a :: S kk) where ... + +But how can we "connect up" the scoped variable `kk` with the skolem kind from the +standalone kind signature for `C`? In general we do this by unifying the two. +For example + type T k = (k,Type) + type W :: forall k. T k -> Type + data W (a :: (x,Type)) = ..blah blah.. + +When we encounter (a :: (x,Type)) we unify the kind (x,Type) with the kind (T k) +from the standalone kind signature. Of course, unification looks through synonyms +so we end up with the mapping [x :-> k] that connects the scoped type variable `x` +with the kind from the signature. + +But in our earlier example this unification is ineffective -- because `S` is a +phantom synonym that just discards its argument. So our plan is this: + + if matchUpSigWithDecl fails to connect `kk with `k`, by unification, + we give up and complain about a "disconnected" type variable. + +See #24083 for dicussion of alternatives, none satisfactory. Also the fix is +easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` +explicitly, rather than binding it implicitly via unification. +-} + {- ********************************************************************* * * Bringing type variables into scope ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -477,6 +477,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvalidVisibleKindArgument" = 20967 GhcDiagnosticCode "TcRnTooManyBinders" = 05989 GhcDiagnosticCode "TcRnDifferentNamesForTyVar" = 17370 + GhcDiagnosticCode "TcRnDisconnectedTyVar" = 59738 GhcDiagnosticCode "TcRnInvalidReturnKind" = 55233 GhcDiagnosticCode "TcRnClassKindNotConstraint" = 80768 GhcDiagnosticCode "TcRnMatchesHaveDiffNumArgs" = 91938 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -480,6 +480,10 @@ data GhcHint {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} | SuggestExplicitQuantification RdrName + + {-| Suggest binding explicitly; e.g data T @k (a :: F k) = .... -} + | SuggestBindTyVarExplicitly Name + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -271,6 +271,9 @@ instance Outputable GhcHint where SuggestExplicitQuantification tv -> hsep [ text "Use an explicit", quotes (text "forall") , text "to quantify over", quotes (ppr tv) ] + SuggestBindTyVarExplicitly tv + -> text "bind" <+> quotes (ppr tv) + <+> text "explicitly with" <+> quotes (char '@' <> ppr tv) perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== testsuite/tests/polykinds/T24083.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} + +module T24083 where +import Data.Kind (Constraint, Type) + +data family Pi t :: Type + +type FunctionSymbol :: Type -> Type +type FunctionSymbol t = Type + +type IsSum :: forall s. FunctionSymbol s -> Constraint +class IsSum (sumf :: FunctionSymbol t) where + sumConNames :: Pi t ===================================== testsuite/tests/polykinds/T24083.stderr ===================================== @@ -0,0 +1,6 @@ + +T24083.hs:13:14: error: [GHC-59738] + • Scoped type variable only appears non-injectively in declaration header: + ‘t’ bound at T24083.hs:13:14 + • In the class declaration for ‘IsSum’ + Suggested fix: bind ‘t’ explicitly with ‘@t’ ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -243,3 +243,4 @@ test('T22379b', normal, compile, ['']) test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) +test('T24083', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dbab1808bfbe484b3fb396aab1d105314f918d8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dbab1808bfbe484b3fb396aab1d105314f918d8 You're receiving 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 Nov 10 01:27:48 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 09 Nov 2023 20:27:48 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/fma_x86 Message-ID: <654d871443b2f_2baaec7b3898e0678062@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/fma_x86 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/fma_x86 You're receiving 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 Nov 10 10:05:25 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 10 Nov 2023 05:05:25 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] 103 commits: Fix restarts in .ghcid Message-ID: <654e006518a59_2baaec874f1f147083f7@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 038726ca by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 Work in progress on unfoldings re-engineering - - - - - 73d2ca28 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 More - - - - - 06b85333 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 More -- now it compiles - - - - - b4beee26 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 Wibbles - - - - - da9aa6a8 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 Wibbles - - - - - e4466ea0 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 Wibbles - - - - - bb4a130e by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 More wibbles In particular, respect OtherCon - - - - - ef697f96 by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 oops remove spurious trace - - - - - bf71f51c by Simon Peyton Jones at 2023-11-10T09:19:04+00:00 Value args only in ExprTrees - - - - - 44f10cb0 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Another wibble - - - - - 9ca38d83 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Be a little bit more eager - - - - - b4ff08dd by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Comment out unused arg_is_free - - - - - 8951fda7 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Fix scoping bug - - - - - 762f54f4 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Take care with void args - - - - - e7142e1a by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Comments - - - - - d7df5287 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Limit case width and depth - - - - - 82731628 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 White space - - - - - 4c7df811 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Simplify size calculations - - - - - e9b2e751 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Fix egregious error - - - - - c3893574 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Further improvements * Fix threshold in SpecConstr * Need to recurse in keptCaseSize - - - - - 7611d1a6 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 More care with discounts and sizes - - - - - 8eb40184 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 More improvements Rename et_tot to et_wc_tot (for "worst case") Fix size bug in etCaseOf - - - - - 25316031 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Bale out altogether on very wide cases - - - - - cd534453 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Stupid typo - - - - - 6b6861ba by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Wibble - - - - - c301da74 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 More improvements Mainly doing the result-discounts as before. Some skirmishing about dealing with knownCon.. more to come - - - - - 7c5e64d1 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Fix a bad, subtle bug in exprIsConApp_maybe In extend_in_scope We were simply overwriting useful bindings in the in-scope set, notably ones that had unfoldings. That could lead to repeated simplifier iterations. - - - - - 15149cb1 by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Minor refactoring... Plus: don't be so eager to inline when argument is a non-value, but has some struture. We want *some* incentive though. - - - - - b519fd3d by Simon Peyton Jones at 2023-11-10T09:19:05+00:00 Wibbles The significant one is a discount for arguments that have structure - - - - - 8475a27c by Simon Peyton Jones at 2023-11-10T10:04:39+00:00 More wibbles - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/TyCon.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55dc1a5972a40610c416a428805b5294b3160f71...8475a27c3a675839b2e29c4fd604af42386196e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55dc1a5972a40610c416a428805b5294b3160f71...8475a27c3a675839b2e29c4fd604af42386196e4 You're receiving 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 Nov 10 15:37:31 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 10 Nov 2023 10:37:31 -0500 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.4.8-release Message-ID: <654e4e3b8083e_2baaec8ef088d47328ad@gitlab.mail> Zubin pushed new tag ghc-9.4.8-release at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.4.8-release You're receiving 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 Nov 10 16:09:55 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 10 Nov 2023 11:09:55 -0500 Subject: [Git][ghc/ghc][wip/romes/24161] testsuite: Skip MultiLayerModulesTH_Make on darwin Message-ID: <654e55d34a28f_2baaec8fccd6cc7367a2@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24161 at Glasgow Haskell Compiler / GHC Commits: 743bf658 by Rodrigo Mesquita at 2023-11-10T16:09:43+00:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - 1 changed file: - testsuite/tests/perf/compiler/all.T Changes: ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -361,7 +361,10 @@ test('MultiLayerModulesTH_Make', pre_cmd('$MAKE -s --no-print-directory MultiLayerModulesTH_Make_Prep'), extra_files(['genMultiLayerModulesTH']), unless(have_dynamic(),skip), - compile_timeout_multiplier(5) + compile_timeout_multiplier(5), + # We skip the test on darwin due to recent regression due to toolchain + # upgrade (tracked in #24177) + when(opsys('darwin'), skip) ], multimod_compile_fail, # see Note [Increased initial stack size for MultiLayerModules] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/743bf658caf56283779aa7d4fb3a72680205ae12 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/743bf658caf56283779aa7d4fb3a72680205ae12 You're receiving 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 Nov 10 22:35:20 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 10 Nov 2023 17:35:20 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/no-warn-superclasses Message-ID: <654eb028ceafd_2baaec9899c8f07552b3@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/no-warn-superclasses at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no-warn-superclasses You're receiving 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 Nov 10 23:08:15 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 10 Nov 2023 18:08:15 -0500 Subject: [Git][ghc/ghc][wip/no-warn-superclasses] Remove loopy superclass solve mechanism Message-ID: <654eb7df77e72_2baaec99639d107654b5@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/no-warn-superclasses at Glasgow Haskell Compiler / GHC Commits: df0d1198 by Krzysztof Gogolewski at 2023-11-11T00:06:14+01:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 26 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/using-warnings.rst - − testsuite/tests/typecheck/should_compile/T20666b.stderr - − testsuite/tests/typecheck/should_compile/T22891.stderr - − testsuite/tests/typecheck/should_compile/T22912.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T20666.stderr - testsuite/tests/typecheck/should_fail/T20666a.stderr - testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs - + testsuite/tests/typecheck/should_fail/T20666b.stderr - testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs - + testsuite/tests/typecheck/should_fail/T22891.stderr - testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs - + testsuite/tests/typecheck/should_fail/T22912.stderr - testsuite/tests/typecheck/should_fail/T6161.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail223.stderr Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -688,7 +688,7 @@ data WarningFlag = | Opt_WarnGADTMonoLocalBinds -- Since 9.4 | Opt_WarnTypeEqualityOutOfScope -- Since 9.4 | Opt_WarnTypeEqualityRequiresOperators -- Since 9.4 - | Opt_WarnLoopySuperclassSolve -- Since 9.6 + | Opt_WarnLoopySuperclassSolve -- Since 9.6, has no effect since 9.10 | Opt_WarnTermVariableCapture -- Since 9.8 | Opt_WarnMissingRoleAnnotations -- Since 9.8 | Opt_WarnImplicitRhsQuantification -- Since 9.8 @@ -948,7 +948,6 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnForallIdentifier, Opt_WarnUnicodeBidirectionalFormatCharacters, Opt_WarnGADTMonoLocalBinds, - Opt_WarnLoopySuperclassSolve, Opt_WarnBadlyStagedTypes, Opt_WarnTypeEqualityRequiresOperators, Opt_WarnInconsistentFlags, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2198,7 +2198,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of Opt_WarnInconsistentFlags -> warnSpec x Opt_WarnInlineRuleShadowing -> warnSpec x Opt_WarnIdentities -> warnSpec x - Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnLoopySuperclassSolve -> depWarnSpec x "it is now an error" Opt_WarnMissingFields -> warnSpec x Opt_WarnMissingImportList -> warnSpec x Opt_WarnMissingExportList -> warnSpec x ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1349,18 +1349,6 @@ instance Diagnostic TcRnMessage where , text "Combine alternative minimal complete definitions with `|'" ] where sigs = sig1 : sig2 : otherSigs - TcRnLoopySuperclassSolve wtd_loc wtd_pty -> - mkSimpleDecorated $ vcat [ header, warning, user_manual ] - where - header, warning, user_manual :: SDoc - header - = vcat [ text "I am solving the constraint" <+> quotes (ppr wtd_pty) <> comma - , nest 2 $ pprCtOrigin (ctLocOrigin wtd_loc) <> comma - , text "in a way that might turn out to loop at runtime." ] - warning - = vcat [ text "Starting from GHC 9.10, this warning will turn into an error." ] - user_manual = - vcat [ text "See the user manual, § Undecidable instances and loopy superclasses." ] TcRnUnexpectedStandaloneDerivingDecl -> mkSimpleDecorated $ text "Illegal standalone deriving declaration" TcRnUnusedVariableInRuleDecl name var -> mkSimpleDecorated $ @@ -2311,8 +2299,6 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDuplicateMinimalSig{} -> ErrorWithoutFlag - TcRnLoopySuperclassSolve{} - -> WarningWithFlag Opt_WarnLoopySuperclassSolve TcRnUnexpectedStandaloneDerivingDecl{} -> ErrorWithoutFlag TcRnUnusedVariableInRuleDecl{} @@ -2962,13 +2948,6 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.DefaultSignatures] TcRnDuplicateMinimalSig{} -> noHints - TcRnLoopySuperclassSolve wtd_loc wtd_pty - -> [LoopySuperclassSolveHint wtd_pty cls_or_qc] - where - cls_or_qc :: ClsInstOrQC - cls_or_qc = case ctLocOrigin wtd_loc of - ScOrigin c_or_q _ -> c_or_q - _ -> IsClsInst -- shouldn't happen TcRnUnexpectedStandaloneDerivingDecl{} -> [suggestExtension LangExt.StandaloneDeriving] TcRnUnusedVariableInRuleDecl{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3134,23 +3134,6 @@ data TcRnMessage where TcRnDeprecatedInvisTyArgInConPat :: TcRnMessage - {-| TcRnLoopySuperclassSolve is a warning, controlled by @-Wloopy-superclass-solve@, - that is triggered when GHC solves a constraint in a possibly-loopy way, - violating the class instance termination rules described in the section - "Undecidable instances and loopy superclasses" of the user's guide. - - Example: - - class Foo f - class Foo f => Bar f g - instance Bar f f => Bar f (h k) - - Test cases: T20666, T20666{a,b}, T22891, T22912. - -} - TcRnLoopySuperclassSolve :: CtLoc -- ^ Wanted 'CtLoc' - -> PredType -- ^ Wanted 'PredType' - -> TcRnMessage - {-| TcRnUnexpectedStandaloneDerivingDecl is an error thrown when a user uses standalone deriving without enabling the StandaloneDeriving extension. ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -98,7 +98,6 @@ solveDict dict_ct@(DictCt { di_ev = ev, di_cls = cls, di_tys = tys }) ; doTopFunDepImprovement dict_ct - ; tryLastResortProhibitedSuperClass dict_ct ; simpleStage (updInertDicts dict_ct) ; stopWithStage (dictCtEvidence dict_ct) "Kept inert DictCt" } @@ -1367,38 +1366,6 @@ with the least superclass depth (see Note [Replacement vs keeping]), but that doesn't work for the example from #22216. -} -{- ******************************************************************* -* * - Last resort prohibited superclass -* * -**********************************************************************-} - -tryLastResortProhibitedSuperClass :: DictCt -> SolverStage () --- ^ As a last resort, we TEMPORARILY allow a prohibited superclass solve, --- emitting a loud warning when doing so: we might be creating non-terminating --- evidence (as we are in T22912 for example). --- --- See Note [Migrating away from loopy superclass solving] in GHC.Tc.TyCl.Instance. -tryLastResortProhibitedSuperClass dict_ct - = Stage $ do { inerts <- getInertCans - ; last_resort inerts dict_ct } - -last_resort :: InertCans -> DictCt -> TcS (StopOrContinue ()) -last_resort inerts (DictCt { di_ev = ev_w, di_cls = cls, di_tys = xis }) - | let loc_w = ctEvLoc ev_w - orig_w = ctLocOrigin loc_w - , ScOrigin _ NakedSc <- orig_w -- work_item is definitely Wanted - , Just ct_i <- lookupInertDict inerts loc_w cls xis - , let ev_i = dictCtEvidence ct_i - , isGiven ev_i - = do { setEvBindIfWanted ev_w True (ctEvTerm ev_i) - ; ctLocWarnTcS loc_w $ - TcRnLoopySuperclassSolve loc_w (ctEvPred ev_w) - ; return $ Stop ev_w (text "Loopy superclass") } - | otherwise - = continueWith () - - {- ********************************************************************* * * * Functional dependencies, instantiation of equations ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1696,20 +1696,6 @@ Answer: superclass selection, except at a smaller type. This test is implemented by GHC.Tc.Solver.InertSet.prohibitedSuperClassSolve -Note [Migrating away from loopy superclass solving] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The logic from Note [Solving superclass constraints] was implemented in GHC 9.6. -However, we want to provide a migration strategy for users, to avoid suddenly -breaking their code going when upgrading to GHC 9.6. To this effect, we temporarily -continue to allow the constraint solver to create these potentially non-terminating -solutions, but emit a loud warning when doing so: see -GHC.Tc.Solver.Dict.tryLastResortProhibitedSuperclass. - -Users can silence the warning by manually adding the necessary constraint to the -context. GHC will then keep this user-written Given, dropping the Given arising -from superclass expansion which has greater SC depth, as explained in -Note [Replacement vs keeping] in GHC.Tc.Solver.Dict. - Note [Silent superclass arguments] (historical interest only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB1: this note describes our *old* solution to the ===================================== compiler/GHC/Tc/Types/Origin.hs-boot ===================================== @@ -16,8 +16,4 @@ data FixedRuntimeRepOrigin mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext -data CtOrigin -data ClsInstOrQC = IsClsInst - | IsQC CtOrigin - unkSkol :: HasCallStack => SkolemInfo ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -520,7 +520,6 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnMisplacedSigDecl" = 87866 GhcDiagnosticCode "TcRnUnexpectedDefaultSig" = 40700 GhcDiagnosticCode "TcRnDuplicateMinimalSig" = 85346 - GhcDiagnosticCode "TcRnLoopySuperclassSolve" = 36038 GhcDiagnosticCode "TcRnUnexpectedStandaloneDerivingDecl" = 95159 GhcDiagnosticCode "TcRnUnusedVariableInRuleDecl" = 65669 GhcDiagnosticCode "TcRnUnexpectedStandaloneKindSig" = 45906 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -35,13 +35,12 @@ import GHC.Hs.Extension (GhcTc, GhcRn) import GHC.Core.Coercion import GHC.Core.FamInstEnv (FamFlavor) import GHC.Core.TyCon (TyCon) -import GHC.Core.Type (PredType, Type) +import GHC.Core.Type (Type) import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Types.Name (Name, NameSpace, OccName (occNameFS), isSymOcc, nameOccName) import GHC.Types.Name.Reader (RdrName (Unqual), ImpDeclSpec) import GHC.Types.SrcLoc (SrcSpan) import GHC.Types.Basic (Activation, RuleName) -import {-# SOURCE #-} GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Parser.Errors.Basic import GHC.Utils.Outputable import GHC.Data.FastString (fsLit, FastString) @@ -433,8 +432,6 @@ data GhcHint -} | SuggestRenameTypeVariable - | LoopySuperclassSolveHint PredType ClsInstOrQC - | SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn] {-| Suggest enabling one of the SafeHaskell modes Safe, Unsafe or ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -16,7 +16,6 @@ import GHC.Core.FamInstEnv (FamFlavor(..)) import GHC.Core.TyCon import GHC.Core.TyCo.Rep ( mkVisFunTyMany ) import GHC.Hs.Expr () -- instance Outputable -import GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace) @@ -217,14 +216,6 @@ instance Outputable GhcHint where mod = nameModule name SuggestRenameTypeVariable -> text "Consider renaming the type variable." - LoopySuperclassSolveHint pty cls_or_qc - -> vcat [ text "Add the constraint" <+> quotes (ppr pty) <+> text "to the" <+> what <> comma - , text "even though it seems logically implied by other constraints in the context." ] - where - what :: SDoc - what = case cls_or_qc of - IsClsInst -> text "instance context" - IsQC {} -> text "context of the quantified constraint" SuggestExplicitBidiPatSyn name pat args -> hang (text "Instead use an explicitly bidirectional" <+> text "pattern synonym, e.g.") ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2422,20 +2422,17 @@ of ``-W(no-)*``. extension. .. ghc-flag:: -Wloopy-superclass-solve - :shortdesc: warn when creating potentially-loopy superclass constraint evidence + :shortdesc: *(deprecated)* warn when creating potentially-loopy superclass constraint evidence :type: dynamic :reverse: -Wno-loopy-superclass-solve :since: 9.6.1 - As explained in :ref:`undecidable-instances`, when using - :extension:`UndecidableInstances` it is possible for GHC to construct + This warning is deprecated. It no longer has any effect since GHC 9.10. + In the past, :extension:`UndecidableInstances` allowed potentially non-terminating evidence for certain superclass constraints. - - This behaviour is scheduled to be removed in a future GHC version. - In the meantime, GHC emits this warning to inform users of potential - non-termination. Users can manually add the required constraint to the context - to avoid the problem (thus silencing the warning). + This is no longer allowed, as explained in :ref:`undecidable-instances`. + This warning was used during the transition period. .. ghc-flag:: -Wterm-variable-capture :shortdesc: warn when an implicitly quantified type variable captures a term's name ===================================== testsuite/tests/typecheck/should_compile/T20666b.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22891.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Foo f’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Foo f’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22912.stderr deleted ===================================== @@ -1,12 +0,0 @@ - -T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Implies c’, - arising from the head of a quantified constraint - arising from a use of ‘go’, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Implies - c’ to the context of the quantified constraint, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -866,9 +866,6 @@ test('T22647', normal, compile, ['']) test('T19577', normal, compile, ['']) test('T22383', normal, compile, ['']) test('T21501', normal, compile, ['']) -test('T20666b', normal, compile, ['']) -test('T22891', normal, compile, ['']) -test('T22912', normal, compile, ['']) test('T22924', normal, compile, ['']) test('T22985a', normal, compile, ['-O']) test('T22985b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T20666.stderr ===================================== @@ -1,20 +1,20 @@ -T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:13:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d) + bound by the instance declaration at T20666.hs:13:10-31 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C1 c’ -T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:17:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d, c' ~ c) + bound by the instance declaration at T20666.hs:17:10-40 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C2 c'’ ===================================== testsuite/tests/typecheck/should_fail/T20666a.stderr ===================================== @@ -1,10 +1,10 @@ -T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666a.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666a.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T20666b.stderr ===================================== @@ -0,0 +1,10 @@ + +T20666b.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666b.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22891.stderr ===================================== @@ -0,0 +1,9 @@ + +T22891.hs:9:10: error: [GHC-39999] + • Could not deduce ‘Foo f’ + arising from the superclasses of an instance declaration + from the context: Bar f f + bound by the instance declaration at T22891.hs:9:10-31 + Possible fix: + add (Foo f) to the context of the instance declaration + • In the instance declaration for ‘Bar f (h k3)’ ===================================== testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22912.stderr ===================================== @@ -0,0 +1,20 @@ + +T22912.hs:17:16: error: [GHC-39999] + • Could not deduce ‘Implies c’ + arising from the head of a quantified constraint + arising from a use of ‘go’ + from the context: Exactly (Implies c) + bound by a quantified context at T22912.hs:17:16-17 + Possible fix: + add (Implies c) to the context of + the type signature for: + anythingDict :: forall (c :: Constraint). Dict c + or If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the expression: go + In an equation for ‘anythingDict’: + anythingDict + = go + where + go :: (Exactly (Implies c) => Implies c) => Dict c + go = Dict ===================================== testsuite/tests/typecheck/should_fail/T6161.stderr ===================================== @@ -1,10 +1,7 @@ -T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Super (Fam a)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Super (Fam a)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T6161.hs:19:10: error: [GHC-39999] + • Could not deduce ‘Super (Fam a)’ + arising from the superclasses of an instance declaration + from the context: Foo a + bound by the instance declaration at T6161.hs:19:10-31 + • In the instance declaration for ‘Duper (Fam a)’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -241,7 +241,7 @@ test('tcfail215', normal, compile_fail, ['']) test('tcfail216', normal, compile_fail, ['']) test('tcfail217', normal, compile_fail, ['']) test('tcfail218', normal, compile_fail, ['']) -test('tcfail223', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('tcfail223', normal, compile_fail, ['']) test('tcfail224', normal, compile_fail, ['']) test('tcfail225', normal, compile_fail, ['']) @@ -293,7 +293,7 @@ test('T19187a', normal, compile_fail, ['']) test('T2534', normal, compile_fail, ['']) test('T7175', normal, compile_fail, ['']) test('T7210', normal, compile_fail, ['']) -test('T6161', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T6161', normal, compile_fail, ['']) test('T7368', normal, compile_fail, ['']) test('T7264', normal, compile_fail, ['']) test('T6069', normal, compile_fail, ['']) @@ -668,8 +668,11 @@ test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) test('T22570', normal, compile_fail, ['']) test('T22645', normal, compile_fail, ['']) -test('T20666', normal, compile, ['']) # To become compile_fail after migration period (see #22912) -test('T20666a', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T20666', normal, compile_fail, ['']) +test('T20666a', normal, compile_fail, ['']) +test('T20666b', normal, compile_fail, ['']) +test('T22891', normal, compile_fail, ['']) +test('T22912', normal, compile_fail, ['']) test('T22924a', normal, compile_fail, ['']) test('T22924b', normal, compile_fail, ['']) test('T22940', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/tcfail223.stderr ===================================== @@ -1,10 +1,9 @@ -tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Class1 a’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Class1 a’ to the instance context, - even though it seems logically implied by other constraints in the context. +tcfail223.hs:10:10: error: [GHC-39999] + • Could not deduce ‘Class1 a’ + arising from the superclasses of an instance declaration + from the context: Class3 a + bound by the instance declaration at tcfail223.hs:10:10-29 + Possible fix: + add (Class1 a) to the context of the instance declaration + • In the instance declaration for ‘Class2 a’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df0d1198650fc228b1167aebf998b4cc78f6d1af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df0d1198650fc228b1167aebf998b4cc78f6d1af You're receiving 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 Nov 11 00:44:56 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 10 Nov 2023 19:44:56 -0500 Subject: [Git][ghc/ghc][wip/no-warn-superclasses] Remove loopy superclass solve mechanism Message-ID: <654ece887837a_2baaec9be61db077474d@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/no-warn-superclasses at Glasgow Haskell Compiler / GHC Commits: 21f154c1 by Krzysztof Gogolewski at 2023-11-11T01:44:24+01:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 25 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/using-warnings.rst - − testsuite/tests/typecheck/should_compile/T20666b.stderr - − testsuite/tests/typecheck/should_compile/T22891.stderr - − testsuite/tests/typecheck/should_compile/T22912.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T20666.stderr - testsuite/tests/typecheck/should_fail/T20666a.stderr - testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs - + testsuite/tests/typecheck/should_fail/T20666b.stderr - testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs - + testsuite/tests/typecheck/should_fail/T22891.stderr - testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs - + testsuite/tests/typecheck/should_fail/T22912.stderr - testsuite/tests/typecheck/should_fail/T6161.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail223.stderr Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -688,7 +688,7 @@ data WarningFlag = | Opt_WarnGADTMonoLocalBinds -- Since 9.4 | Opt_WarnTypeEqualityOutOfScope -- Since 9.4 | Opt_WarnTypeEqualityRequiresOperators -- Since 9.4 - | Opt_WarnLoopySuperclassSolve -- Since 9.6 + | Opt_WarnLoopySuperclassSolve -- Since 9.6, has no effect since 9.10 | Opt_WarnTermVariableCapture -- Since 9.8 | Opt_WarnMissingRoleAnnotations -- Since 9.8 | Opt_WarnImplicitRhsQuantification -- Since 9.8 @@ -948,7 +948,6 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnForallIdentifier, Opt_WarnUnicodeBidirectionalFormatCharacters, Opt_WarnGADTMonoLocalBinds, - Opt_WarnLoopySuperclassSolve, Opt_WarnBadlyStagedTypes, Opt_WarnTypeEqualityRequiresOperators, Opt_WarnInconsistentFlags, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2198,7 +2198,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of Opt_WarnInconsistentFlags -> warnSpec x Opt_WarnInlineRuleShadowing -> warnSpec x Opt_WarnIdentities -> warnSpec x - Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnLoopySuperclassSolve -> depWarnSpec x "it is now an error" Opt_WarnMissingFields -> warnSpec x Opt_WarnMissingImportList -> warnSpec x Opt_WarnMissingExportList -> warnSpec x ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1349,18 +1349,6 @@ instance Diagnostic TcRnMessage where , text "Combine alternative minimal complete definitions with `|'" ] where sigs = sig1 : sig2 : otherSigs - TcRnLoopySuperclassSolve wtd_loc wtd_pty -> - mkSimpleDecorated $ vcat [ header, warning, user_manual ] - where - header, warning, user_manual :: SDoc - header - = vcat [ text "I am solving the constraint" <+> quotes (ppr wtd_pty) <> comma - , nest 2 $ pprCtOrigin (ctLocOrigin wtd_loc) <> comma - , text "in a way that might turn out to loop at runtime." ] - warning - = vcat [ text "Starting from GHC 9.10, this warning will turn into an error." ] - user_manual = - vcat [ text "See the user manual, § Undecidable instances and loopy superclasses." ] TcRnUnexpectedStandaloneDerivingDecl -> mkSimpleDecorated $ text "Illegal standalone deriving declaration" TcRnUnusedVariableInRuleDecl name var -> mkSimpleDecorated $ @@ -2311,8 +2299,6 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDuplicateMinimalSig{} -> ErrorWithoutFlag - TcRnLoopySuperclassSolve{} - -> WarningWithFlag Opt_WarnLoopySuperclassSolve TcRnUnexpectedStandaloneDerivingDecl{} -> ErrorWithoutFlag TcRnUnusedVariableInRuleDecl{} @@ -2962,13 +2948,6 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.DefaultSignatures] TcRnDuplicateMinimalSig{} -> noHints - TcRnLoopySuperclassSolve wtd_loc wtd_pty - -> [LoopySuperclassSolveHint wtd_pty cls_or_qc] - where - cls_or_qc :: ClsInstOrQC - cls_or_qc = case ctLocOrigin wtd_loc of - ScOrigin c_or_q _ -> c_or_q - _ -> IsClsInst -- shouldn't happen TcRnUnexpectedStandaloneDerivingDecl{} -> [suggestExtension LangExt.StandaloneDeriving] TcRnUnusedVariableInRuleDecl{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3134,23 +3134,6 @@ data TcRnMessage where TcRnDeprecatedInvisTyArgInConPat :: TcRnMessage - {-| TcRnLoopySuperclassSolve is a warning, controlled by @-Wloopy-superclass-solve@, - that is triggered when GHC solves a constraint in a possibly-loopy way, - violating the class instance termination rules described in the section - "Undecidable instances and loopy superclasses" of the user's guide. - - Example: - - class Foo f - class Foo f => Bar f g - instance Bar f f => Bar f (h k) - - Test cases: T20666, T20666{a,b}, T22891, T22912. - -} - TcRnLoopySuperclassSolve :: CtLoc -- ^ Wanted 'CtLoc' - -> PredType -- ^ Wanted 'PredType' - -> TcRnMessage - {-| TcRnUnexpectedStandaloneDerivingDecl is an error thrown when a user uses standalone deriving without enabling the StandaloneDeriving extension. ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -98,7 +98,6 @@ solveDict dict_ct@(DictCt { di_ev = ev, di_cls = cls, di_tys = tys }) ; doTopFunDepImprovement dict_ct - ; tryLastResortProhibitedSuperClass dict_ct ; simpleStage (updInertDicts dict_ct) ; stopWithStage (dictCtEvidence dict_ct) "Kept inert DictCt" } @@ -1367,38 +1366,6 @@ with the least superclass depth (see Note [Replacement vs keeping]), but that doesn't work for the example from #22216. -} -{- ******************************************************************* -* * - Last resort prohibited superclass -* * -**********************************************************************-} - -tryLastResortProhibitedSuperClass :: DictCt -> SolverStage () --- ^ As a last resort, we TEMPORARILY allow a prohibited superclass solve, --- emitting a loud warning when doing so: we might be creating non-terminating --- evidence (as we are in T22912 for example). --- --- See Note [Migrating away from loopy superclass solving] in GHC.Tc.TyCl.Instance. -tryLastResortProhibitedSuperClass dict_ct - = Stage $ do { inerts <- getInertCans - ; last_resort inerts dict_ct } - -last_resort :: InertCans -> DictCt -> TcS (StopOrContinue ()) -last_resort inerts (DictCt { di_ev = ev_w, di_cls = cls, di_tys = xis }) - | let loc_w = ctEvLoc ev_w - orig_w = ctLocOrigin loc_w - , ScOrigin _ NakedSc <- orig_w -- work_item is definitely Wanted - , Just ct_i <- lookupInertDict inerts loc_w cls xis - , let ev_i = dictCtEvidence ct_i - , isGiven ev_i - = do { setEvBindIfWanted ev_w True (ctEvTerm ev_i) - ; ctLocWarnTcS loc_w $ - TcRnLoopySuperclassSolve loc_w (ctEvPred ev_w) - ; return $ Stop ev_w (text "Loopy superclass") } - | otherwise - = continueWith () - - {- ********************************************************************* * * * Functional dependencies, instantiation of equations ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1696,20 +1696,6 @@ Answer: superclass selection, except at a smaller type. This test is implemented by GHC.Tc.Solver.InertSet.prohibitedSuperClassSolve -Note [Migrating away from loopy superclass solving] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The logic from Note [Solving superclass constraints] was implemented in GHC 9.6. -However, we want to provide a migration strategy for users, to avoid suddenly -breaking their code going when upgrading to GHC 9.6. To this effect, we temporarily -continue to allow the constraint solver to create these potentially non-terminating -solutions, but emit a loud warning when doing so: see -GHC.Tc.Solver.Dict.tryLastResortProhibitedSuperclass. - -Users can silence the warning by manually adding the necessary constraint to the -context. GHC will then keep this user-written Given, dropping the Given arising -from superclass expansion which has greater SC depth, as explained in -Note [Replacement vs keeping] in GHC.Tc.Solver.Dict. - Note [Silent superclass arguments] (historical interest only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB1: this note describes our *old* solution to the ===================================== compiler/GHC/Tc/Types/Origin.hs-boot ===================================== @@ -16,8 +16,4 @@ data FixedRuntimeRepOrigin mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext -data CtOrigin -data ClsInstOrQC = IsClsInst - | IsQC CtOrigin - unkSkol :: HasCallStack => SkolemInfo ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -35,13 +35,12 @@ import GHC.Hs.Extension (GhcTc, GhcRn) import GHC.Core.Coercion import GHC.Core.FamInstEnv (FamFlavor) import GHC.Core.TyCon (TyCon) -import GHC.Core.Type (PredType, Type) +import GHC.Core.Type (Type) import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Types.Name (Name, NameSpace, OccName (occNameFS), isSymOcc, nameOccName) import GHC.Types.Name.Reader (RdrName (Unqual), ImpDeclSpec) import GHC.Types.SrcLoc (SrcSpan) import GHC.Types.Basic (Activation, RuleName) -import {-# SOURCE #-} GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Parser.Errors.Basic import GHC.Utils.Outputable import GHC.Data.FastString (fsLit, FastString) @@ -433,8 +432,6 @@ data GhcHint -} | SuggestRenameTypeVariable - | LoopySuperclassSolveHint PredType ClsInstOrQC - | SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn] {-| Suggest enabling one of the SafeHaskell modes Safe, Unsafe or ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -16,7 +16,6 @@ import GHC.Core.FamInstEnv (FamFlavor(..)) import GHC.Core.TyCon import GHC.Core.TyCo.Rep ( mkVisFunTyMany ) import GHC.Hs.Expr () -- instance Outputable -import GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace) @@ -217,14 +216,6 @@ instance Outputable GhcHint where mod = nameModule name SuggestRenameTypeVariable -> text "Consider renaming the type variable." - LoopySuperclassSolveHint pty cls_or_qc - -> vcat [ text "Add the constraint" <+> quotes (ppr pty) <+> text "to the" <+> what <> comma - , text "even though it seems logically implied by other constraints in the context." ] - where - what :: SDoc - what = case cls_or_qc of - IsClsInst -> text "instance context" - IsQC {} -> text "context of the quantified constraint" SuggestExplicitBidiPatSyn name pat args -> hang (text "Instead use an explicitly bidirectional" <+> text "pattern synonym, e.g.") ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2422,20 +2422,17 @@ of ``-W(no-)*``. extension. .. ghc-flag:: -Wloopy-superclass-solve - :shortdesc: warn when creating potentially-loopy superclass constraint evidence + :shortdesc: *(deprecated)* warn when creating potentially-loopy superclass constraint evidence :type: dynamic :reverse: -Wno-loopy-superclass-solve :since: 9.6.1 - As explained in :ref:`undecidable-instances`, when using - :extension:`UndecidableInstances` it is possible for GHC to construct + This warning is deprecated. It no longer has any effect since GHC 9.10. + In the past, :extension:`UndecidableInstances` allowed potentially non-terminating evidence for certain superclass constraints. - - This behaviour is scheduled to be removed in a future GHC version. - In the meantime, GHC emits this warning to inform users of potential - non-termination. Users can manually add the required constraint to the context - to avoid the problem (thus silencing the warning). + This is no longer allowed, as explained in :ref:`undecidable-instances`. + This warning was used during the transition period. .. ghc-flag:: -Wterm-variable-capture :shortdesc: warn when an implicitly quantified type variable captures a term's name ===================================== testsuite/tests/typecheck/should_compile/T20666b.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22891.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Foo f’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Foo f’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22912.stderr deleted ===================================== @@ -1,12 +0,0 @@ - -T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Implies c’, - arising from the head of a quantified constraint - arising from a use of ‘go’, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Implies - c’ to the context of the quantified constraint, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -866,9 +866,6 @@ test('T22647', normal, compile, ['']) test('T19577', normal, compile, ['']) test('T22383', normal, compile, ['']) test('T21501', normal, compile, ['']) -test('T20666b', normal, compile, ['']) -test('T22891', normal, compile, ['']) -test('T22912', normal, compile, ['']) test('T22924', normal, compile, ['']) test('T22985a', normal, compile, ['-O']) test('T22985b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T20666.stderr ===================================== @@ -1,20 +1,20 @@ -T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:13:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d) + bound by the instance declaration at T20666.hs:13:10-31 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C1 c’ -T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:17:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d, c' ~ c) + bound by the instance declaration at T20666.hs:17:10-40 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C2 c'’ ===================================== testsuite/tests/typecheck/should_fail/T20666a.stderr ===================================== @@ -1,10 +1,10 @@ -T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666a.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666a.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T20666b.stderr ===================================== @@ -0,0 +1,10 @@ + +T20666b.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666b.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22891.stderr ===================================== @@ -0,0 +1,9 @@ + +T22891.hs:9:10: error: [GHC-39999] + • Could not deduce ‘Foo f’ + arising from the superclasses of an instance declaration + from the context: Bar f f + bound by the instance declaration at T22891.hs:9:10-31 + Possible fix: + add (Foo f) to the context of the instance declaration + • In the instance declaration for ‘Bar f (h k3)’ ===================================== testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22912.stderr ===================================== @@ -0,0 +1,20 @@ + +T22912.hs:17:16: error: [GHC-39999] + • Could not deduce ‘Implies c’ + arising from the head of a quantified constraint + arising from a use of ‘go’ + from the context: Exactly (Implies c) + bound by a quantified context at T22912.hs:17:16-17 + Possible fix: + add (Implies c) to the context of + the type signature for: + anythingDict :: forall (c :: Constraint). Dict c + or If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the expression: go + In an equation for ‘anythingDict’: + anythingDict + = go + where + go :: (Exactly (Implies c) => Implies c) => Dict c + go = Dict ===================================== testsuite/tests/typecheck/should_fail/T6161.stderr ===================================== @@ -1,10 +1,7 @@ -T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Super (Fam a)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Super (Fam a)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T6161.hs:19:10: error: [GHC-39999] + • Could not deduce ‘Super (Fam a)’ + arising from the superclasses of an instance declaration + from the context: Foo a + bound by the instance declaration at T6161.hs:19:10-31 + • In the instance declaration for ‘Duper (Fam a)’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -241,7 +241,7 @@ test('tcfail215', normal, compile_fail, ['']) test('tcfail216', normal, compile_fail, ['']) test('tcfail217', normal, compile_fail, ['']) test('tcfail218', normal, compile_fail, ['']) -test('tcfail223', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('tcfail223', normal, compile_fail, ['']) test('tcfail224', normal, compile_fail, ['']) test('tcfail225', normal, compile_fail, ['']) @@ -293,7 +293,7 @@ test('T19187a', normal, compile_fail, ['']) test('T2534', normal, compile_fail, ['']) test('T7175', normal, compile_fail, ['']) test('T7210', normal, compile_fail, ['']) -test('T6161', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T6161', normal, compile_fail, ['']) test('T7368', normal, compile_fail, ['']) test('T7264', normal, compile_fail, ['']) test('T6069', normal, compile_fail, ['']) @@ -668,8 +668,11 @@ test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) test('T22570', normal, compile_fail, ['']) test('T22645', normal, compile_fail, ['']) -test('T20666', normal, compile, ['']) # To become compile_fail after migration period (see #22912) -test('T20666a', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T20666', normal, compile_fail, ['']) +test('T20666a', normal, compile_fail, ['']) +test('T20666b', normal, compile_fail, ['']) +test('T22891', normal, compile_fail, ['']) +test('T22912', normal, compile_fail, ['']) test('T22924a', normal, compile_fail, ['']) test('T22924b', normal, compile_fail, ['']) test('T22940', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/tcfail223.stderr ===================================== @@ -1,10 +1,9 @@ -tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Class1 a’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Class1 a’ to the instance context, - even though it seems logically implied by other constraints in the context. +tcfail223.hs:10:10: error: [GHC-39999] + • Could not deduce ‘Class1 a’ + arising from the superclasses of an instance declaration + from the context: Class3 a + bound by the instance declaration at tcfail223.hs:10:10-29 + Possible fix: + add (Class1 a) to the context of the instance declaration + • In the instance declaration for ‘Class2 a’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21f154c104e3189f41fdf3311b296d471aa959c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21f154c104e3189f41fdf3311b296d471aa959c7 You're receiving 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 Nov 11 01:00:10 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 10 Nov 2023 20:00:10 -0500 Subject: [Git][ghc/ghc][wip/no-warn-superclasses] Remove loopy superclass solve mechanism Message-ID: <654ed21a81d61_2baaec9c61a6747767bc@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/no-warn-superclasses at Glasgow Haskell Compiler / GHC Commits: 06759f51 by Krzysztof Gogolewski at 2023-11-11T01:59:44+01:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 26 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/using-warnings.rst - − testsuite/tests/typecheck/should_compile/T20666b.stderr - − testsuite/tests/typecheck/should_compile/T22891.stderr - − testsuite/tests/typecheck/should_compile/T22912.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T20666.stderr - testsuite/tests/typecheck/should_fail/T20666a.stderr - testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs - + testsuite/tests/typecheck/should_fail/T20666b.stderr - testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs - + testsuite/tests/typecheck/should_fail/T22891.stderr - testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs - + testsuite/tests/typecheck/should_fail/T22912.stderr - testsuite/tests/typecheck/should_fail/T6161.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail223.stderr Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -688,7 +688,7 @@ data WarningFlag = | Opt_WarnGADTMonoLocalBinds -- Since 9.4 | Opt_WarnTypeEqualityOutOfScope -- Since 9.4 | Opt_WarnTypeEqualityRequiresOperators -- Since 9.4 - | Opt_WarnLoopySuperclassSolve -- Since 9.6 + | Opt_WarnLoopySuperclassSolve -- Since 9.6, has no effect since 9.10 | Opt_WarnTermVariableCapture -- Since 9.8 | Opt_WarnMissingRoleAnnotations -- Since 9.8 | Opt_WarnImplicitRhsQuantification -- Since 9.8 @@ -948,7 +948,6 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnForallIdentifier, Opt_WarnUnicodeBidirectionalFormatCharacters, Opt_WarnGADTMonoLocalBinds, - Opt_WarnLoopySuperclassSolve, Opt_WarnBadlyStagedTypes, Opt_WarnTypeEqualityRequiresOperators, Opt_WarnInconsistentFlags, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2198,7 +2198,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of Opt_WarnInconsistentFlags -> warnSpec x Opt_WarnInlineRuleShadowing -> warnSpec x Opt_WarnIdentities -> warnSpec x - Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnLoopySuperclassSolve -> depWarnSpec x "it is now an error" Opt_WarnMissingFields -> warnSpec x Opt_WarnMissingImportList -> warnSpec x Opt_WarnMissingExportList -> warnSpec x ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1349,18 +1349,6 @@ instance Diagnostic TcRnMessage where , text "Combine alternative minimal complete definitions with `|'" ] where sigs = sig1 : sig2 : otherSigs - TcRnLoopySuperclassSolve wtd_loc wtd_pty -> - mkSimpleDecorated $ vcat [ header, warning, user_manual ] - where - header, warning, user_manual :: SDoc - header - = vcat [ text "I am solving the constraint" <+> quotes (ppr wtd_pty) <> comma - , nest 2 $ pprCtOrigin (ctLocOrigin wtd_loc) <> comma - , text "in a way that might turn out to loop at runtime." ] - warning - = vcat [ text "Starting from GHC 9.10, this warning will turn into an error." ] - user_manual = - vcat [ text "See the user manual, § Undecidable instances and loopy superclasses." ] TcRnUnexpectedStandaloneDerivingDecl -> mkSimpleDecorated $ text "Illegal standalone deriving declaration" TcRnUnusedVariableInRuleDecl name var -> mkSimpleDecorated $ @@ -2311,8 +2299,6 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDuplicateMinimalSig{} -> ErrorWithoutFlag - TcRnLoopySuperclassSolve{} - -> WarningWithFlag Opt_WarnLoopySuperclassSolve TcRnUnexpectedStandaloneDerivingDecl{} -> ErrorWithoutFlag TcRnUnusedVariableInRuleDecl{} @@ -2962,13 +2948,6 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.DefaultSignatures] TcRnDuplicateMinimalSig{} -> noHints - TcRnLoopySuperclassSolve wtd_loc wtd_pty - -> [LoopySuperclassSolveHint wtd_pty cls_or_qc] - where - cls_or_qc :: ClsInstOrQC - cls_or_qc = case ctLocOrigin wtd_loc of - ScOrigin c_or_q _ -> c_or_q - _ -> IsClsInst -- shouldn't happen TcRnUnexpectedStandaloneDerivingDecl{} -> [suggestExtension LangExt.StandaloneDeriving] TcRnUnusedVariableInRuleDecl{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3134,23 +3134,6 @@ data TcRnMessage where TcRnDeprecatedInvisTyArgInConPat :: TcRnMessage - {-| TcRnLoopySuperclassSolve is a warning, controlled by @-Wloopy-superclass-solve@, - that is triggered when GHC solves a constraint in a possibly-loopy way, - violating the class instance termination rules described in the section - "Undecidable instances and loopy superclasses" of the user's guide. - - Example: - - class Foo f - class Foo f => Bar f g - instance Bar f f => Bar f (h k) - - Test cases: T20666, T20666{a,b}, T22891, T22912. - -} - TcRnLoopySuperclassSolve :: CtLoc -- ^ Wanted 'CtLoc' - -> PredType -- ^ Wanted 'PredType' - -> TcRnMessage - {-| TcRnUnexpectedStandaloneDerivingDecl is an error thrown when a user uses standalone deriving without enabling the StandaloneDeriving extension. ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -98,7 +98,6 @@ solveDict dict_ct@(DictCt { di_ev = ev, di_cls = cls, di_tys = tys }) ; doTopFunDepImprovement dict_ct - ; tryLastResortProhibitedSuperClass dict_ct ; simpleStage (updInertDicts dict_ct) ; stopWithStage (dictCtEvidence dict_ct) "Kept inert DictCt" } @@ -1367,38 +1366,6 @@ with the least superclass depth (see Note [Replacement vs keeping]), but that doesn't work for the example from #22216. -} -{- ******************************************************************* -* * - Last resort prohibited superclass -* * -**********************************************************************-} - -tryLastResortProhibitedSuperClass :: DictCt -> SolverStage () --- ^ As a last resort, we TEMPORARILY allow a prohibited superclass solve, --- emitting a loud warning when doing so: we might be creating non-terminating --- evidence (as we are in T22912 for example). --- --- See Note [Migrating away from loopy superclass solving] in GHC.Tc.TyCl.Instance. -tryLastResortProhibitedSuperClass dict_ct - = Stage $ do { inerts <- getInertCans - ; last_resort inerts dict_ct } - -last_resort :: InertCans -> DictCt -> TcS (StopOrContinue ()) -last_resort inerts (DictCt { di_ev = ev_w, di_cls = cls, di_tys = xis }) - | let loc_w = ctEvLoc ev_w - orig_w = ctLocOrigin loc_w - , ScOrigin _ NakedSc <- orig_w -- work_item is definitely Wanted - , Just ct_i <- lookupInertDict inerts loc_w cls xis - , let ev_i = dictCtEvidence ct_i - , isGiven ev_i - = do { setEvBindIfWanted ev_w True (ctEvTerm ev_i) - ; ctLocWarnTcS loc_w $ - TcRnLoopySuperclassSolve loc_w (ctEvPred ev_w) - ; return $ Stop ev_w (text "Loopy superclass") } - | otherwise - = continueWith () - - {- ********************************************************************* * * * Functional dependencies, instantiation of equations ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1696,20 +1696,6 @@ Answer: superclass selection, except at a smaller type. This test is implemented by GHC.Tc.Solver.InertSet.prohibitedSuperClassSolve -Note [Migrating away from loopy superclass solving] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The logic from Note [Solving superclass constraints] was implemented in GHC 9.6. -However, we want to provide a migration strategy for users, to avoid suddenly -breaking their code going when upgrading to GHC 9.6. To this effect, we temporarily -continue to allow the constraint solver to create these potentially non-terminating -solutions, but emit a loud warning when doing so: see -GHC.Tc.Solver.Dict.tryLastResortProhibitedSuperclass. - -Users can silence the warning by manually adding the necessary constraint to the -context. GHC will then keep this user-written Given, dropping the Given arising -from superclass expansion which has greater SC depth, as explained in -Note [Replacement vs keeping] in GHC.Tc.Solver.Dict. - Note [Silent superclass arguments] (historical interest only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB1: this note describes our *old* solution to the ===================================== compiler/GHC/Tc/Types/Origin.hs-boot ===================================== @@ -16,8 +16,4 @@ data FixedRuntimeRepOrigin mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext -data CtOrigin -data ClsInstOrQC = IsClsInst - | IsQC CtOrigin - unkSkol :: HasCallStack => SkolemInfo ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -520,7 +520,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnMisplacedSigDecl" = 87866 GhcDiagnosticCode "TcRnUnexpectedDefaultSig" = 40700 GhcDiagnosticCode "TcRnDuplicateMinimalSig" = 85346 - GhcDiagnosticCode "TcRnLoopySuperclassSolve" = 36038 + GhcDiagnosticCode "TcRnLoopySuperclassSolve" = Outdated 36038 GhcDiagnosticCode "TcRnUnexpectedStandaloneDerivingDecl" = 95159 GhcDiagnosticCode "TcRnUnusedVariableInRuleDecl" = 65669 GhcDiagnosticCode "TcRnUnexpectedStandaloneKindSig" = 45906 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -35,13 +35,12 @@ import GHC.Hs.Extension (GhcTc, GhcRn) import GHC.Core.Coercion import GHC.Core.FamInstEnv (FamFlavor) import GHC.Core.TyCon (TyCon) -import GHC.Core.Type (PredType, Type) +import GHC.Core.Type (Type) import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Types.Name (Name, NameSpace, OccName (occNameFS), isSymOcc, nameOccName) import GHC.Types.Name.Reader (RdrName (Unqual), ImpDeclSpec) import GHC.Types.SrcLoc (SrcSpan) import GHC.Types.Basic (Activation, RuleName) -import {-# SOURCE #-} GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Parser.Errors.Basic import GHC.Utils.Outputable import GHC.Data.FastString (fsLit, FastString) @@ -433,8 +432,6 @@ data GhcHint -} | SuggestRenameTypeVariable - | LoopySuperclassSolveHint PredType ClsInstOrQC - | SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn] {-| Suggest enabling one of the SafeHaskell modes Safe, Unsafe or ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -16,7 +16,6 @@ import GHC.Core.FamInstEnv (FamFlavor(..)) import GHC.Core.TyCon import GHC.Core.TyCo.Rep ( mkVisFunTyMany ) import GHC.Hs.Expr () -- instance Outputable -import GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace) @@ -217,14 +216,6 @@ instance Outputable GhcHint where mod = nameModule name SuggestRenameTypeVariable -> text "Consider renaming the type variable." - LoopySuperclassSolveHint pty cls_or_qc - -> vcat [ text "Add the constraint" <+> quotes (ppr pty) <+> text "to the" <+> what <> comma - , text "even though it seems logically implied by other constraints in the context." ] - where - what :: SDoc - what = case cls_or_qc of - IsClsInst -> text "instance context" - IsQC {} -> text "context of the quantified constraint" SuggestExplicitBidiPatSyn name pat args -> hang (text "Instead use an explicitly bidirectional" <+> text "pattern synonym, e.g.") ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2422,20 +2422,17 @@ of ``-W(no-)*``. extension. .. ghc-flag:: -Wloopy-superclass-solve - :shortdesc: warn when creating potentially-loopy superclass constraint evidence + :shortdesc: *(deprecated)* warn when creating potentially-loopy superclass constraint evidence :type: dynamic :reverse: -Wno-loopy-superclass-solve :since: 9.6.1 - As explained in :ref:`undecidable-instances`, when using - :extension:`UndecidableInstances` it is possible for GHC to construct + This warning is deprecated. It no longer has any effect since GHC 9.10. + In the past, :extension:`UndecidableInstances` allowed potentially non-terminating evidence for certain superclass constraints. - - This behaviour is scheduled to be removed in a future GHC version. - In the meantime, GHC emits this warning to inform users of potential - non-termination. Users can manually add the required constraint to the context - to avoid the problem (thus silencing the warning). + This is no longer allowed, as explained in :ref:`undecidable-instances`. + This warning was used during the transition period. .. ghc-flag:: -Wterm-variable-capture :shortdesc: warn when an implicitly quantified type variable captures a term's name ===================================== testsuite/tests/typecheck/should_compile/T20666b.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22891.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Foo f’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Foo f’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22912.stderr deleted ===================================== @@ -1,12 +0,0 @@ - -T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Implies c’, - arising from the head of a quantified constraint - arising from a use of ‘go’, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Implies - c’ to the context of the quantified constraint, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -866,9 +866,6 @@ test('T22647', normal, compile, ['']) test('T19577', normal, compile, ['']) test('T22383', normal, compile, ['']) test('T21501', normal, compile, ['']) -test('T20666b', normal, compile, ['']) -test('T22891', normal, compile, ['']) -test('T22912', normal, compile, ['']) test('T22924', normal, compile, ['']) test('T22985a', normal, compile, ['-O']) test('T22985b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T20666.stderr ===================================== @@ -1,20 +1,20 @@ -T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:13:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d) + bound by the instance declaration at T20666.hs:13:10-31 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C1 c’ -T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:17:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d, c' ~ c) + bound by the instance declaration at T20666.hs:17:10-40 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C2 c'’ ===================================== testsuite/tests/typecheck/should_fail/T20666a.stderr ===================================== @@ -1,10 +1,10 @@ -T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666a.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666a.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T20666b.stderr ===================================== @@ -0,0 +1,10 @@ + +T20666b.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666b.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22891.stderr ===================================== @@ -0,0 +1,9 @@ + +T22891.hs:9:10: error: [GHC-39999] + • Could not deduce ‘Foo f’ + arising from the superclasses of an instance declaration + from the context: Bar f f + bound by the instance declaration at T22891.hs:9:10-31 + Possible fix: + add (Foo f) to the context of the instance declaration + • In the instance declaration for ‘Bar f (h k3)’ ===================================== testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22912.stderr ===================================== @@ -0,0 +1,20 @@ + +T22912.hs:17:16: error: [GHC-39999] + • Could not deduce ‘Implies c’ + arising from the head of a quantified constraint + arising from a use of ‘go’ + from the context: Exactly (Implies c) + bound by a quantified context at T22912.hs:17:16-17 + Possible fix: + add (Implies c) to the context of + the type signature for: + anythingDict :: forall (c :: Constraint). Dict c + or If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the expression: go + In an equation for ‘anythingDict’: + anythingDict + = go + where + go :: (Exactly (Implies c) => Implies c) => Dict c + go = Dict ===================================== testsuite/tests/typecheck/should_fail/T6161.stderr ===================================== @@ -1,10 +1,7 @@ -T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Super (Fam a)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Super (Fam a)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T6161.hs:19:10: error: [GHC-39999] + • Could not deduce ‘Super (Fam a)’ + arising from the superclasses of an instance declaration + from the context: Foo a + bound by the instance declaration at T6161.hs:19:10-31 + • In the instance declaration for ‘Duper (Fam a)’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -241,7 +241,7 @@ test('tcfail215', normal, compile_fail, ['']) test('tcfail216', normal, compile_fail, ['']) test('tcfail217', normal, compile_fail, ['']) test('tcfail218', normal, compile_fail, ['']) -test('tcfail223', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('tcfail223', normal, compile_fail, ['']) test('tcfail224', normal, compile_fail, ['']) test('tcfail225', normal, compile_fail, ['']) @@ -293,7 +293,7 @@ test('T19187a', normal, compile_fail, ['']) test('T2534', normal, compile_fail, ['']) test('T7175', normal, compile_fail, ['']) test('T7210', normal, compile_fail, ['']) -test('T6161', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T6161', normal, compile_fail, ['']) test('T7368', normal, compile_fail, ['']) test('T7264', normal, compile_fail, ['']) test('T6069', normal, compile_fail, ['']) @@ -668,8 +668,11 @@ test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) test('T22570', normal, compile_fail, ['']) test('T22645', normal, compile_fail, ['']) -test('T20666', normal, compile, ['']) # To become compile_fail after migration period (see #22912) -test('T20666a', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T20666', normal, compile_fail, ['']) +test('T20666a', normal, compile_fail, ['']) +test('T20666b', normal, compile_fail, ['']) +test('T22891', normal, compile_fail, ['']) +test('T22912', normal, compile_fail, ['']) test('T22924a', normal, compile_fail, ['']) test('T22924b', normal, compile_fail, ['']) test('T22940', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/tcfail223.stderr ===================================== @@ -1,10 +1,9 @@ -tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Class1 a’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Class1 a’ to the instance context, - even though it seems logically implied by other constraints in the context. +tcfail223.hs:10:10: error: [GHC-39999] + • Could not deduce ‘Class1 a’ + arising from the superclasses of an instance declaration + from the context: Class3 a + bound by the instance declaration at tcfail223.hs:10:10-29 + Possible fix: + add (Class1 a) to the context of the instance declaration + • In the instance declaration for ‘Class2 a’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06759f514eb0bcfa401190e54bd69022b082bb96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06759f514eb0bcfa401190e54bd69022b082bb96 You're receiving 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 Nov 11 08:55:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 11 Nov 2023 03:55:30 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Don't assume the current locale is *.UTF-8, set the encoding explicitly Message-ID: <654f41824d6fe_2baaeca78bd240784947@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 1cebf8d2 by Sven Tennie at 2023-11-11T03:55:15-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 9a9a3f64 by Alan Zimmerman at 2023-11-11T03:55:16-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 17 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - hadrian/src/Builder.hs - rts/configure.ac - + testsuite/tests/polykinds/T24083.hs - + testsuite/tests/polykinds/T24083.stderr - testsuite/tests/polykinds/all.T - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -162,8 +162,9 @@ basicBlockCodeGen block = do -- unwinding info. See Ticket 19913 -- code generation may introduce new basic block boundaries, which -- are indicated by the NEWBLOCK instruction. We must split up the - -- instruction stream into basic blocks again. Also, we extract - -- LDATAs here too. + -- instruction stream into basic blocks again. Also, we may extract + -- LDATAs here too (if they are implemented by AArch64 again - See + -- PPC how to do that.) let (top,other_blocks,statics) = foldrOL mkBlocks ([],[],[]) instrs @@ -174,8 +175,6 @@ mkBlocks :: Instr -> ([Instr], [GenBasicBlock Instr], [GenCmmDecl RawCmmStatics h g]) mkBlocks (NEWBLOCK id) (instrs,blocks,statics) = ([], BasicBlock id instrs : blocks, statics) -mkBlocks (LDATA sec dat) (instrs,blocks,statics) - = (instrs, blocks, CmmData sec dat:statics) mkBlocks instr (instrs,blocks,statics) = (instr:instrs, blocks, statics) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -432,7 +432,6 @@ isMetaInstr instr COMMENT{} -> True MULTILINE_COMMENT{} -> True LOCATION{} -> True - LDATA{} -> True NEWBLOCK{} -> True DELTA{} -> True PUSH_STACK_FRAME -> True @@ -535,11 +534,6 @@ data Instr -- location pseudo-op (file, line, col, name) | LOCATION Int Int Int String - -- some static data spat out during code - -- generation. Will be extracted before - -- pretty-printing. - | LDATA Section RawCmmStatics - -- start a new basic block. Useful during -- codegen, removed later. Preceding -- instruction should be a jump, as per the @@ -672,7 +666,6 @@ instrCon i = MULTILINE_COMMENT{} -> "COMMENT" ANN{} -> "ANN" LOCATION{} -> "LOCATION" - LDATA{} -> "LDATA" NEWBLOCK{} -> "NEWBLOCK" DELTA{} -> "DELTA" SXTB{} -> "SXTB" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -357,7 +357,6 @@ pprInstr platform instr = case instr of -- in the final instruction stream. But we still want to be able to -- print it for debugging purposes. line (text "BLOCK " <> pprAsmLabel platform (blockLbl blockid)) - LDATA _ _ -> panic "pprInstr: LDATA" -- Pseudo Instructions ------------------------------------------------------- ===================================== compiler/GHC/Parser.y ===================================== @@ -2259,9 +2259,9 @@ tyop :: { (LocatedN RdrName, PromotionFlag) } ; return (op, IsPromoted) } } atype :: { LHsType GhcPs } - : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples + : ntgtycon {% acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples -- See Note [%shift: atype -> tyvar] - | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) + | tyvar %shift {% acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) | '*' {% do { warnStarIsType (getLoc $1) ; return $ sL1a $1 (HsStarTy noExtField (isUnicode $1)) } } @@ -2308,7 +2308,7 @@ atype :: { LHsType GhcPs } -- Type variables are never exported, so `M.tyvar` will be rejected by the renamer. -- We let it pass the parser because the renamer can generate a better error message. | QVARID {% let qname = mkQual tvName (getQVARID $1) - in acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glEE $1 $>) [] cs) NotPromoted (sL1n $1 $ qname)))} + in acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glEE $1 $>) [] cs) NotPromoted (sL1n $1 $ qname)))} -- An inst_type is what occurs in the head of an instance decl -- e.g. (Foo a, Gaz b) => Wibble a b @@ -2945,9 +2945,10 @@ aexp1 :: { ECP } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | aexp1 TIGHT_INFIX_PROJ field {% runPV (unECP $1) >>= \ $1 -> - fmap ecpFromExp $ acsa (\cs -> + fmap ecpFromExp $ acsA (\cs -> let fl = sLLa $2 $> (DotFieldOcc ((EpAnn (glR $2) (AnnFieldLabel (Just $ glAA $2)) emptyComments)) $3) in - mkRdrGetField (noAnnSrcSpan $ comb2 $1 $>) $1 fl (EpAnn (glEE $1 $>) NoEpAnns cs)) } + sLL $1 $> $ mkRdrGetField $1 fl (EpAnn (glEE $1 $>) NoEpAnns cs)) } + | aexp2 { $1 } @@ -3473,7 +3474,7 @@ fbind :: { forall b. DisambECP b => PV (Fbind b) } -- f (R { x = show -> s }) = ... | qvar { placeHolderPunRhs >>= \rhs -> - fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } + fmap Left $ acsA (\cs -> sL1 $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } -- In the punning case, use a place-holder -- The renamer fills in the final value @@ -4328,12 +4329,6 @@ glAA = srcSpan2e . getHasLoc n2l :: LocatedN a -> LocatedA a n2l (L la a) = L (l2l la) a -acs :: MonadP m => (EpAnnComments -> Located a) -> m (Located a) -acs a = do - let (L l _) = a emptyComments - cs <- getCommentsFor l - return (a cs) - -- Called at the very end to pick up the EOF position, as well as any comments not allocated yet. acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P (Located a) acsFinal a = do @@ -4346,17 +4341,17 @@ acsFinal a = do Strict.Just (pos `Strict.And` gap) -> Just (pos,gap) return (a (cs Semi.<> csf) ce) -acsa :: MonadP m => (EpAnnComments -> LocatedAn t a) -> m (LocatedAn t a) -acsa a = do +acs :: (HasLoc t, MonadP m) => (EpAnnComments -> GenLocated t a) -> m (GenLocated t a) +acs a = do let (L l _) = a emptyComments cs <- getCommentsFor (locA l) return (a cs) -acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) +acsA :: (HasLoc t, HasAnnotation t, MonadP m) => (EpAnnComments -> Located a) -> m (GenLocated t a) acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP -acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a +acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acs a ; return (ecpFromExp $ expr) } amsA :: MonadP m => LocatedA a -> [TrailingAnn] -> m (LocatedA a) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3230,10 +3230,10 @@ starSym False = fsLit "*" ----------------------------------------- -- Bits and pieces for RecordDotSyntax. -mkRdrGetField :: SrcSpanAnnA -> LHsExpr GhcPs -> LocatedAn NoEpAnns (DotFieldOcc GhcPs) - -> EpAnnCO -> LHsExpr GhcPs -mkRdrGetField loc arg field anns = - L loc HsGetField { +mkRdrGetField :: LHsExpr GhcPs -> LocatedAn NoEpAnns (DotFieldOcc GhcPs) + -> EpAnnCO -> HsExpr GhcPs +mkRdrGetField arg field anns = + HsGetField { gf_ext = anns , gf_expr = arg , gf_field = field ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -999,6 +999,12 @@ instance Diagnostic TcRnMessage where -- Note [Swizzling the tyvars before generaliseTcTyCon] = vcat [ quotes (ppr n1) <+> text "bound at" <+> ppr (getSrcLoc n1) , quotes (ppr n2) <+> text "bound at" <+> ppr (getSrcLoc n2) ] + + TcRnDisconnectedTyVar n + -> mkSimpleDecorated $ + hang (text "Scoped type variable only appears non-injectively in declaration header:") + 2 (quotes (ppr n) <+> text "bound at" <+> ppr (getSrcLoc n)) + TcRnInvalidReturnKind data_sort allowed_kind kind _suggested_ext -> mkSimpleDecorated $ sep [ ppDataSort data_sort <+> @@ -2201,6 +2207,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDifferentNamesForTyVar{} -> ErrorWithoutFlag + TcRnDisconnectedTyVar{} + -> ErrorWithoutFlag TcRnInvalidReturnKind{} -> ErrorWithoutFlag TcRnClassKindNotConstraint{} @@ -2842,6 +2850,8 @@ instance Diagnostic TcRnMessage where -> noHints TcRnDifferentNamesForTyVar{} -> noHints + TcRnDisconnectedTyVar n + -> [SuggestBindTyVarExplicitly n] TcRnInvalidReturnKind _ _ _ mb_suggest_unlifted_ext -> case mb_suggest_unlifted_ext of Nothing -> noHints ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2276,6 +2276,13 @@ data TcRnMessage where -} TcRnDifferentNamesForTyVar :: !Name -> !Name -> TcRnMessage + {-| TcRnDisconnectedTyVar is an error for a data declaration that has a kind signature, + where the implicitly-bound type type variables can't be matched up unambiguously + with the ones from the signature. See Note [Disconnected type variables] in + GHC.Tc.Gen.HsType. + -} + TcRnDisconnectedTyVar :: !Name -> TcRnMessage + {-| TcRnInvalidReturnKind is an error for a data declaration that has a kind signature with an invalid result kind. ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2608,6 +2608,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs + ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2621,11 +2622,11 @@ kcCheckDeclHeader_sig sig_kind name flav all_tv_prs = mkTyVarNamePairs (binderVars swizzled_tcbs) ; traceTc "kcCheckDeclHeader swizzle" $ vcat - [ text "implicit_prs = " <+> ppr implicit_prs - , text "implicit_nms = " <+> ppr implicit_nms - , text "hs_tv_bndrs = " <+> ppr hs_tv_bndrs - , text "all_tcbs = " <+> pprTyVars (binderVars all_tcbs) - , text "swizzled_tcbs = " <+> pprTyVars (binderVars swizzled_tcbs) + [ text "sig_tcbs =" <+> ppr sig_tcbs + , text "implicit_prs =" <+> ppr implicit_prs + , text "hs_tv_bndrs =" <+> ppr hs_tv_bndrs + , text "all_tcbs =" <+> pprTyVars (binderVars all_tcbs) + , text "swizzled_tcbs =" <+> pprTyVars (binderVars swizzled_tcbs) , text "tycon_res_kind =" <+> ppr tycon_res_kind , text "swizzled_kind =" <+> ppr swizzled_kind ] @@ -2963,6 +2964,22 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} +checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +-- See Note [Disconnected type variables] +-- `scoped_prs` is the mapping gotten by unifying +-- - the standalone kind signature for T, with +-- - the header of the type/class declaration for T +checkForDisconnectedScopedTyVars sig_tcbs scoped_prs + = mapM_ report_disconnected (filterOut ok scoped_prs) + where + sig_tvs = mkVarSet (binderVars sig_tcbs) + ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs + + report_disconnected :: (Name,TcTyVar) -> TcM () + report_disconnected (nm, _) + = setSrcSpan (getSrcSpan nm) $ + addErrTc $ TcRnDisconnectedTyVar nm + checkForDuplicateScopedTyVars :: [(Name,TcTyVar)] -> TcM () -- Check for duplicates -- E.g. data SameKind (a::k) (b::k) @@ -2993,6 +3010,45 @@ checkForDuplicateScopedTyVars scoped_prs addErrTc $ TcRnDifferentNamesForTyVar n1 n2 +{- Note [Disconnected type variables] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This note applies when kind-checking the header of a type/class decl that has +a separate, standalone kind signature. See #24083. + +Consider: + type S a = Type + + type C :: forall k. S k -> Constraint + class C (a :: S kk) where + op :: ...kk... + +Note that the class has a separate kind signature, so the elaborated decl should +look like + class C @kk (a :: S kk) where ... + +But how can we "connect up" the scoped variable `kk` with the skolem kind from the +standalone kind signature for `C`? In general we do this by unifying the two. +For example + type T k = (k,Type) + type W :: forall k. T k -> Type + data W (a :: (x,Type)) = ..blah blah.. + +When we encounter (a :: (x,Type)) we unify the kind (x,Type) with the kind (T k) +from the standalone kind signature. Of course, unification looks through synonyms +so we end up with the mapping [x :-> k] that connects the scoped type variable `x` +with the kind from the signature. + +But in our earlier example this unification is ineffective -- because `S` is a +phantom synonym that just discards its argument. So our plan is this: + + if matchUpSigWithDecl fails to connect `kk with `k`, by unification, + we give up and complain about a "disconnected" type variable. + +See #24083 for dicussion of alternatives, none satisfactory. Also the fix is +easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` +explicitly, rather than binding it implicitly via unification. +-} + {- ********************************************************************* * * Bringing type variables into scope ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -477,6 +477,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnInvalidVisibleKindArgument" = 20967 GhcDiagnosticCode "TcRnTooManyBinders" = 05989 GhcDiagnosticCode "TcRnDifferentNamesForTyVar" = 17370 + GhcDiagnosticCode "TcRnDisconnectedTyVar" = 59738 GhcDiagnosticCode "TcRnInvalidReturnKind" = 55233 GhcDiagnosticCode "TcRnClassKindNotConstraint" = 80768 GhcDiagnosticCode "TcRnMatchesHaveDiffNumArgs" = 91938 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -480,6 +480,10 @@ data GhcHint {-| Suggest explicitly quantifying a type variable instead of relying on implicit quantification -} | SuggestExplicitQuantification RdrName + + {-| Suggest binding explicitly; e.g data T @k (a :: F k) = .... -} + | SuggestBindTyVarExplicitly Name + -- | An 'InstantiationSuggestion' for a '.hsig' file. This is generated -- by GHC in case of a 'DriverUnexpectedSignature' and suggests a way -- to instantiate a particular signature, where the first argument is ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -271,6 +271,9 @@ instance Outputable GhcHint where SuggestExplicitQuantification tv -> hsep [ text "Use an explicit", quotes (text "forall") , text "to quantify over", quotes (ppr tv) ] + SuggestBindTyVarExplicitly tv + -> text "bind" <+> quotes (ppr tv) + <+> text "explicitly with" <+> quotes (char '@' <> ppr tv) perhapsAsPat :: SDoc perhapsAsPat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" ===================================== hadrian/src/Builder.hs ===================================== @@ -333,8 +333,8 @@ instance H.Builder Builder where GenApply -> captureStdout GenPrimopCode -> do - stdin <- readFile' input - Stdout stdout <- cmd' (Stdin stdin) [path] buildArgs buildOptions + need [input] + Stdout stdout <- cmd' (FileStdin input) [path] buildArgs buildOptions -- see Note [Capture stdout as a ByteString] writeFileChangedBS output stdout ===================================== rts/configure.ac ===================================== @@ -408,7 +408,7 @@ dnl See Note [Undefined symbols in the RTS] [ symbolExtraDefs='' -if [[ "$CABAL_FLAG_find_ptr" = 1 ]]; then +if [ "$CABAL_FLAG_find_ptr" = 1 ]; then symbolExtraDefs+=' -DFIND_PTR' fi @@ -418,7 +418,7 @@ cat $srcdir/external-symbols.list.in \ > external-symbols.list \ || exit 1 -if [[ "$CABAL_FLAG_leading_underscore" = 1 ]]; then +if [ "$CABAL_FLAG_leading_underscore" = 1 ]; then sedExpr='s/^(.*)$/ "-Wl,-u,_\1"/' else sedExpr='s/^(.*)$/ "-Wl,-u,\1"/' ===================================== testsuite/tests/polykinds/T24083.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} + +module T24083 where +import Data.Kind (Constraint, Type) + +data family Pi t :: Type + +type FunctionSymbol :: Type -> Type +type FunctionSymbol t = Type + +type IsSum :: forall s. FunctionSymbol s -> Constraint +class IsSum (sumf :: FunctionSymbol t) where + sumConNames :: Pi t ===================================== testsuite/tests/polykinds/T24083.stderr ===================================== @@ -0,0 +1,6 @@ + +T24083.hs:13:14: error: [GHC-59738] + • Scoped type variable only appears non-injectively in declaration header: + ‘t’ bound at T24083.hs:13:14 + • In the class declaration for ‘IsSum’ + Suggested fix: bind ‘t’ explicitly with ‘@t’ ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -243,3 +243,4 @@ test('T22379b', normal, compile, ['']) test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) +test('T24083', normal, compile_fail, ['']) ===================================== utils/genprimopcode/Main.hs ===================================== @@ -13,6 +13,7 @@ import Data.Char import Data.List (union, intersperse, intercalate, nub) import Data.Maybe ( catMaybes ) import System.Environment ( getArgs ) +import System.IO ( hSetEncoding, stdin, stdout, utf8 ) vecOptions :: Entry -> [(String,String,Int)] vecOptions i = @@ -116,7 +117,9 @@ main = getArgs >>= \args -> ++ unlines (map (" "++) known_args) ) else - do s <- getContents + do hSetEncoding stdin utf8 -- The input file is in UTF-8. Set the encoding explicitly. + hSetEncoding stdout utf8 + s <- getContents case parse s of Left err -> error ("parse error at " ++ (show err)) Right p_o_specs@(Info _ _) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b00fd69815e01806fc591203a2ac25733ee1dc71...9a9a3f64665426953925849dc26b8edbaef92fc8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b00fd69815e01806fc591203a2ac25733ee1dc71...9a9a3f64665426953925849dc26b8edbaef92fc8 You're receiving 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 Nov 11 11:31:47 2023 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Sat, 11 Nov 2023 06:31:47 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24178 Message-ID: <654f662342f38_2baaecab286fa8792825@gitlab.mail> Teo Camarasu pushed new branch wip/T24178 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24178 You're receiving 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 Nov 11 11:35:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 11 Nov 2023 06:35:49 -0500 Subject: [Git][ghc/ghc][master] AArch64: Delete unused LDATA pseudo-instruction Message-ID: <654f6715c4487_2baaecab815a28798087@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 3 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -162,8 +162,9 @@ basicBlockCodeGen block = do -- unwinding info. See Ticket 19913 -- code generation may introduce new basic block boundaries, which -- are indicated by the NEWBLOCK instruction. We must split up the - -- instruction stream into basic blocks again. Also, we extract - -- LDATAs here too. + -- instruction stream into basic blocks again. Also, we may extract + -- LDATAs here too (if they are implemented by AArch64 again - See + -- PPC how to do that.) let (top,other_blocks,statics) = foldrOL mkBlocks ([],[],[]) instrs @@ -174,8 +175,6 @@ mkBlocks :: Instr -> ([Instr], [GenBasicBlock Instr], [GenCmmDecl RawCmmStatics h g]) mkBlocks (NEWBLOCK id) (instrs,blocks,statics) = ([], BasicBlock id instrs : blocks, statics) -mkBlocks (LDATA sec dat) (instrs,blocks,statics) - = (instrs, blocks, CmmData sec dat:statics) mkBlocks instr (instrs,blocks,statics) = (instr:instrs, blocks, statics) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -432,7 +432,6 @@ isMetaInstr instr COMMENT{} -> True MULTILINE_COMMENT{} -> True LOCATION{} -> True - LDATA{} -> True NEWBLOCK{} -> True DELTA{} -> True PUSH_STACK_FRAME -> True @@ -535,11 +534,6 @@ data Instr -- location pseudo-op (file, line, col, name) | LOCATION Int Int Int String - -- some static data spat out during code - -- generation. Will be extracted before - -- pretty-printing. - | LDATA Section RawCmmStatics - -- start a new basic block. Useful during -- codegen, removed later. Preceding -- instruction should be a jump, as per the @@ -672,7 +666,6 @@ instrCon i = MULTILINE_COMMENT{} -> "COMMENT" ANN{} -> "ANN" LOCATION{} -> "LOCATION" - LDATA{} -> "LDATA" NEWBLOCK{} -> "NEWBLOCK" DELTA{} -> "DELTA" SXTB{} -> "SXTB" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -357,7 +357,6 @@ pprInstr platform instr = case instr of -- in the final instruction stream. But we still want to be able to -- print it for debugging purposes. line (text "BLOCK " <> pprAsmLabel platform (blockLbl blockid)) - LDATA _ _ -> panic "pprInstr: LDATA" -- Pseudo Instructions ------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2255136428b1e5fea5185c490e901c7d2ffee4a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2255136428b1e5fea5185c490e901c7d2ffee4a6 You're receiving 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 Nov 11 11:36:33 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 11 Nov 2023 06:36:33 -0500 Subject: [Git][ghc/ghc][master] EPA: harmonise acsa and acsA in GHC/Parser.y Message-ID: <654f67415a6bf_2baaecab815a28801962@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 2 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2259,9 +2259,9 @@ tyop :: { (LocatedN RdrName, PromotionFlag) } ; return (op, IsPromoted) } } atype :: { LHsType GhcPs } - : ntgtycon {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples + : ntgtycon {% acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- Not including unit tuples -- See Note [%shift: atype -> tyvar] - | tyvar %shift {% acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) + | tyvar %shift {% acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glR $1) [] cs) NotPromoted $1)) } -- (See Note [Unit tuples]) | '*' {% do { warnStarIsType (getLoc $1) ; return $ sL1a $1 (HsStarTy noExtField (isUnicode $1)) } } @@ -2308,7 +2308,7 @@ atype :: { LHsType GhcPs } -- Type variables are never exported, so `M.tyvar` will be rejected by the renamer. -- We let it pass the parser because the renamer can generate a better error message. | QVARID {% let qname = mkQual tvName (getQVARID $1) - in acsa (\cs -> sL1a $1 (HsTyVar (EpAnn (glEE $1 $>) [] cs) NotPromoted (sL1n $1 $ qname)))} + in acsA (\cs -> sL1 $1 (HsTyVar (EpAnn (glEE $1 $>) [] cs) NotPromoted (sL1n $1 $ qname)))} -- An inst_type is what occurs in the head of an instance decl -- e.g. (Foo a, Gaz b) => Wibble a b @@ -2945,9 +2945,10 @@ aexp1 :: { ECP } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | aexp1 TIGHT_INFIX_PROJ field {% runPV (unECP $1) >>= \ $1 -> - fmap ecpFromExp $ acsa (\cs -> + fmap ecpFromExp $ acsA (\cs -> let fl = sLLa $2 $> (DotFieldOcc ((EpAnn (glR $2) (AnnFieldLabel (Just $ glAA $2)) emptyComments)) $3) in - mkRdrGetField (noAnnSrcSpan $ comb2 $1 $>) $1 fl (EpAnn (glEE $1 $>) NoEpAnns cs)) } + sLL $1 $> $ mkRdrGetField $1 fl (EpAnn (glEE $1 $>) NoEpAnns cs)) } + | aexp2 { $1 } @@ -3473,7 +3474,7 @@ fbind :: { forall b. DisambECP b => PV (Fbind b) } -- f (R { x = show -> s }) = ... | qvar { placeHolderPunRhs >>= \rhs -> - fmap Left $ acsa (\cs -> sL1a $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } + fmap Left $ acsA (\cs -> sL1 $1 $ HsFieldBind (EpAnn (glR $1) [] cs) (sL1a $1 $ mkFieldOcc $1) rhs True) } -- In the punning case, use a place-holder -- The renamer fills in the final value @@ -4328,12 +4329,6 @@ glAA = srcSpan2e . getHasLoc n2l :: LocatedN a -> LocatedA a n2l (L la a) = L (l2l la) a -acs :: MonadP m => (EpAnnComments -> Located a) -> m (Located a) -acs a = do - let (L l _) = a emptyComments - cs <- getCommentsFor l - return (a cs) - -- Called at the very end to pick up the EOF position, as well as any comments not allocated yet. acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P (Located a) acsFinal a = do @@ -4346,17 +4341,17 @@ acsFinal a = do Strict.Just (pos `Strict.And` gap) -> Just (pos,gap) return (a (cs Semi.<> csf) ce) -acsa :: MonadP m => (EpAnnComments -> LocatedAn t a) -> m (LocatedAn t a) -acsa a = do +acs :: (HasLoc t, MonadP m) => (EpAnnComments -> GenLocated t a) -> m (GenLocated t a) +acs a = do let (L l _) = a emptyComments cs <- getCommentsFor (locA l) return (a cs) -acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) +acsA :: (HasLoc t, HasAnnotation t, MonadP m) => (EpAnnComments -> Located a) -> m (GenLocated t a) acsA a = reLoc <$> acs a acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP -acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a +acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acs a ; return (ecpFromExp $ expr) } amsA :: MonadP m => LocatedA a -> [TrailingAnn] -> m (LocatedA a) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3230,10 +3230,10 @@ starSym False = fsLit "*" ----------------------------------------- -- Bits and pieces for RecordDotSyntax. -mkRdrGetField :: SrcSpanAnnA -> LHsExpr GhcPs -> LocatedAn NoEpAnns (DotFieldOcc GhcPs) - -> EpAnnCO -> LHsExpr GhcPs -mkRdrGetField loc arg field anns = - L loc HsGetField { +mkRdrGetField :: LHsExpr GhcPs -> LocatedAn NoEpAnns (DotFieldOcc GhcPs) + -> EpAnnCO -> HsExpr GhcPs +mkRdrGetField arg field anns = + HsGetField { gf_ext = anns , gf_expr = arg , gf_field = field View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a0ec8eb2ebeabfa473723f9bcee68d851e0f0df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a0ec8eb2ebeabfa473723f9bcee68d851e0f0df You're receiving 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 Nov 11 15:23:12 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 11 Nov 2023 10:23:12 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-epalocation-not-anchor Message-ID: <654f9c606e33_2baaecb1041d64812868@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-epalocation-not-anchor at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-epalocation-not-anchor You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Nov 11 15:26:43 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 11 Nov 2023 10:26:43 -0500 Subject: [Git][ghc/ghc][wip/az/epa-epalocation-not-anchor] EPA: Replace Anchor with EpaLocation Message-ID: <654f9d337491b_2baaecb14cf0208147ac@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-epalocation-not-anchor at Glasgow Haskell Compiler / GHC Commits: db811ddf by Alan Zimmerman at 2023-11-11T15:26:08+00:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - 12 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/ghc-api/exactprint/T22919.stderr - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.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/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db811ddf798dd8a52ded5acf5e53f4eeaeb42474 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db811ddf798dd8a52ded5acf5e53f4eeaeb42474 You're receiving 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 Nov 11 16:47:33 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 11 Nov 2023 11:47:33 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/unified-variable-namespace Message-ID: <654fb025a5bc9_2baaecb31aff3c815279@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/unified-variable-namespace at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/unified-variable-namespace You're receiving 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 Nov 11 16:55:53 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 11 Nov 2023 11:55:53 -0500 Subject: [Git][ghc/ghc][wip/int-index/unified-variable-namespace] Fix comment Message-ID: <654fb2196447e_2baaecb31e9124817156@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/unified-variable-namespace at Glasgow Haskell Compiler / GHC Commits: 8a1b227e by Vladislav Zavialov at 2023-11-11T19:55:45+03:00 Fix comment - - - - - 1 changed file: - compiler/GHC/Hs/Decls.hs Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -198,7 +198,6 @@ type instance XCHsGroup GhcPs = () type instance XCHsGroup GhcRn = NameSet -- Names bound in the HsGroup. Term variables from this set are used -- in tcTopSrcDecls as an argument to tcAddTermVarPlaceholders. - -- See Note [Demotion of unqualified variables] (W1) in GHC.Rename.Env type instance XCHsGroup GhcTc = NameSet type instance XXHsGroup (GhcPass _) = DataConCantHappen View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a1b227e2141aeae0bf0b5aeef9345fbe25001f3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a1b227e2141aeae0bf0b5aeef9345fbe25001f3 You're receiving 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 Nov 11 18:57:57 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 11 Nov 2023 13:57:57 -0500 Subject: [Git][ghc/ghc][wip/int-index/unified-variable-namespace] Fix T18522-dbg-ppr Message-ID: <654fceb5874cc_2baaecb631bdb4820184@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/unified-variable-namespace at Glasgow Haskell Compiler / GHC Commits: 285fa79a by Vladislav Zavialov at 2023-11-11T21:57:46+03:00 Fix T18522-dbg-ppr - - - - - 1 changed file: - testsuite/tests/ghc-api/T18522-dbg-ppr.hs Changes: ===================================== testsuite/tests/ghc-api/T18522-dbg-ppr.hs ===================================== @@ -5,6 +5,7 @@ module Main where import Language.Haskell.TH (runQ) import GHC.Types.Basic import GHC.Types.Error +import GHC.Types.Name.Occurrence import GHC.ThToHs import GHC.Driver.Session import GHC.Core.TyCo.Ppr @@ -44,7 +45,7 @@ main = do forall (a :: k) (b :: j) -> () |] let hs_t = fromRight (error "convertToHsType") $ - convertToHsType (Generated SkipPmc) noSrcSpan th_t + convertToHsType (Generated SkipPmc) noSrcSpan tvName th_t (messages, mres) <- tcRnType hsc_env SkolemiseFlexi True hs_t let (warnings, errors) = partitionMessages messages View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/285fa79a905427340197e9f92aa3a855b87ff6bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/285fa79a905427340197e9f92aa3a855b87ff6bb You're receiving 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 Nov 11 23:58:04 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 11 Nov 2023 18:58:04 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Small updates Message-ID: <6550150c3d10_2baaecbcd573908321da@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 3c0c2664 by Simon Peyton Jones at 2023-11-11T23:57:24+00:00 Small updates * Reduce unfolding-use-threshold to 80 * Make dfun applications look like value args - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -606,8 +606,14 @@ exprDigest env e = go env e [] | let env' = env `addNewInScopeIds` bindersOf b = go env' e as -{- - -- Look through single-branch case-expressions; like lets +{- -- Look through single-branch case-expressions; like lets + -- This is a bit aggressive, because we might have + -- f (case x of (a,b) -> (b,a)) + -- where f p = Just (case p of (a,b) -> a) + -- So f is lazy, and we won't get cancellation of the case in the body. + -- + -- If f is strict and we don't inline, we'll float the case out, so we don't + -- need to be clever here. go env (Case _ b _ alts) as | [Alt _ bs e] <- alts , let env' = env `addNewInScopeIds` (b:bs) @@ -645,8 +651,13 @@ exprDigest env e = go env e [] = ArgIsCon (DataAlt con) (map (exprDigest env) val_args) | DFunUnfolding {} <- unfolding - = ArgNonTriv -- Says "this is a data con" without saying which - -- Will also return this for ($df d1 .. dn) + = ArgIsNot [] -- We (slightly hackily) use ArgIsNot [] for dfun applications + -- ($df d1 .. dn). This is very important to encourage inlining + -- of overloaded functions. Example. GHC.Base.liftM2. It has + -- three uses of its dict arg, each of which attracts a ScrutOf + -- discount. But the ArgDigest had better be good enough to + -- attract that ScrutOf discount! We want liftM2 to be inlined + -- in its use in the liftA2 method of instance Applicative (ST s) | Just rhs <- expandUnfolding_maybe unfolding = go (zapSubstEnv env) rhs val_args ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -206,8 +206,12 @@ defaultUnfoldingOpts = UnfoldingOpts -- inline into Csg.calc (The unfolding for sqr never makes it -- into the interface file.) - , unfoldingUseThreshold = 90 - -- Last adjusted upwards in #18282, when I reduced + , unfoldingUseThreshold = 80 + -- Adjusted 90 -> 80 when adding discounts for free variables which + -- generally make things more likely to inline. Reducing the threshold + -- eliminates some undesirable compile-time regressions (e.g. T10412a) + -- + -- Previously: adjusted upwards in #18282, when I reduced -- the result discount for constructors. , unfoldingFunAppDiscount = 60 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0c266472359c041ef41adc30a6af66638d17d4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0c266472359c041ef41adc30a6af66638d17d4 You're receiving 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 Nov 12 09:44:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 12 Nov 2023 04:44:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: AArch64: Delete unused LDATA pseudo-instruction Message-ID: <65509e80c0980_2baaecca926d1c8573ac@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - fdc43b7f by Teo Camarasu at 2023-11-12T04:44:06-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 57a70f1f by Alan Zimmerman at 2023-11-12T04:44:06-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - 16 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - nofib - testsuite/tests/ghc-api/exactprint/T22919.stderr - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.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/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a9a3f64665426953925849dc26b8edbaef92fc8...57a70f1f6ac7b602d5492a7bf2c629cc65f1eccb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a9a3f64665426953925849dc26b8edbaef92fc8...57a70f1f6ac7b602d5492a7bf2c629cc65f1eccb You're receiving 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 Nov 12 12:25:20 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sun, 12 Nov 2023 07:25:20 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/supersven/AArch64_remove_unused_instructions Message-ID: <6550c430c5dc1_2baaecce2e317c8711d3@gitlab.mail> Sven Tennie pushed new branch wip/supersven/AArch64_remove_unused_instructions at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/supersven/AArch64_remove_unused_instructions You're receiving 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 Nov 12 13:04:40 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 12 Nov 2023 08:04:40 -0500 Subject: [Git][ghc/ghc][master] nofib: bump submodule Message-ID: <6550cd6813918_2baaeccefa028487939c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 1 changed file: - nofib Changes: ===================================== nofib ===================================== @@ -1 +1 @@ -Subproject commit 274cc3f7479431e3a52c78840b3daee887e0414f +Subproject commit f8213d27fa2aa2a70dca86ae35e3d1e7c5517033 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ae517a047394ba96b822490eca6959e39601423 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7ae517a047394ba96b822490eca6959e39601423 You're receiving 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 Nov 12 13:05:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 12 Nov 2023 08:05:32 -0500 Subject: [Git][ghc/ghc][master] EPA: Replace Anchor with EpaLocation Message-ID: <6550cd9c370de_2baaecced69c54883293@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - 12 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/ghc-api/exactprint/T22919.stderr - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.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/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f0036ecae6874dc792625034363c73fc42dd65f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f0036ecae6874dc792625034363c73fc42dd65f You're receiving 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 Nov 12 13:44:26 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 12 Nov 2023 08:44:26 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-remove-anchoroperation Message-ID: <6550d6bae550c_2baaecd0526f2c8854fb@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-remove-anchoroperation at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-remove-anchoroperation You're receiving 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 Nov 12 13:46:20 2023 From: gitlab at gitlab.haskell.org (Teo Camarasu (@teo)) Date: Sun, 12 Nov 2023 08:46:20 -0500 Subject: [Git][ghc/ghc] Deleted branch wip/T24178 Message-ID: <6550d72ca588b_2baaecd04f8b2c887368@gitlab.mail> Teo Camarasu deleted branch wip/T24178 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 Sun Nov 12 18:48:37 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 12 Nov 2023 13:48:37 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 24 commits: Create specially-solved DataToTag class Message-ID: <65511e0544ec1_2baaecd76c9a6c9049c3@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - 57c4b9d6 by Alan Zimmerman at 2023-11-12T13:08:49+00:00 EPA: get rid of AnchorOperation [2023-09-21 Thu] Only error is HsDocTy - - - - - 0c84f3af by Alan Zimmerman at 2023-11-12T13:09:21+00:00 EPA: splitLHsForAllTyInvis no ann returned - - - - - 0fd65e35 by Alan Zimmerman at 2023-11-12T18:37:04+00:00 EPA: Replace Monoid with NoAnn [2023-08-19 Sat] AddClassMethod fails - - - - - ba3d552a by Alan Zimmerman at 2023-11-12T18:37:04+00:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - ad9519cb by Alan Zimmerman at 2023-11-12T18:37:04+00:00 EPA: Present no longer has annotation - - - - - e27fa24b by Alan Zimmerman at 2023-11-12T18:37:04+00:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 861573de by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: Remove parenthesizeHsType - - - - - 72754a70 by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - ba4157b2 by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: Remove SrcSpanAnn [2023-10-12 Thu] Failures HsDocTy T15242 - - - - - 337597fc by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: Remove SrcSpanAnn completely - - - - - 1e8dceef by Alan Zimmerman at 2023-11-12T18:37:05+00:00 Clean up mkScope - - - - - 86c22e61 by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: Clean up TC Monad Utils - - - - - af93972e by Alan Zimmerman at 2023-11-12T18:37:05+00:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - d62bfc30 by Alan Zimmerman at 2023-11-12T18:37:06+00:00 Semigroup instances for AnnList and AnnContext - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.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/e94b94dfc15619d32f54af8e4ebe22d2b183ee28...d62bfc30467db227ba0849b46828f4c5dddde4bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e94b94dfc15619d32f54af8e4ebe22d2b183ee28...d62bfc30467db227ba0849b46828f4c5dddde4bc You're receiving 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 Nov 13 12:32:31 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 13 Nov 2023 07:32:31 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Inline on structured arguments Message-ID: <6552175f7e155_1b47142090fb8732bc@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: f56c7c18 by Simon Peyton Jones at 2023-11-13T12:32:09+00:00 Inline on structured arguments - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Inline.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -650,7 +650,8 @@ exprDigest env e = go env e [] | Just con <- isDataConWorkId_maybe f = ArgIsCon (DataAlt con) (map (exprDigest env) val_args) - | DFunUnfolding {} <- unfolding +-- | DFunUnfolding {} <- unfolding + | hasSomeUnfolding unfolding = ArgIsNot [] -- We (slightly hackily) use ArgIsNot [] for dfun applications -- ($df d1 .. dn). This is very important to encourage inlining -- of overloaded functions. Example. GHC.Base.liftM2. It has @@ -658,6 +659,12 @@ exprDigest env e = go env e [] -- discount. But the ArgDigest had better be good enough to -- attract that ScrutOf discount! We want liftM2 to be inlined -- in its use in the liftA2 method of instance Applicative (ST s) + -- + -- Actually in specrtal/puzzle I found that we got a big (40%!) + -- benefit from let newDest = ... in case (notSeen newDest) of ... + -- We want to inline notSeen. The argument has structure (its RHS) + -- and in fat if we inline notSeen, newDest turns into a thunk + -- (SPJ GHC log 13 Nov). | Just rhs <- expandUnfolding_maybe unfolding = go (zapSubstEnv env) rhs val_args View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f56c7c18fc4bb55eca89e19cb75baecc7da59b19 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f56c7c18fc4bb55eca89e19cb75baecc7da59b19 You're receiving 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 Nov 13 16:14:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 13 Nov 2023 11:14:24 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: nofib: bump submodule Message-ID: <65524b60cdc90_1b471475c54c089522@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 87d9a93e by Andrew Lelechenko at 2023-11-13T11:14:20-05:00 Add since annotation for showHFloat - - - - - 14 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - libraries/base/src/Numeric.hs - nofib - testsuite/tests/ghc-api/exactprint/T22919.stderr - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.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/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57a70f1f6ac7b602d5492a7bf2c629cc65f1eccb...87d9a93e4b9eafe1321a48c09c2e9b2f99ad4aca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57a70f1f6ac7b602d5492a7bf2c629cc65f1eccb...87d9a93e4b9eafe1321a48c09c2e9b2f99ad4aca You're receiving 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 Nov 13 20:54:32 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 13 Nov 2023 15:54:32 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 12 commits: Create specially-solved DataToTag class Message-ID: <65528d0850033_1b4714e217d0811005a@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - b307ea93 by Apoorv Ingle at 2023-11-13T10:13:34-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 0f084eb5 by Apoorv Ingle at 2023-11-13T14:53:32-06:00 - Kill mc_what in HsMatchCtxt and rename `HsMatchCtxt` to `TcMatchAltChecker` - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c9b762d7be8c8c07f798279f33da93790e6eb02...0f084eb5b0cbdcd4c10753b9996f91b76bf81435 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c9b762d7be8c8c07f798279f33da93790e6eb02...0f084eb5b0cbdcd4c10753b9996f91b76bf81435 You're receiving 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 Nov 13 21:25:01 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 13 Nov 2023 16:25:01 -0500 Subject: [Git][ghc/ghc][master] EPA: get rid of AnchorOperation Message-ID: <6552942dcd85_1b4714f0eae4811892@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 6 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Transform.hs - utils/haddock Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3392,9 +3392,9 @@ apats :: { [LPat GhcPs] } stmtlist :: { forall b. DisambECP b => PV (LocatedL [LocatedA (Stmt GhcPs (LocatedA b))]) } : '{' stmts '}' { $2 >>= \ $2 -> - amsrl (sLL $1 $> (reverse $ snd $ unLoc $2)) (AnnList (Just $ stmtsAnchor $2) (Just $ moc $1) (Just $ mcc $3) (fromOL $ fst $ unLoc $2) []) } + amsrl (sLL $1 $> (reverse $ snd $ unLoc $2)) (AnnList (stmtsAnchor $2) (Just $ moc $1) (Just $ mcc $3) (fromOL $ fst $ unLoc $2) []) } | vocurly stmts close { $2 >>= \ $2 -> amsrl - (L (stmtsLoc $2) (reverse $ snd $ unLoc $2)) (AnnList (Just $ stmtsAnchor $2) Nothing Nothing (fromOL $ fst $ unLoc $2) []) } + (L (stmtsLoc $2) (reverse $ snd $ unLoc $2)) (AnnList (stmtsAnchor $2) Nothing Nothing (fromOL $ fst $ unLoc $2) []) } -- do { ;; s ; s ; ; s ;; } -- The last Stmt should be an expression, but that's hard to enforce ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -18,8 +18,8 @@ module GHC.Parser.Annotation ( getTokenSrcSpan, DeltaPos(..), deltaPos, getDeltaLine, - EpAnn(..), Anchor, AnchorOperation(..), - anchor, anchor_op, + EpAnn(..), Anchor, + anchor, spanAsAnchor, realSpanAsAnchor, spanFromAnchor, noSpanAnchor, NoAnn(..), @@ -517,15 +517,6 @@ data EpAnn ann -- e.g. from TH, deriving, etc. deriving (Data, Eq, Functor) --- | If tools modify the parsed source, the 'MovedAnchor' variant can --- directly provide the spacing for this item relative to the previous --- one when printing. This allows AST fragments with a particular --- anchor to be freely moved, without worrying about recalculating the --- appropriate anchor span. -data AnchorOperation = UnchangedAnchor - | MovedAnchor !DeltaPos ![LEpaComment] - deriving (Data, Eq, Show) - -- | An 'Anchor' records the base location for the start of the -- syntactic element holding the annotations, and is used as the point -- of reference for calculating delta positions for contained @@ -539,10 +530,6 @@ anchor :: Anchor -> RealSrcSpan anchor (EpaSpan r _) = r anchor _ = panic "anchor" -anchor_op :: Anchor -> AnchorOperation -anchor_op (EpaSpan _ _) = UnchangedAnchor -anchor_op (EpaDelta dp cs) = MovedAnchor dp cs - spanAsAnchor :: SrcSpan -> Anchor spanAsAnchor (RealSrcSpan r mb) = EpaSpan r mb spanAsAnchor s = EpaSpan (realSrcSpan s) Strict.Nothing @@ -1457,10 +1444,6 @@ instance (Outputable a) => Outputable (EpAnn a) where instance Outputable NoEpAnns where ppr NoEpAnns = text "NoEpAnns" -instance Outputable AnchorOperation where - ppr UnchangedAnchor = text "UnchangedAnchor" - ppr (MovedAnchor d cs) = text "MovedAnchor" <+> ppr d <+> ppr cs - instance Outputable DeltaPos where ppr (SameLine c) = text "SameLine" <+> ppr c ppr (DifferentLine l c) = text "DifferentLine" <+> ppr l <+> ppr c ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -503,12 +503,11 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. -stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor +stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan r rb)) _), _)) - = widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) -stmtsAnchor (L (RealSrcSpan l mb) _) = EpaSpan l mb -stmtsAnchor _ = panic "stmtsAnchor" --- stmtsAnchor _ = Nothing + = Just $ widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) +stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan l mb +stmtsAnchor _ = Nothing stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan stmtsLoc (L l ((ConsOL aa _), _)) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -420,7 +420,6 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do p <- getPosP pe0 <- getPriorEndD debugM $ "enterAnn:starting:(p,pe,anchor',a) =" ++ show (p, pe0, showAst anchor', astId a) - debugM $ "enterAnn:anchor_op=" ++ showGhc (anchor_op anchor') prevAnchor <- getAnchorU let curAnchor = case anchor' of EpaSpan r _ -> r @@ -442,8 +441,8 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do printCommentsBefore curAnchor priorCs <- cua canUpdateAnchor takeAppliedComments -- no pop -- ------------------------- - case anchor_op anchor' of - MovedAnchor dp _ -> do + case anchor' of + EpaDelta dp _ -> do debugM $ "enterAnn: MovedAnchor:" ++ show dp -- Set the original anchor as prior end, so the rest of this AST -- fragment has a reference @@ -484,8 +483,8 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do -- changed. off (ss2delta priorEndAfterComments curAnchor) debugM $ "enterAnn: (edp',off,priorEndAfterComments,curAnchor):" ++ show (edp',off,priorEndAfterComments,rs2range curAnchor) - let edp'' = case anchor_op anchor' of - MovedAnchor dp _ -> dp + let edp'' = case anchor' of + EpaDelta dp _ -> dp _ -> edp' -- --------------------------------------------- -- let edp = edp'' @@ -506,7 +505,7 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do debugM $ "enterAnn.dPriorEndPosition:spanStart=" ++ show spanStart modify (\s -> s { dPriorEndPosition = spanStart } )) - debugM $ "enterAnn: (anchor_op, curAnchor):" ++ show (anchor_op anchor', rs2range curAnchor) + debugM $ "enterAnn: (anchor', curAnchor):" ++ show (anchor', rs2range curAnchor) -- debugM $ "enterAnn: (dLHS,spanStart,pec,edp)=" ++ show (off,spanStart,priorEndAfterComments,edp) p0 <- getPosP d <- getPriorEndD @@ -1402,15 +1401,12 @@ printCommentsIn ss = do printOneComment :: (Monad m, Monoid w) => Comment -> EP w m () printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c - dp <-case anchor_op loc of - MovedAnchor dp _ -> return dp - _ -> do + dp <-case loc of + EpaDelta dp _ -> return dp + EpaSpan r _ -> do pe <- getPriorEndD debugM $ "printOneComment:pe=" ++ showGhc pe - -- let dp = ss2delta pe (anchor loc) - let dp = case loc of - EpaSpan r _ -> ss2delta pe r - EpaDelta dp1 _ -> dp1 + let dp = ss2delta pe r debugM $ "printOneComment:(dp,pe,loc)=" ++ showGhc (dp,pe,loc) adjustDeltaForOffsetM dp mep <- getExtraDP ===================================== utils/check-exact/Transform.hs ===================================== @@ -51,7 +51,6 @@ module Transform , noAnnSrcSpanDP1 , noAnnSrcSpanDPn , d0, d1, dn - , m0, m1, mn , addComma -- ** Managing lists, Transform monad @@ -771,15 +770,6 @@ d1 = EpaDelta (SameLine 1) [] dn :: Int -> EpaLocation dn n = EpaDelta (SameLine n) [] -m0 :: AnchorOperation -m0 = MovedAnchor (SameLine 0) [] - -m1 :: AnchorOperation -m1 = MovedAnchor (SameLine 1) [] - -mn :: Int -> AnchorOperation -mn n = MovedAnchor (SameLine n) [] - addComma :: SrcSpanAnnA -> SrcSpanAnnA addComma (SrcSpanAnn EpAnnNotUsed l) = (SrcSpanAnn (EpAnn (spanAsAnchor l) (AnnListItem [AddCommaAnn d0]) emptyComments) l) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit be2d1628c23dc2eca39b82a8b4909cca1a3925d9 +Subproject commit a70ba4918b8a65abd18b16f414b6e2c3c4e38c46 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7492048b616c9fc38af4cad40928ff4e5e7ae96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7492048b616c9fc38af4cad40928ff4e5e7ae96 You're receiving 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 Nov 13 21:25:46 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 13 Nov 2023 16:25:46 -0500 Subject: [Git][ghc/ghc][master] Add since annotation for showHFloat Message-ID: <6552945a1c5df_1b4714ee570f012225c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - 1 changed file: - libraries/base/src/Numeric.hs Changes: ===================================== libraries/base/src/Numeric.hs ===================================== @@ -243,6 +243,8 @@ similar to the @%a@ specifier in C's printf. "-0x1.9851ecp3" >>> showHFloat (-0 :: Double) "" "-0x0p+0" + + at since 4.11.0.0 -} showHFloat :: RealFloat a => a -> ShowS showHFloat = showString . fmt View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0745c34de69374f4eec832c9b30192aa5aed0424 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0745c34de69374f4eec832c9b30192aa5aed0424 You're receiving 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 Nov 13 21:59:22 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 13 Nov 2023 16:59:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/document-repr-poly Message-ID: <65529c3ab62ed_1b471410459948122444@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/document-repr-poly at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/document-repr-poly You're receiving 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 Nov 14 10:14:06 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 14 Nov 2023 05:14:06 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/24151 Message-ID: <6553486e1a173_1b471421408af0172869@gitlab.mail> Zubin pushed new branch wip/24151 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/24151 You're receiving 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 Nov 14 11:55:22 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 14 Nov 2023 06:55:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24083a Message-ID: <6553602a93c04_1b47142392c14c1831cc@gitlab.mail> Simon Peyton Jones pushed new branch wip/T24083a at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24083a You're receiving 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 Nov 14 12:32:02 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Tue, 14 Nov 2023 07:32:02 -0500 Subject: [Git][ghc/ghc][wip/romes/24161] 3 commits: darwin: Fix single_module is obsolete warning Message-ID: <655368c2ea911_1b471424874a142006e6@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/24161 at Glasgow Haskell Compiler / GHC Commits: df988e4a by Rodrigo Mesquita at 2023-11-14T12:31:44+00:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - f03c1fef by Rodrigo Mesquita at 2023-11-14T12:31:44+00:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - b4a6d8c8 by Rodrigo Mesquita at 2023-11-14T12:31:44+00:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 15 changed files: - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - m4/fp_prog_ld_no_compact_unwind.m4 - + m4/fp_prog_ld_single_module.m4 - m4/prep_target_file.m4 - testsuite/tests/perf/compiler/all.T - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -11,6 +11,7 @@ where import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Settings (ToolSettings(toolSettings_ldSupportsSingleModule)) import GHC.Driver.Config.Linker import GHC.Driver.Session @@ -152,6 +153,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- dynamic binding nonsense when referring to symbols from -- within the library. The NCG assumes that this option is -- specified (on i386, at least). + -- In XCode 15, -single_module is the default and passing the + -- flag is now obsolete and raises a warning (#24168). We encode + -- this information into the toolchain field ...SupportsSingleModule. -- -install_name -- Mac OS/X stores the path where a dynamic library is (to -- be) installed in the library itself. It's called the @@ -177,8 +181,11 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages ] ++ map Option o_files ++ [ Option "-undefined", - Option "dynamic_lookup", - Option "-single_module" ] + Option "dynamic_lookup" + ] + ++ (if toolSettings_ldSupportsSingleModule (toolSettings dflags) + then [ Option "-single_module" ] + else [ ]) ++ (if platformArch platform `elem` [ ArchX86_64, ArchAArch64 ] then [ ] else [ Option "-Wl,-read_only_relocs,suppress" ]) ===================================== compiler/GHC/Settings.hs ===================================== @@ -86,6 +86,7 @@ data Settings = Settings data ToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind :: Bool , toolSettings_ldSupportsFilelist :: Bool + , toolSettings_ldSupportsSingleModule :: Bool , toolSettings_mergeObjsSupportsResponseFiles :: Bool , toolSettings_ldIsGnuLd :: Bool , toolSettings_ccSupportsNoPie :: Bool ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -107,6 +107,7 @@ initSettings top_dir = do ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind" ldSupportsFilelist <- getBooleanSetting "ld supports filelist" + ldSupportsSingleModule <- getBooleanSetting "ld supports single module" mergeObjsSupportsResponseFiles <- getBooleanSetting "Merge objects supports response files" ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" @@ -171,6 +172,7 @@ initSettings top_dir = do , sToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind , toolSettings_ldSupportsFilelist = ldSupportsFilelist + , toolSettings_ldSupportsSingleModule = ldSupportsSingleModule , toolSettings_mergeObjsSupportsResponseFiles = mergeObjsSupportsResponseFiles , toolSettings_ldIsGnuLd = ldIsGnuLd , toolSettings_ccSupportsNoPie = gccSupportsNoPie ===================================== configure.ac ===================================== @@ -452,6 +452,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** Which nm to use? ===================================== distrib/configure.ac.in ===================================== @@ -136,6 +136,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** which strip to use? dnl -------------------------------------------------------------- ===================================== hadrian/bindist/Makefile ===================================== @@ -104,6 +104,7 @@ lib/settings : config.mk @echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@ @echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@ @echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@ + @echo ',("ld supports single module", "$(LdHasSingleModule)")' >> $@ @echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@ @echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@ @echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -191,6 +191,7 @@ LdHasBuildId = @LdHasBuildId@ LdHasFilelist = @LdHasFilelist@ LdIsGNULd = @LdIsGNULd@ LdHasNoCompactUnwind = @LdHasNoCompactUnwind@ +LdHasSingleModule = @LdHasSingleModule@ ArArgs = @ArArgs@ ArSupportsAtFile = @ArSupportsAtFile@ ArSupportsDashL = @ArSupportsDashL@ ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = False , ccLinkSupportsCompactUnwind = False , ccLinkSupportsFilelist = False +, ccLinkSupportsSingleModule = True , ccLinkIsGnu = False } ===================================== hadrian/cfg/default.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = @CONF_GCC_SUPPORTS_NO_PIEBool@ , ccLinkSupportsCompactUnwind = @LdHasNoCompactUnwindBool@ , ccLinkSupportsFilelist = @LdHasFilelistBool@ +, ccLinkSupportsSingleModule = @LdHasSingleModuleBool@ , ccLinkIsGnu = @LdIsGNULdBool@ } ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -373,6 +373,7 @@ generateSettings = do , ("Haskell CPP flags", queryTarget hsCppFlags) , ("ld supports compact unwind", queryTarget linkSupportsCompactUnwind) , ("ld supports filelist", queryTarget linkSupportsFilelist) + , ("ld supports single module", queryTarget linkSupportsSingleModule) , ("ld is GNU ld", queryTarget linkIsGnu) , ("Merge objects command", queryTarget mergeObjsPath) , ("Merge objects flags", queryTarget mergeObjsFlags) @@ -431,6 +432,7 @@ generateSettings = do hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink ===================================== m4/fp_prog_ld_no_compact_unwind.m4 ===================================== @@ -6,7 +6,7 @@ AC_DEFUN([FP_PROG_LD_NO_COMPACT_UNWIND], [ AC_CACHE_CHECK([whether ld understands -no_compact_unwind], [fp_cv_ld_no_compact_unwind], [ -case $build in +case $target in *-darwin) echo 'int foo() { return 0; }' > conftest.c "${CC-cc}" -c conftest.c ===================================== m4/fp_prog_ld_single_module.m4 ===================================== @@ -0,0 +1,30 @@ +# FP_PROG_LD_SINGLE_MODULE +# ---------------------------- +# Sets the output variable LdHasSingleModule to YES if the darwin ld supports +# -single_module, or NO otherwise. +# +# In XCode 15, -single_module is a default and passing it as a flag raises a +# warning. +AC_DEFUN([FP_PROG_LD_SINGLE_MODULE], +[ +AC_CACHE_CHECK([whether ld supports -single_module], [fp_cv_ld_single_module], +[ +case $target in + *-darwin) + echo 'int foo(int x) { return x*x; }' > conftest.c + echo 'extern int foo(int); int main() { return foo(5); }' > conftestmain.c + "$CC" -c -o conftestmain.o conftestmain.c + "$CC" -shared -o conftest.dylib conftest.c + if "$CC" -Wl,-single_module -o conftest conftestmain.o conftest.dylib 2>&1 | grep obsolete > /dev/null; then + fp_cv_ld_single_module=no + else + fp_cv_ld_single_module=yes + fi + rm -rf conftest* ;; + *) + fp_cv_ld_single_module=no ;; +esac +]) +FP_CAPITALIZE_YES_NO(["$fp_cv_ld_single_module"], [LdHasSingleModule]) +AC_SUBST([LdHasSingleModule]) +])# FP_PROG_LD_SINGLE_MODULE ===================================== m4/prep_target_file.m4 ===================================== @@ -131,6 +131,7 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_BOOLEAN([TargetHasIdentDirective]) PREP_BOOLEAN([CONF_GCC_SUPPORTS_NO_PIE]) PREP_BOOLEAN([LdHasFilelist]) + PREP_BOOLEAN([LdHasSingleModule]) PREP_BOOLEAN([LdIsGNULd]) PREP_BOOLEAN([LdHasNoCompactUnwind]) PREP_BOOLEAN([TargetHasSubsectionsViaSymbols]) ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -361,7 +361,10 @@ test('MultiLayerModulesTH_Make', pre_cmd('$MAKE -s --no-print-directory MultiLayerModulesTH_Make_Prep'), extra_files(['genMultiLayerModulesTH']), unless(have_dynamic(),skip), - compile_timeout_multiplier(5) + compile_timeout_multiplier(5), + # We skip the test on darwin due to recent regression due to toolchain + # upgrade (tracked in #24177) + when(opsys('darwin'), skip) ], multimod_compile_fail, # see Note [Increased initial stack size for MultiLayerModules] ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -22,6 +22,7 @@ data CcLink = CcLink { ccLinkProgram :: Program , ccLinkSupportsNoPie :: Bool -- See Note [No PIE when linking] in GHC.Driver.Session , ccLinkSupportsCompactUnwind :: Bool , ccLinkSupportsFilelist :: Bool + , ccLinkSupportsSingleModule :: Bool , ccLinkIsGnu :: Bool } deriving (Read, Eq, Ord) @@ -34,6 +35,7 @@ instance Show CcLink where , ", ccLinkSupportsNoPie = " ++ show ccLinkSupportsNoPie , ", ccLinkSupportsCompactUnwind = " ++ show ccLinkSupportsCompactUnwind , ", ccLinkSupportsFilelist = " ++ show ccLinkSupportsFilelist + , ", ccLinkSupportsSingleModule = " ++ show ccLinkSupportsSingleModule , ", ccLinkIsGnu = " ++ show ccLinkIsGnu , "}" ] @@ -66,12 +68,13 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram + ccLinkSupportsSingleModule <- checkSupportsSingleModule archOs cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram checkBfdCopyBug archOs cc readelf ccLinkProgram ccLinkProgram <- addPlatformDepLinkFlags archOs cc ccLinkProgram let ccLink = CcLink {ccLinkProgram, ccLinkSupportsNoPie, ccLinkSupportsCompactUnwind, ccLinkSupportsFilelist, - ccLinkIsGnu} + ccLinkSupportsSingleModule, ccLinkIsGnu} ccLink <- linkRequiresNoFixupChains archOs cc ccLink ccLink <- linkRequiresNoWarnDuplicateLibraries archOs cc ccLink return ccLink @@ -164,6 +167,35 @@ checkSupportsFilelist cc ccLink = checking "whether the cc linker understands -f return (isSuccess exitCode) +-- | Check that the (darwin) linker supports @-single_module at . +-- +-- In XCode 15, the linker warns when @-single_module@ is passed as the flag +-- became the default and is now obsolete to pass. +-- +-- We assume non-darwin linkers don't support this flag. +checkSupportsSingleModule :: ArchOS -> Cc -> Program -> M Bool +checkSupportsSingleModule archOs cc link + | ArchOS _ OSDarwin <- archOs + = checking "whether the darwin linker supports -single_module" $ do + withTempDir $ \dir -> do + let test_dylib = dir "test.dylib" + test_c = dir "test.c" + testmain_o = dir "testmain.o" + testmain = dir "testmain" + + -- Main + compileC cc testmain_o "extern int foo(int); int main() { return foo(5); }" + + -- Dynamic library + writeFile test_c "int foo(int x) { return x*x; }" + _ <- runProgram (ccProgram cc) ["-shared", "-o", test_dylib, test_c] + + (_, out, err) <- readProgram link ["-Wl,-single_module", "-o", testmain, test_dylib, testmain_o] + + return $ not $ "obsolete" `isInfixOf` err || "obsolete" `isInfixOf` out + | otherwise + = return False + -- | Check whether linking works. checkLinkWorks :: Cc -> Program -> M () checkLinkWorks cc ccLink = withTempDir $ \dir -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/743bf658caf56283779aa7d4fb3a72680205ae12...b4a6d8c8be2834b9727af5412457892fb41d5040 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/743bf658caf56283779aa7d4fb3a72680205ae12...b4a6d8c8be2834b9727af5412457892fb41d5040 You're receiving 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 Nov 14 12:56:04 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 14 Nov 2023 07:56:04 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Further wibbles Message-ID: <65536e64ac687_1b471425469874212890@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: c5b6bcc3 by Simon Peyton Jones at 2023-11-14T12:55:20+00:00 Further wibbles Make unlifted cases cheaper - - - - - 3 changed files: - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs Changes: ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -564,7 +564,7 @@ substExprTree id_env et@(ExprTree { et_size = size, et_cases = cases }) where id_env' = id_env `delVarEnv` case_bndr alts' = map (subst_alt id_env') alts - extra = altTreesSize alts + extra = altTreesSize v alts subst_alt id_env (AltTree con bs rhs) = AltTree con bs (substExprTree id_env' rhs) ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -49,7 +49,7 @@ import GHC.Types.Literal import GHC.Types.Id.Info import GHC.Types.RepType ( isZeroBitTy ) import GHC.Types.Basic ( Arity ) -import GHC.Types.ForeignCall +-- import GHC.Types.ForeignCall import GHC.Types.Tickish import GHC.Builtin.Names @@ -670,13 +670,12 @@ exprTree opts args expr = Nothing -- See Note [Bale out on very wide case expressions] | Just scrut_id <- interestingVarScrut vs scrut - = go remaining_case_depth vs scrut `met_add` - (if remaining_case_depth > 0 - then do { alts' <- mapM (alt_alt_tree scrut_id) alts - ; etCaseOf bOMB_OUT_SIZE scrut_id b alts' } - else Just (etScrutOf scrut_id caseElimDiscount) `met_add` + = if remaining_case_depth > 0 + then do { alts' <- mapM (alt_alt_tree scrut_id) alts + ; etCaseOf bOMB_OUT_SIZE scrut_id b alts' } + else Just (etScrutOf scrut_id caseElimDiscount) `met_add` -- When this scrutinee has structure, we expect to eliminate the case - go_alts remaining_case_depth vs b alts) + go_alts remaining_case_depth vs b alts where -- Decremement remaining case depth when going inside -- a case with more than one alternative. @@ -695,27 +694,29 @@ exprTree opts args expr -- Don't record a CaseOf go_case rcd vs scrut b alts -- alts is non-empty - = caseSize scrut alts `metAddS` -- It is a bit odd that this `caseSize` business is only - -- applied in this equation, not in the previous ones + = -- caseDiscount scrut alts `metAddS` -- It is a bit odd that this `caseDiscount` business is only + -- -- applied in this equation, not in the previous ones go rcd vs scrut `met_add` go_alts (rcd-1) vs b alts go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree -- Add up the sizes of all RHSs. Only used for ScrutOf. - -- IMPORTANT: include a charge `altSize` for each alternative, else we + -- IMPORTANT: include a charge for the case itself, else we -- find that giant case nests are treated as practically free -- A good example is Foreign.C.Error.errnoToIOError - go_alts rcd vs b alts = foldr1 met_add_alt (map alt_expr_tree alts) + go_alts rcd vs case_bndr alts + = caseSize case_bndr alts `metAddS` + foldr1 met_add_alt (map alt_expr_tree alts) where alt_expr_tree :: Alt Var -> Maybe ExprTree - alt_expr_tree (Alt _con bs rhs) = altSize `metAddS` - go rcd (vs `add_lvs` (b:bs)) rhs + alt_expr_tree (Alt _con bs rhs) = go rcd (vs `add_lvs` (case_bndr : bs)) rhs -- Don't charge for bndrs, so that wrappers look cheap -- (See comments about wrappers with Case) -- Don't forget to add the case binder, b, to lvs. -caseSize :: CoreExpr -> [CoreAlt] -> Size -caseSize scrut alts +{- +caseDiscount :: CoreExpr -> [CoreAlt] -> Size +caseDiscount scrut alts | is_inline_scrut scrut, lengthAtMost alts 1 = -10 | otherwise = 0 -- Normally we don't charge for the case itself, but @@ -750,6 +751,7 @@ caseSize scrut alts _other -> False | otherwise = False +-} add_lv :: ETVars -> Var -> ETVars add_lv (avs,lvs) b = (avs, lvs `extendVarSet` b) @@ -894,9 +896,21 @@ primOpSize op n_val_args where op_size = primOpCodeSize op -altSize :: Size --- We charge `altSize` for each alternative in a case -altSize = 10 +caseSize :: Id -> [alt] -> Size +-- For a case expression we charge for charge for each alternative. +-- (This does /not/ include the cost of the alternatives themselves) +-- If there are no alternatives (case e of {}), we get zero +-- +-- Unlifted cases are much, much cheaper becuase they don't need to +-- save live variables, push a return address create an info table +-- An unlifted case is just a conditional; and if there is only one +-- alternative, it's not even a conditional, hence size zero +caseSize scrut_id alts + | isUnliftedType (idType scrut_id) + = if isSingleton alts then 0 + else 5 * length alts + | otherwise + = 10 * length alts caseElimDiscount :: Discount -- Bonus for eliminating a case @@ -1159,15 +1173,16 @@ etCaseOf bOMB_OUT_SIZE scrut case_bndr alts , et_cases = unitBag case_tree }) where case_tree = CaseOf scrut case_bndr alts - tot = altTreesSize alts + tot = altTreesSize scrut alts ret = altTreesDiscount alts -altTreesSize :: [AltTree] -> Size +altTreesSize :: Id -> [AltTree] -> Size -- Total worst-case size of a [AltTree], including the per-alternative cost of altSize -altTreesSize alts = foldl' add_alt 0 alts +altTreesSize scrut_id alts + = foldl' add_alt (caseSize scrut_id alts) alts where - add_alt n (AltTree _ _ (ExprTree { et_wc_tot = alt_tot })) - = n + alt_tot + altSize + add_alt :: Size -> AltTree -> Size + add_alt sz (AltTree _ _ (ExprTree { et_wc_tot = alt_tot })) = sz + alt_tot altTreesDiscount :: [AltTree] -> Discount -- See Note [Result discount for case alternatives] @@ -1256,10 +1271,10 @@ caseTreeSize ic (ScrutOf bndr disc) caseTreeSize ic (CaseOf scrut_var case_bndr alts) = case lookupBndr ic scrut_var of - ArgNoInfo -> altsSize ic case_bndr alts + case_size - ArgNonTriv -> altsSize ic case_bndr alts + case_size + ArgNoInfo -> caseAltsSize ic case_bndr alts + case_size + ArgNonTriv -> caseAltsSize ic case_bndr alts + case_size - ArgIsNot cons -> altsSize ic case_bndr (trim_alts cons alts) + ArgIsNot cons -> caseAltsSize ic case_bndr (trim_alts cons alts) -- The case-expression may not disappear, but it scrutinises -- a variable bound to something with structure; may lead to -- avoiding a thunk, or other benefits. So we give a discount @@ -1268,7 +1283,7 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts) -- -- The function 'radiance' in nofib/real/smallpt benefits a lot from this - ArgIsLam -> altsSize ic case_bndr alts -- Case will disappear altogether + ArgIsLam -> caseAltsSize ic case_bndr alts -- Case will disappear altogether arg_digest@(ArgIsCon con args) | Just at@(AltTree alt_con bndrs rhs) <- find_alt con alts @@ -1283,13 +1298,9 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts) -- Take off an extra discount for eliminating the case expression itself | otherwise -- Happens for empty alternatives - -> altsSize ic case_bndr alts + -> caseAltsSize ic case_bndr alts where - case_size = altSize * length alts - -- We make the case itself free, but charge for each alternatives - -- (the latter is already included in the AltTrees) - -- If there are no alternatives (case e of {}), we get zero - + case_size = caseSize scrut_var alts find_alt :: AltCon -> [AltTree] -> Maybe AltTree find_alt _ [] = Nothing @@ -1308,9 +1319,10 @@ trim_alts acs (alt:alts) | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts | otherwise = alt : trim_alts acs alts -altsSize :: InlineContext -> Id -> [AltTree] -> Size +caseAltsSize :: InlineContext -> Id -> [AltTree] -> Size -- Size of a (retained) case expression -altsSize ic case_bndr alts = foldr ((+) . size_alt) 0 alts +-- Do /not/ include the per-alternative cost, just the alternatives themselves +caseAltsSize ic case_bndr alts = foldr ((+) . size_alt) 0 alts -- Just add up the sizes of the alternatives -- We recurse in case we have -- args = [a,b], expr_tree = [CaseOf a [ X -> CaseOf b [...] ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -474,7 +474,6 @@ Note [Worker/wrapper for INLINABLE functions] Note [Thoughtful forcing in mkCoreUnfolding] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Core expressions retained in unfoldings is one of biggest uses of memory when compiling a program. Therefore we have to be careful about retaining copies of old or redundant templates (see !6202 for a particularly bad case). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5b6bcc3e2cda086d2d98506a72709bba504c2e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5b6bcc3e2cda086d2d98506a72709bba504c2e8 You're receiving 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 Nov 14 14:00:41 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 14 Nov 2023 09:00:41 -0500 Subject: [Git][ghc/ghc][wip/document-repr-poly] Document defaulting of RuntimeReps Message-ID: <65537d8960a95_1b47142714ac2c228820@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/document-repr-poly at Glasgow Haskell Compiler / GHC Commits: 5fa2ce3a by Krzysztof Gogolewski at 2023-11-14T15:00:15+01:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 6 changed files: - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -1383,6 +1383,7 @@ The plugin has type ``WantedConstraints -> [DefaultingProposal]``. * It is given the currently unsolved constraints. * It returns a list of independent "defaulting proposals". * Each proposal of type ``DefaultingProposal`` specifies: + * ``deProposals``: specifies a list, in priority order, of sets of type variable assignments * ``deProposalCts :: [Ct]`` gives a set of constraints (always a ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -100,13 +100,13 @@ The following kinds and promoted data constructors can be used even when :extension:`DataKinds` is not enabled: - ``Type`` -- ``TYPE`` (see :ref:`_runtime-rep`) +- ``TYPE`` (see :ref:`runtime-rep`) - ``Constraint`` (see :ref:`constraint-kind`) - ``CONSTRAINT`` - ``Multiplicity`` and its promoted data constructors (see :extension:`LinearTypes`) -- ``LiftedRep`` (see :ref:`_runtime-rep`) -- ``RuntimeRep`` and its promoted data constructors (see :ref:`_runtime-rep`) -- ``Levity`` and its promoted data constructors (see :ref:`_runtime-rep`) +- ``LiftedRep`` (see :ref:`runtime-rep`) +- ``RuntimeRep`` and its promoted data constructors (see :ref:`runtime-rep`) +- ``Levity`` and its promoted data constructors (see :ref:`runtime-rep`) - ``VecCount`` and its promoted data constructors - ``VecElem`` and its promoted data constructors @@ -231,7 +231,7 @@ See also :ghc-ticket:`7347`. :extension:`DataKinds` and type synonyms ---------------------------------------- -The :extensions:`DataKinds` extension interacts with type synonyms in the +The :extension:`DataKinds` extension interacts with type synonyms in the following ways: 1. In a *type* context: :extension:`DataKinds` is not required to use a type ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -1,3 +1,5 @@ +.. _linear-types: + Linear types ============ @@ -58,7 +60,8 @@ partially. See, however :ref:`linear-types-limitations`. Linear and multiplicity-polymorphic arrows are *always declared*, never inferred. That is, if you don't give an appropriate type signature to a function, it will be inferred as being a regular -function of type ``a -> b``. +function of type ``a -> b``. The same principle holds for +representation polymorphism (see :ref:`representation-polymorphism-defaulting`). Data types ---------- ===================================== docs/users_guide/exts/primitives.rst ===================================== @@ -438,7 +438,7 @@ You may even declare levity-polymorphic data types: :: While ``f`` above could reasonably be levity-polymorphic (as it evaluates its argument either way), GHC currently disallows the more general type ``PEither @l Int Bool -> Bool``. This is a consequence of the -`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__, +`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__. Pattern matching against an unlifted data type work just like that for lifted types; but see :ref:`recursive-and-polymorphic-let-bindings` for the semantics of ===================================== docs/users_guide/exts/representation_polymorphism.rst ===================================== @@ -108,6 +108,35 @@ These functions do not bind a representation-polymorphic variable, and so are accepted. Their polymorphism allows users to use these to conveniently stub out functions that return unboxed types. +.. _representation-polymorphism-defaulting: + +Inference and defaulting +------------------------ + +GHC does not infer representation-polymorphic types. +If the representation of a variable is not specified, it will be assumed +to be ``LiftedRep``. +For example, if you write ``f a b = a b``, the inferred type of ``f`` +will be :: + + f :: forall {a :: Type} {b :: Type}. (a -> b) -> a -> b + +even though :: + + f :: forall {rep} {a :: Type} {b :: TYPE rep}. (a -> b) -> a -> b + +would also be legal, as described above. + +Likewise, in a user-written signature ``f :: forall a b. (a -> b) -> a -> b`` +GHC will assume that both ``a`` and ``b`` have kind ``Type``. To use +a different representation, you have to specify the kinds of ``a`` and ``b``. + +During type inference, GHC does not quantify over variables of kind +``RuntimeRep`` nor ``Levity``. +Instead, they are defaulted to ``LiftedRep`` and ``Lifted`` respectively. +Likewise, ``Multiplicity`` variables (:ref:`linear-types`) are defaulted +to ``Many``. + .. _printing-representation-polymorphic-types: Printing representation-polymorphic types ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2577,7 +2577,7 @@ of ``-W(no-)*``. Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind (without having enabled the :extension:`DataKinds` extension) is caught in the typechecker (hence the ``-tc`` suffix). These warnings complement the - existing :extensions:`DataKinds` checks (that have existed since + existing :extension:`DataKinds` checks (that have existed since :extension:`DataKinds` was first introduced), which result in errors instead of warnings. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fa2ce3a2e988270f45735199caccbf77208ea2f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fa2ce3a2e988270f45735199caccbf77208ea2f You're receiving 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 Nov 14 14:15:36 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 14 Nov 2023 09:15:36 -0500 Subject: [Git][ghc/ghc][wip/T24083a] Second fix to #24083 Message-ID: <655381083c50b_1b4714279c893023335c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T24083a at Glasgow Haskell Compiler / GHC Commits: f91e8418 by Simon Peyton Jones at 2023-11-14T14:13:46+00:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 3 changed files: - compiler/GHC/Tc/Gen/HsType.hs - + testsuite/tests/polykinds/T24083a.hs - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2569,23 +2569,19 @@ kcCheckDeclHeader_sig sig_kind name flav -- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'. -- -- Also see Note [Arity of type families and type synonyms] - ; ctx_k <- kc_res_ki + ; res_kind :: ContextKind <- kc_res_ki ; let sig_res_kind' = mkTyConKind excess_sig_tcbs sig_res_kind ; traceTc "kcCheckDeclHeader_sig 2" $ vcat [ text "excess_sig_tcbs" <+> ppr excess_sig_tcbs - , text "ctx_k" <+> ppr ctx_k + , text "res_kind" <+> ppr res_kind , text "sig_res_kind'" <+> ppr sig_res_kind' ] - -- Unify res_ki (from the type declaration) with the residual kind from - -- the kind signature. Don't forget to apply the skolemising 'subst' first. - ; case ctx_k of - AnyKind -> return () -- No signature - _ -> do - res_ki <- newExpectedKind ctx_k - check_exp_res_ki sig_res_kind' res_ki + -- Unify res_ki (from the type declaration) with + -- sig_res_kind', the residual kind from the kind signature. + ; checkExpectedResKind sig_res_kind' res_kind -- Add more binders for data/newtype, so the result kind has no arrows -- See Note [Datatype return kinds] @@ -2608,7 +2604,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2650,18 +2646,23 @@ kcCheckDeclHeader_sig sig_kind name flav -- | Check the result kind annotation on a type constructor against -- the corresponding section of the standalone kind signature. -- Drops invisible binders that interfere with unification. -check_exp_res_ki :: TcKind -- ^ the actual kind - -> TcKind -- ^ the expected kind - -> TcM () -check_exp_res_ki act_kind exp_kind - = discardResult $ unifyKind Nothing act_kind' exp_kind - where - (_, act_kind') = splitInvisPiTysN n_to_inst act_kind +checkExpectedResKind :: TcKind -- ^ the result kind from the separate kind signature + -> ContextKind -- ^ the result kind from the declaration header + -> TcM () +checkExpectedResKind _ AnyKind + = return () -- No signature in the declaration header +checkExpectedResKind sig_kind res_ki + = do { actual_res_ki <- newExpectedKind res_ki - -- by analogy with checkExpectedKind - n_exp_invis_bndrs = invisibleTyBndrCount exp_kind - n_act_invis_bndrs = invisibleTyBndrCount act_kind - n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + ; let -- Drop invisible binders from sig_kind until they match up + -- with res_ki. By analogy with checkExpectedKind. + n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki + n_sig_invis_bndrs = invisibleTyBndrCount sig_kind + n_to_inst = n_sig_invis_bndrs - n_res_invis_bndrs + + (_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind + + ; discardResult $ unifyKind Nothing sig_kind' actual_res_ki } matchUpSigWithDecl :: Name -- Name of the type constructor for error messages @@ -2964,13 +2965,16 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] + -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars sig_tcbs scoped_prs - = mapM_ report_disconnected (filterOut ok scoped_prs) +checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs + = when (needsEtaExpansion flav) $ + -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] + mapM_ report_disconnected (filterOut ok scoped_prs) where sig_tvs = mkVarSet (binderVars sig_tcbs) ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs @@ -3047,6 +3051,25 @@ phantom synonym that just discards its argument. So our plan is this: See #24083 for dicussion of alternatives, none satisfactory. Also the fix is easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` explicitly, rather than binding it implicitly via unification. + +(DTV1) We only want to make this check when there /are/ scoped type variables; and + that is determined by needsEtaExpansion. Examples: + + type C :: x -> y -> Constraint + class C a :: b -> Constraint where { ... } + -- The a,b scope over the "..." + + type D :: forall k. k -> Type + data family D :: kk -> Type + -- Nothing for `kk` to scope over! + + In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will + return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty. So if we do + the check-for-disconnected-tyvars check we'll complain that `kk` is not bound + to one of `all_tcbs` (see #24083, comments about the `singletons` package). + + The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, + where needsEtaExpansion is True. -} {- ********************************************************************* ===================================== testsuite/tests/polykinds/T24083a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ScopedTypeVariables, RankNTypes #-} + +module T24083a where + +type TyCon :: (k1 -> k2) -> unmatchable_fun +data family TyCon :: (k1 -> k2) -> unmatchable_fun ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -244,3 +244,4 @@ test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) test('T24083', normal, compile_fail, ['']) +test('T24083a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f91e84188add4f91fa94fa9347513dff2e27fab8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f91e84188add4f91fa94fa9347513dff2e27fab8 You're receiving 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 Nov 14 18:00:37 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Tue, 14 Nov 2023 13:00:37 -0500 Subject: [Git][ghc/ghc][wip/bump-bytestring-0.12.1-dev] 13 commits: Create specially-solved DataToTag class Message-ID: <6553b5c55d772_1b47142cd59d882861fc@gitlab.mail> Matthew Craven pushed to branch wip/bump-bytestring-0.12.1-dev at Glasgow Haskell Compiler / GHC Commits: 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - f834cc8a by Matthew Craven at 2023-11-14T13:00:18-05:00 Bump bytestring submodule to upstream HEAD ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c which reworks unaligned writes in Builder can see wider testing. The less-terrible code for unaligned writes used in Builder on hosts not known to be ulaigned-friendly also takes less effort for GHC to compile, resulting in a metric decrease for T21839c on some platforms. The metric increase on T21839r is caused by the unrelated commit 750dac33465e7b59100698a330b44de7049a345c. It perhaps warrants further analysis and discussion (see #23822) but is not critical. Metric Decrease: T21839c Metric Increase: T21839r - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/9.10.1-notes.rst - hadrian/src/Builder.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da64f934ade2648a6f8261f709a477a05a768c07...f834cc8a9e15682a3ee161277fca165cc523fbd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da64f934ade2648a6f8261f709a477a05a768c07...f834cc8a9e15682a3ee161277fca165cc523fbd2 You're receiving 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 Nov 14 21:04:38 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 14 Nov 2023 16:04:38 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/foreign-libs-test Message-ID: <6553e0e6d4eee_1b4714310f3df02961d1@gitlab.mail> Matthew Pickering pushed new branch wip/foreign-libs-test at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/foreign-libs-test You're receiving 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 Nov 14 22:01:23 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 14 Nov 2023 17:01:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-splitlhsforalltyinvis Message-ID: <6553ee3329b7_1b4714326bd71c30120@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-splitlhsforalltyinvis at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-splitlhsforalltyinvis You're receiving 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 Nov 15 09:35:52 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 04:35:52 -0500 Subject: [Git][ghc/ghc][wip/foreign-libs-test] fix test Message-ID: <655490f870154_1b47144280f7903452d9@gitlab.mail> Matthew Pickering pushed to branch wip/foreign-libs-test at Glasgow Haskell Compiler / GHC Commits: 31f9b6ea by Matthew Pickering at 2023-11-15T09:35:42+00:00 fix test - - - - - 2 changed files: - testsuite/tests/driver/Makefile - − testsuite/tests/driver/driver016a.stderr Changes: ===================================== testsuite/tests/driver/Makefile ===================================== @@ -65,11 +65,10 @@ test016: test -f F016_stub.h testForeignExportSharedLibrary: - $(RM) F016.hi F016$(dllext) - "$(TEST_HC)" $(TEST_HC_OPTS) -shared -dynamic -fPIC F016.hs -flink-rts -o libfoo$(dllext) - "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic -no-hs-main f016.c -lfoo -L. - "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic -no-hs-main f016.o -lfoo -L. -optl-Wl,-rpath,'$ORIGIN' -o f016$(exeext) - ./f016$(exeext) + $(RM) F016.hi libfoo$(dllext) f016$(exeext) + "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) -shared -dynamic -fPIC F016.hs -flink-rts -o libfoo$(dllext) + LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) -dynamic -no-hs-main f016.c -lfoo -o f016$(exeext) + LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./f016$(exeext) # test -stubdir (filename differs from module name) test017: ===================================== testsuite/tests/driver/driver016a.stderr deleted ===================================== @@ -1,6 +0,0 @@ -Warning: -rtsopts and -with-rtsopts have no effect with -shared. - Call hs_init_ghc() from your main() function to set these options. -Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. - Call hs_init_ghc() from your main() function to set these options. -Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. - Call hs_init_ghc() from your main() function to set these options. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31f9b6ea1fc2163b09d0041ce610efe0f3661a66 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31f9b6ea1fc2163b09d0041ce610efe0f3661a66 You're receiving 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 Nov 15 10:08:23 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 05:08:23 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Add since annotation for showHFloat Message-ID: <6554989770ac_1b4714434d74143670ba@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - 9da2596d by Zubin Duggal at 2023-11-14T15:42:22+05:30 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 90ea86e0 by Alan Zimmerman at 2023-11-15T05:08:01-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - 3 changed files: - compiler/GHC/Hs/Type.hs - docs/users_guide/conf.py - libraries/base/src/Numeric.hs Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -701,10 +701,10 @@ splitLHsPatSynTy ty = (univs, reqs, exis, provs, ty4) HsOuterImplicit{} -> ([], ignoreParens body) HsOuterExplicit{hso_bndrs = exp_bndrs} -> (exp_bndrs, body) - (univs, ty1) = split_sig_ty ty - (reqs, ty2) = splitLHsQualTy ty1 - ((_an, exis), ty3) = splitLHsForAllTyInvis ty2 - (provs, ty4) = splitLHsQualTy ty3 + (univs, ty1) = split_sig_ty ty + (reqs, ty2) = splitLHsQualTy ty1 + (exis, ty3) = splitLHsForAllTyInvis ty2 + (provs, ty4) = splitLHsQualTy ty3 -- | Decompose a sigma type (of the form @forall . context => body@) -- into its constituent parts. @@ -724,8 +724,8 @@ splitLHsSigmaTyInvis :: LHsType (GhcPass p) -> ([LHsTyVarBndr Specificity (GhcPass p)] , Maybe (LHsContext (GhcPass p)), LHsType (GhcPass p)) splitLHsSigmaTyInvis ty - | ((_an,tvs), ty1) <- splitLHsForAllTyInvis ty - , (ctxt, ty2) <- splitLHsQualTy ty1 + | (tvs, ty1) <- splitLHsForAllTyInvis ty + , (ctxt, ty2) <- splitLHsQualTy ty1 = (tvs, ctxt, ty2) -- | Decompose a GADT type into its constituent parts. @@ -770,11 +770,11 @@ splitLHsGadtTy (L _ sig_ty) -- Unlike 'splitLHsSigmaTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis :: - LHsType (GhcPass pass) -> ( (EpAnnForallTy, [LHsTyVarBndr Specificity (GhcPass pass)]) + LHsType (GhcPass pass) -> ( [LHsTyVarBndr Specificity (GhcPass pass)] , LHsType (GhcPass pass)) splitLHsForAllTyInvis ty | ((mb_tvbs), body) <- splitLHsForAllTyInvis_KP (ignoreParens ty) - = (fromMaybe (EpAnnNotUsed,[]) mb_tvbs, body) + = (fromMaybe [] mb_tvbs, body) -- | Decompose a type of the form @forall . body@ into its constituent -- parts. Only splits type variable binders that @@ -788,14 +788,13 @@ splitLHsForAllTyInvis ty -- Unlike 'splitLHsForAllTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis_KP :: - LHsType (GhcPass pass) -> (Maybe (EpAnnForallTy, [LHsTyVarBndr Specificity (GhcPass pass)]) + LHsType (GhcPass pass) -> (Maybe ([LHsTyVarBndr Specificity (GhcPass pass)]) , LHsType (GhcPass pass)) splitLHsForAllTyInvis_KP lty@(L _ ty) = case ty of - HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an - , hsf_invis_bndrs = tvs } + HsForAllTy { hst_tele = HsForAllInvis {hsf_invis_bndrs = tvs } , hst_body = body } - -> (Just (an, tvs), body) + -> (Just tvs, body) _ -> (Nothing, lty) -- | Decompose a type of the form @context => body@ into its constituent parts. ===================================== docs/users_guide/conf.py ===================================== @@ -225,7 +225,7 @@ def haddock_role(lib): # for the template_haskell.rst example this will be '..' current_doc_to_topdir = os.path.relpath(topdir, os.path.dirname(current_doc)) - relative_path = '%s/%s/%s-%s' % (current_doc_to_topdir, libs_base_uri, lib, lib_version) + relative_path = '%s/%s/%s' % (current_doc_to_topdir, libs_base_uri, lib_version) uri = '%s/%s.html%s' % (relative_path, module, anchor) ===================================== libraries/base/src/Numeric.hs ===================================== @@ -243,6 +243,8 @@ similar to the @%a@ specifier in C's printf. "-0x1.9851ecp3" >>> showHFloat (-0 :: Double) "" "-0x0p+0" + + at since 4.11.0.0 -} showHFloat :: RealFloat a => a -> ShowS showHFloat = showString . fmt View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87d9a93e4b9eafe1321a48c09c2e9b2f99ad4aca...90ea86e0f0ef1d98e6ec1eb1e347a9377aaa6268 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87d9a93e4b9eafe1321a48c09c2e9b2f99ad4aca...90ea86e0f0ef1d98e6ec1eb1e347a9377aaa6268 You're receiving 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 Nov 15 11:13:19 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 06:13:19 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Don't build genapply for javascript backend Message-ID: <6554a7cf5243c_1b471444fdfdc439165@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: ca0ba472 by GHC GitLab CI at 2023-11-15T11:06:57+00:00 Don't build genapply for javascript backend - - - - - 2 changed files: - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Default.hs Changes: ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -153,10 +153,13 @@ buildBinDistDir root conf at BindistConfig{..} = do lib_pkgs <- stagePackages library_stage (lib_targets, _) <- partitionEithers <$> mapM (pkgTarget conf) lib_pkgs - bin_pkgs <- stagePackages executable_stage + bin_pkgs_all <- stagePackages executable_stage + -- Things we don't want to distribute ever + let excluded_packages = [ genapply ] + bin_pkgs = filter (`notElem` excluded_packages) bin_pkgs_all (_, bin_targets) <- partitionEithers <$> mapM (pkgTarget conf) bin_pkgs - liftIO $ print (library_stage, executable_stage, lib_targets, bin_targets) + cross <- flag CrossCompiling ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -131,6 +131,7 @@ stage1Packages = do libraries0 <- filter good_stage0_package <$> stage0Packages cross <- flag CrossCompiling winTarget <- isWinTarget Stage1 + jsTarget <- isJsTarget Stage2 let when c xs = if c then xs else mempty @@ -160,9 +161,10 @@ stage1Packages = do , xhtml , haddock , hpcBin - , genapply , if winTarget then win32 else unix ] ++ + [ genapply | not jsTarget ] + ++ [ iserv , runGhc , ghcToolchainBin View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca0ba472fb138438309358891b18267506d7a512 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca0ba472fb138438309358891b18267506d7a512 You're receiving 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 Nov 15 11:36:41 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 06:36:41 -0500 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 30 commits: Add laws relating between Foldable/Traversable with their Bi- superclasses Message-ID: <6554ad497f7f4_1b471445a283a839398e@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - 1cd2aeab by Matthew Pickering at 2023-11-15T11:36:23+00:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 8ebda3ae by Matthew Pickering at 2023-11-15T11:36:23+00:00 fail when bindist configure fails - - - - - f737fbce by Matthew Pickering at 2023-11-15T11:36:23+00:00 Correctly propagate build/host/target to bindist fix host/target bindist t - - - - - 0f1b6a9f by Matthew Pickering at 2023-11-15T11:36:23+00:00 ci: Test cross bindists - - - - - 347b4a68 by Matthew Pickering at 2023-11-15T11:36:23+00:00 CROSS_STAGE variable - - - - - 0282f019 by Matthew Pickering at 2023-11-15T11:36:23+00:00 Use explicit syntax rather than pure - - - - - 068020a5 by Matthew Pickering at 2023-11-15T11:36:23+00:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - 86ff4d34 by Matthew Pickering at 2023-11-15T11:36:23+00:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 1ecac93c by Matthew Pickering at 2023-11-15T11:36:23+00:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - c1920a73 by GHC GitLab CI at 2023-11-15T11:36:23+00:00 fix - - - - - bcd6c0b3 by GHC GitLab CI at 2023-11-15T11:36:24+00:00 Build genapply per stage - - - - - d1e401d8 by GHC GitLab CI at 2023-11-15T11:36:24+00:00 Correct GHC_PKG path - - - - - b1333990 by GHC GitLab CI at 2023-11-15T11:36:24+00:00 Don't build genapply for javascript backend - - - - - 321ed287 by Matthew Pickering at 2023-11-15T11:36:24+00:00 hadrian: Make binary-dist-dir the default build target This allows us to have the logic in one place about which libraries/stages to build with cross compilers. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca0ba472fb138438309358891b18267506d7a512...321ed287c8de98b861e8e65fdacb1317e9acefb1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca0ba472fb138438309358891b18267506d7a512...321ed287c8de98b861e8e65fdacb1317e9acefb1 You're receiving 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 Nov 15 11:46:38 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 15 Nov 2023 06:46:38 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/24107 Message-ID: <6554af9e60770_1b471445b82fc83980a5@gitlab.mail> Zubin pushed new branch wip/24107 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/24107 You're receiving 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 Nov 15 13:50:27 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Wed, 15 Nov 2023 08:50:27 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/deprecated-type-abstractions Message-ID: <6554cca3b40e9_1b4714493f0a6841367f@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/deprecated-type-abstractions at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/deprecated-type-abstractions You're receiving 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 Nov 15 14:48:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 09:48:56 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Suppress duplicate librares linker warning of new macOS linker Message-ID: <6554da586becf_1b47144aa9df9042524b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 972f0cb7 by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - 0967d7e7 by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - 64d1972c by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - dfbebe59 by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 2b06ea69 by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - 8a64c411 by Rodrigo Mesquita at 2023-11-15T09:48:44-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 7a64d229 by Luite Stegeman at 2023-11-15T09:48:49-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 06b4d6c8 by Krzysztof Gogolewski at 2023-11-15T09:48:50-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - afa71dc3 by Zubin Duggal at 2023-11-15T09:48:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 9fdfbd80 by Alan Zimmerman at 2023-11-15T09:48:51-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/conf.py - docs/users_guide/using-warnings.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - libraries/base/tests/IO/all.T - + m4/fp_ld_no_warn_duplicate_libraries.m4 - m4/fp_prog_ld_no_compact_unwind.m4 - + m4/fp_prog_ld_single_module.m4 - m4/prep_target_file.m4 - testsuite/tests/driver/Makefile The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90ea86e0f0ef1d98e6ec1eb1e347a9377aaa6268...9fdfbd801a97481a74dc5951d395d2599806c9e2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90ea86e0f0ef1d98e6ec1eb1e347a9377aaa6268...9fdfbd801a97481a74dc5951d395d2599806c9e2 You're receiving 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 Nov 15 15:59:35 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 15 Nov 2023 10:59:35 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-ipe-test Message-ID: <6554eae7758b1_1b47144c8159244465b7@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/fix-ipe-test at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-ipe-test You're receiving 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 Nov 15 16:00:56 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 15 Nov 2023 11:00:56 -0500 Subject: [Git][ghc/ghc][wip/fix-ipe-test] Fix IPE test Message-ID: <6554eb3824644_1b47144c2f589044671c@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/fix-ipe-test at Glasgow Haskell Compiler / GHC Commits: d445cbc6 by Krzysztof Gogolewski at 2023-11-15T17:00:33+01:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 2 changed files: - testsuite/tests/rts/all.T - testsuite/tests/rts/ipe/all.T Changes: ===================================== testsuite/tests/rts/all.T ===================================== @@ -216,10 +216,6 @@ test('EventlogOutput_IPE', ], makefile_test, ['EventlogOutput_IPE']) -# Remove the capability prefix from IPE event log lines. -def noCapabilityOutputFilter(s): - return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) - test('T4059', req_c, makefile_test, ['T4059']) # Test for #4274 ===================================== testsuite/tests/rts/ipe/all.T ===================================== @@ -1,3 +1,7 @@ +# Remove the capability prefix from IPE event log lines. +def noCapabilityOutputFilter(s): + return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) + test('ipeMap', [extra_files(['ipe_lib.c', 'ipe_lib.h']), c_src, omit_ghci], compile_and_run, ['ipe_lib.c']) # Manually create IPE entries and dump them to event log (stderr). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d445cbc60d94d9f3449b979d5f312c5c3e76b86c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d445cbc60d94d9f3449b979d5f312c5c3e76b86c You're receiving 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 Nov 15 16:43:11 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 11:43:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/testsuite-generic-stats Message-ID: <6554f51f72358_1b47144d8e5a4c4669ce@gitlab.mail> Matthew Pickering pushed new branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/testsuite-generic-stats You're receiving 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 Nov 15 16:45:32 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 11:45:32 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <6554f5ac581de_1b47144d9101e8468862@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 8624c29d by Matthew Pickering at 2023-11-15T16:45:12+00:00 testsuite: Add mechanism to collect generic metrics TODO - - - - - 5 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -396,6 +396,9 @@ class TestOptions: # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Does this test define a generic stats test? + self.generic_stats_test = None + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -99,6 +99,11 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + print(opts.generic_stats_test) + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +604,43 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'static/size', deviation, lambda: os.path.getsize(path) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_stat(name : TestName, opts, get_stat): + + opts.generic_stats_test = get_stat + + for (metric, info) in get_stat.items(): + + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + + opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, + deviation=info['deviation']) + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -1733,6 +1775,54 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) + + +def check_generic_stats(name, way, get_stats, range_fields): + + for (metric, baseline_and_dev) in range_fields.items(): + if metric in get_stats: + actual_val = get_stats[metric]['action']() + basline_and_dev = range_fields[metric] + return report_stats(name, way, metric, basline_and_dev, actual_val) + +def report_stats(name, way, metric, baseline_and_dev, actual_val): + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None + if head_commit is None: + return passed() + + result = passed() + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = baseline_and_dev.baseline(way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + tolerance_dev = baseline_and_dev.deviation + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + tolerance_dev, + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result + return result + # ----------------------------------------------------------------------------- # Check test stats. This prints the results for the user. # name: name of the test. @@ -1746,9 +1836,6 @@ def check_stats(name: TestName, stats_file: Path, range_fields: Dict[MetricName, MetricOracles] ) -> PassFail: - head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None - if head_commit is None: - return passed() result = passed() if range_fields: @@ -1771,36 +1858,8 @@ def check_stats(name: TestName, assert val is not None actual_val = int(val) - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) + result = report_stats(name, way, metric, baseline_and_dev, actual_val) - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result return result @@ -1918,6 +1977,11 @@ async def simple_build(name: Union[TestName, str], if badResult(statsResult): return statsResult + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + return passed() # ----------------------------------------------------------------------------- @@ -2002,8 +2066,14 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # Check runtime stats if desired. if stats_file is not None: return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + + # Check other generic stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'hello.o')], compile, ['']) + +test('libdir',[stat_from_file('static/size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8624c29d0f5ebf4942b3482a020e566809639e58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8624c29d0f5ebf4942b3482a020e566809639e58 You're receiving 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 Nov 15 18:19:37 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:19:37 -0500 Subject: [Git][ghc/ghc][master] 6 commits: Suppress duplicate librares linker warning of new macOS linker Message-ID: <65550bb9b9e1c_1b47144fe65f884985ef@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 19 changed files: - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs - libraries/base/tests/IO/all.T - + m4/fp_ld_no_warn_duplicate_libraries.m4 - m4/fp_prog_ld_no_compact_unwind.m4 - + m4/fp_prog_ld_single_module.m4 - m4/prep_target_file.m4 - testsuite/tests/driver/Makefile - testsuite/tests/driver/all.T - testsuite/tests/perf/compiler/all.T - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -11,6 +11,7 @@ where import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Settings (ToolSettings(toolSettings_ldSupportsSingleModule)) import GHC.Driver.Config.Linker import GHC.Driver.Session @@ -152,6 +153,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- dynamic binding nonsense when referring to symbols from -- within the library. The NCG assumes that this option is -- specified (on i386, at least). + -- In XCode 15, -single_module is the default and passing the + -- flag is now obsolete and raises a warning (#24168). We encode + -- this information into the toolchain field ...SupportsSingleModule. -- -install_name -- Mac OS/X stores the path where a dynamic library is (to -- be) installed in the library itself. It's called the @@ -177,8 +181,11 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages ] ++ map Option o_files ++ [ Option "-undefined", - Option "dynamic_lookup", - Option "-single_module" ] + Option "dynamic_lookup" + ] + ++ (if toolSettings_ldSupportsSingleModule (toolSettings dflags) + then [ Option "-single_module" ] + else [ ]) ++ (if platformArch platform `elem` [ ArchX86_64, ArchAArch64 ] then [ ] else [ Option "-Wl,-read_only_relocs,suppress" ]) ===================================== compiler/GHC/Settings.hs ===================================== @@ -86,6 +86,7 @@ data Settings = Settings data ToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind :: Bool , toolSettings_ldSupportsFilelist :: Bool + , toolSettings_ldSupportsSingleModule :: Bool , toolSettings_mergeObjsSupportsResponseFiles :: Bool , toolSettings_ldIsGnuLd :: Bool , toolSettings_ccSupportsNoPie :: Bool ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -107,6 +107,7 @@ initSettings top_dir = do ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind" ldSupportsFilelist <- getBooleanSetting "ld supports filelist" + ldSupportsSingleModule <- getBooleanSetting "ld supports single module" mergeObjsSupportsResponseFiles <- getBooleanSetting "Merge objects supports response files" ldIsGnuLd <- getBooleanSetting "ld is GNU ld" arSupportsDashL <- getBooleanSetting "ar supports -L" @@ -171,6 +172,7 @@ initSettings top_dir = do , sToolSettings = ToolSettings { toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind , toolSettings_ldSupportsFilelist = ldSupportsFilelist + , toolSettings_ldSupportsSingleModule = ldSupportsSingleModule , toolSettings_mergeObjsSupportsResponseFiles = mergeObjsSupportsResponseFiles , toolSettings_ldIsGnuLd = ldIsGnuLd , toolSettings_ccSupportsNoPie = gccSupportsNoPie ===================================== configure.ac ===================================== @@ -452,6 +452,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** Which nm to use? @@ -613,11 +614,17 @@ 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 +#-no_fixup_chains 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]) +#-no_warn_duplicate_libraries +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES GHC_LLVM_TARGET_SET_VAR ===================================== distrib/configure.ac.in ===================================== @@ -136,6 +136,7 @@ CFLAGS="$CFLAGS $GccUseLdOpt" FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST +FP_PROG_LD_SINGLE_MODULE dnl ** which strip to use? dnl -------------------------------------------------------------- @@ -175,11 +176,17 @@ 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]) +#-no_fixup_chains 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]) +#-no_warn_duplicate_libraries +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES AC_SUBST(CONF_CC_OPTS_STAGE0) ===================================== hadrian/bindist/Makefile ===================================== @@ -104,6 +104,7 @@ lib/settings : config.mk @echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@ @echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@ @echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@ + @echo ',("ld supports single module", "$(LdHasSingleModule)")' >> $@ @echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@ @echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@ @echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -191,6 +191,7 @@ LdHasBuildId = @LdHasBuildId@ LdHasFilelist = @LdHasFilelist@ LdIsGNULd = @LdIsGNULd@ LdHasNoCompactUnwind = @LdHasNoCompactUnwind@ +LdHasSingleModule = @LdHasSingleModule@ ArArgs = @ArArgs@ ArSupportsAtFile = @ArSupportsAtFile@ ArSupportsDashL = @ArSupportsDashL@ ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = False , ccLinkSupportsCompactUnwind = False , ccLinkSupportsFilelist = False +, ccLinkSupportsSingleModule = True , ccLinkIsGnu = False } ===================================== hadrian/cfg/default.target.in ===================================== @@ -21,6 +21,7 @@ Target , ccLinkSupportsNoPie = @CONF_GCC_SUPPORTS_NO_PIEBool@ , ccLinkSupportsCompactUnwind = @LdHasNoCompactUnwindBool@ , ccLinkSupportsFilelist = @LdHasFilelistBool@ +, ccLinkSupportsSingleModule = @LdHasSingleModuleBool@ , ccLinkIsGnu = @LdIsGNULdBool@ } ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -373,6 +373,7 @@ generateSettings = do , ("Haskell CPP flags", queryTarget hsCppFlags) , ("ld supports compact unwind", queryTarget linkSupportsCompactUnwind) , ("ld supports filelist", queryTarget linkSupportsFilelist) + , ("ld supports single module", queryTarget linkSupportsSingleModule) , ("ld is GNU ld", queryTarget linkIsGnu) , ("Merge objects command", queryTarget mergeObjsPath) , ("Merge objects flags", queryTarget mergeObjsFlags) @@ -431,6 +432,7 @@ generateSettings = do hsCppFlags = unwords . prgFlags . hsCppProgram . tgtHsCPreprocessor mergeObjsPath = maybe "" (prgPath . mergeObjsProgram) . tgtMergeObjs mergeObjsFlags = maybe "" (unwords . prgFlags . mergeObjsProgram) . tgtMergeObjs + linkSupportsSingleModule = yesNo . ccLinkSupportsSingleModule . tgtCCompilerLink linkSupportsFilelist = yesNo . ccLinkSupportsFilelist . tgtCCompilerLink linkSupportsCompactUnwind = yesNo . ccLinkSupportsCompactUnwind . tgtCCompilerLink linkIsGnu = yesNo . ccLinkIsGnu . tgtCCompilerLink ===================================== libraries/base/tests/IO/all.T ===================================== @@ -136,7 +136,11 @@ test('encoding004', [extra_files(['encoded-data/']), js_broken(22374), # and # https://gitlab.haskell.org/ghc/wasi-libc/-/blob/main/libc-top-half/musl/src/locale/codepages.h # for locales supported by wasi-libc's iconv implementation -when(arch('wasm32'), skip)], compile_and_run, ['']) +when(arch('wasm32'), skip), +# MacOS Sonoma iconv() has a regression that causes this test to fail on the +# CP936 roundtrip. See the ticket for related issues in other projects. +when(opsys('darwin'), fragile(24161)) +], compile_and_run, ['']) test('encoding005', normal, compile_and_run, ['']) test('environment001', [], makefile_test, ['environment001-test']) ===================================== m4/fp_ld_no_warn_duplicate_libraries.m4 ===================================== @@ -0,0 +1,29 @@ +# FP_LD_NO_WARN_DUPLICATE_LIBRARIES +# --------------------------------- +# XCode 15 introduced a new linker which warns on duplicate libraries being +# linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as +# suggested by Brad King in CMake issue #25297. +# +# This flag isn't necessarily available to other linkers on darwin, so we must +# only configure it into the CC linker arguments if valid. +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_WARN_DUPLICATE_LIBRARIES], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether the linker requires -no_warn_duplicate_libraries]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest -Wl,-no_warn_duplicate_libraries conftest.c > /dev/null 2>&1 + then + $2="$$2 -Wl,-no_warn_duplicate_libraries" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o conftest + ;; + + esac +]) + ===================================== m4/fp_prog_ld_no_compact_unwind.m4 ===================================== @@ -6,7 +6,7 @@ AC_DEFUN([FP_PROG_LD_NO_COMPACT_UNWIND], [ AC_CACHE_CHECK([whether ld understands -no_compact_unwind], [fp_cv_ld_no_compact_unwind], [ -case $build in +case $target in *-darwin) echo 'int foo() { return 0; }' > conftest.c "${CC-cc}" -c conftest.c ===================================== m4/fp_prog_ld_single_module.m4 ===================================== @@ -0,0 +1,30 @@ +# FP_PROG_LD_SINGLE_MODULE +# ---------------------------- +# Sets the output variable LdHasSingleModule to YES if the darwin ld supports +# -single_module, or NO otherwise. +# +# In XCode 15, -single_module is a default and passing it as a flag raises a +# warning. +AC_DEFUN([FP_PROG_LD_SINGLE_MODULE], +[ +AC_CACHE_CHECK([whether ld supports -single_module], [fp_cv_ld_single_module], +[ +case $target in + *-darwin) + echo 'int foo(int x) { return x*x; }' > conftest.c + echo 'extern int foo(int); int main() { return foo(5); }' > conftestmain.c + "$CC" -c -o conftestmain.o conftestmain.c + "$CC" -shared -o conftest.dylib conftest.c + if "$CC" -Wl,-single_module -o conftest conftestmain.o conftest.dylib 2>&1 | grep obsolete > /dev/null; then + fp_cv_ld_single_module=no + else + fp_cv_ld_single_module=yes + fi + rm -rf conftest* ;; + *) + fp_cv_ld_single_module=no ;; +esac +]) +FP_CAPITALIZE_YES_NO(["$fp_cv_ld_single_module"], [LdHasSingleModule]) +AC_SUBST([LdHasSingleModule]) +])# FP_PROG_LD_SINGLE_MODULE ===================================== m4/prep_target_file.m4 ===================================== @@ -131,6 +131,7 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_BOOLEAN([TargetHasIdentDirective]) PREP_BOOLEAN([CONF_GCC_SUPPORTS_NO_PIE]) PREP_BOOLEAN([LdHasFilelist]) + PREP_BOOLEAN([LdHasSingleModule]) PREP_BOOLEAN([LdIsGNULd]) PREP_BOOLEAN([LdHasNoCompactUnwind]) PREP_BOOLEAN([TargetHasSubsectionsViaSymbols]) ===================================== testsuite/tests/driver/Makefile ===================================== @@ -552,8 +552,8 @@ T7563: -"$(TEST_HC)" $(TEST_HC_OPTS) -C T7563.hs # Below we set LC_ALL=C to request standard ASCII output in the resulting error -# messages. Unfortunately, Mac OS X and Windows still use a Unicode encoding -# even with LC_ALL=C, so we expect these tests to fail there. +# messages. Unfortunately, versions of MacOS prior to Sonoma and Windows still +# use a Unicode encoding even with LC_ALL=C, so we expect these tests to fail there. .PHONY: T6037 T6037: ===================================== testsuite/tests/driver/all.T ===================================== @@ -178,16 +178,25 @@ test('T7060', [], makefile_test, []) test('T7130', normal, compile_fail, ['-fflul-laziness']) test('T7563', when(unregisterised(), skip), makefile_test, []) test('T6037', - # The testsuite doesn't know how to set a non-Unicode locale on Windows or Mac OS X - [when(opsys('mingw32'), expect_fail), when(opsys('darwin'), expect_fail)], + # The testsuite doesn't know how to set a non-Unicode locale on Windows or MacOS < Sonoma. + # Because in previous version of MacOS the test is still broken, we mark it as fragile. + [when(opsys('mingw32'), expect_fail), + when(opsys('darwin'), fragile(24161)) + ], makefile_test, []) test('T2507', - # The testsuite doesn't know how to set a non-Unicode locale on Windows or Mac OS X - [when(opsys('mingw32'), expect_fail), when(opsys('darwin'), expect_fail)], + # The testsuite doesn't know how to set a non-Unicode locale on Windows or MacOS < Sonoma + # Because in previous version of MacOS the test is still broken, we mark it as fragile. + [when(opsys('mingw32'), expect_fail), + when(opsys('darwin'), fragile(24161)) + ], makefile_test, []) test('T8959a', - # The testsuite doesn't know how to set a non-Unicode locale on Windows or Mac OS X - [when(opsys('mingw32'), expect_fail), when(opsys('darwin'), expect_fail)], + # The testsuite doesn't know how to set a non-Unicode locale on Windows or MacOS < Sonoma + # Because in previous version of MacOS the test is still broken, we mark it as fragile. + [when(opsys('mingw32'), expect_fail), + when(opsys('darwin'), fragile(24161)) + ], makefile_test, []) # Requires readelf ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -361,7 +361,10 @@ test('MultiLayerModulesTH_Make', pre_cmd('$MAKE -s --no-print-directory MultiLayerModulesTH_Make_Prep'), extra_files(['genMultiLayerModulesTH']), unless(have_dynamic(),skip), - compile_timeout_multiplier(5) + compile_timeout_multiplier(5), + # We skip the test on darwin due to recent regression due to toolchain + # upgrade (tracked in #24177) + when(opsys('darwin'), skip) ], multimod_compile_fail, # see Note [Increased initial stack size for MultiLayerModules] ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -22,6 +22,7 @@ data CcLink = CcLink { ccLinkProgram :: Program , ccLinkSupportsNoPie :: Bool -- See Note [No PIE when linking] in GHC.Driver.Session , ccLinkSupportsCompactUnwind :: Bool , ccLinkSupportsFilelist :: Bool + , ccLinkSupportsSingleModule :: Bool , ccLinkIsGnu :: Bool } deriving (Read, Eq, Ord) @@ -34,6 +35,7 @@ instance Show CcLink where , ", ccLinkSupportsNoPie = " ++ show ccLinkSupportsNoPie , ", ccLinkSupportsCompactUnwind = " ++ show ccLinkSupportsCompactUnwind , ", ccLinkSupportsFilelist = " ++ show ccLinkSupportsFilelist + , ", ccLinkSupportsSingleModule = " ++ show ccLinkSupportsSingleModule , ", ccLinkIsGnu = " ++ show ccLinkIsGnu , "}" ] @@ -66,13 +68,15 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram + ccLinkSupportsSingleModule <- checkSupportsSingleModule archOs cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram checkBfdCopyBug archOs cc readelf ccLinkProgram ccLinkProgram <- addPlatformDepLinkFlags archOs cc ccLinkProgram let ccLink = CcLink {ccLinkProgram, ccLinkSupportsNoPie, ccLinkSupportsCompactUnwind, ccLinkSupportsFilelist, - ccLinkIsGnu} + ccLinkSupportsSingleModule, ccLinkIsGnu} ccLink <- linkRequiresNoFixupChains archOs cc ccLink + ccLink <- linkRequiresNoWarnDuplicateLibraries archOs cc ccLink return ccLink @@ -163,6 +167,35 @@ checkSupportsFilelist cc ccLink = checking "whether the cc linker understands -f return (isSuccess exitCode) +-- | Check that the (darwin) linker supports @-single_module at . +-- +-- In XCode 15, the linker warns when @-single_module@ is passed as the flag +-- became the default and is now obsolete to pass. +-- +-- We assume non-darwin linkers don't support this flag. +checkSupportsSingleModule :: ArchOS -> Cc -> Program -> M Bool +checkSupportsSingleModule archOs cc link + | ArchOS _ OSDarwin <- archOs + = checking "whether the darwin linker supports -single_module" $ do + withTempDir $ \dir -> do + let test_dylib = dir "test.dylib" + test_c = dir "test.c" + testmain_o = dir "testmain.o" + testmain = dir "testmain" + + -- Main + compileC cc testmain_o "extern int foo(int); int main() { return foo(5); }" + + -- Dynamic library + writeFile test_c "int foo(int x) { return x*x; }" + _ <- runProgram (ccProgram cc) ["-shared", "-o", test_dylib, test_c] + + (_, out, err) <- readProgram link ["-Wl,-single_module", "-o", testmain, test_dylib, testmain_o] + + return $ not $ "obsolete" `isInfixOf` err || "obsolete" `isInfixOf` out + | otherwise + = return False + -- | Check whether linking works. checkLinkWorks :: Cc -> Program -> M () checkLinkWorks cc ccLink = withTempDir $ \dir -> do @@ -320,7 +353,7 @@ addNoAsNeeded archOs cc ccLink return ccLink' | otherwise = return ccLink --- See if whether we are using a version of ld64 on darwin platforms which +-- | See if whether we are using a version of ld64 on darwin platforms which -- requires us to pass -no_fixup_chains linkRequiresNoFixupChains :: ArchOS -> Cc -> CcLink -> M CcLink linkRequiresNoFixupChains archOs cc ccLink @@ -329,4 +362,16 @@ linkRequiresNoFixupChains archOs cc ccLink in (ccLink' <$ checkLinkWorks cc (ccLinkProgram ccLink')) <|> return ccLink | otherwise = return ccLink +-- | XCode 15 introduced a new linker which warns on duplicate libraries being +-- linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as +-- suggested by Brad King in CMake issue #25297. +-- +-- This flag isn't necessarily available to other linkers on darwin, so we must +-- only configure it into the CC linker arguments if valid. +linkRequiresNoWarnDuplicateLibraries :: ArchOS -> Cc -> CcLink -> M CcLink +linkRequiresNoWarnDuplicateLibraries archOs cc ccLink + | OSDarwin <- archOS_OS archOs = checking "whether CC linker requires -no_warn_duplicate_libraries" $ + let ccLink' = over (_ccLinkProgram % _prgFlags) (++["-Wl,-no_warn_duplicate_libraries"]) ccLink + in (ccLink' <$ checkLinkWorks cc (ccLinkProgram ccLink')) <|> return ccLink + | otherwise = return ccLink View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0745c34de69374f4eec832c9b30192aa5aed0424...af261ccd1df505c4ac13334162ddc1a2565664f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0745c34de69374f4eec832c9b30192aa5aed0424...af261ccd1df505c4ac13334162ddc1a2565664f1 You're receiving 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 Nov 15 18:21:09 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:21:09 -0500 Subject: [Git][ghc/ghc][master] JS: Fix missing variable declarations Message-ID: <65550c15b4390_1b47144fe551745047db@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 1 changed file: - compiler/GHC/StgToJS/Expr.hs Changes: ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -232,10 +232,10 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) = (L.find ((==i) . fst . snd) (zip [0..] vars)) mk_bh :: G JStgStat mk_bh | isUpdatable update = - do x <- Var <$> freshIdent + do x <- freshIdent return $ mconcat - [ x |= ApplExpr (var "h$bh_lne") [Sub sp (toJExpr myOffset), toJExpr (payloadSize+1)] - , IfStat x (ReturnStat x) mempty + [ x ||= ApplExpr (var "h$bh_lne") [Sub sp (toJExpr myOffset), toJExpr (payloadSize+1)] + , IfStat (Var x) (ReturnStat (Var x)) mempty ] | otherwise = pure mempty blk_hl <- mk_bh @@ -913,11 +913,11 @@ loadParams from args = do [ loadIfUsed (from .^ closureField1_) x1 u1 , loadIfUsed (from .^ closureField2_) x2 u2 ] - ((x,u):xs) -> do d <- Var <$> freshIdent + ((x,u):xs) -> do d <- freshIdent return $ mconcat [ loadIfUsed (from .^ closureField1_) x u - , mconcat [ d |= from .^ closureField2_ - , loadConVarsIfUsed d xs + , mconcat [ d ||= from .^ closureField2_ + , loadConVarsIfUsed (Var d) xs ] ] where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2125c17620c701a55d6bef48cfd1abc9cf183161 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2125c17620c701a55d6bef48cfd1abc9cf183161 You're receiving 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 Nov 15 18:23:05 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:23:05 -0500 Subject: [Git][ghc/ghc][master] Remove loopy superclass solve mechanism Message-ID: <65550c8996777_1b47144fe5517451168b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 26 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - docs/users_guide/using-warnings.rst - − testsuite/tests/typecheck/should_compile/T20666b.stderr - − testsuite/tests/typecheck/should_compile/T22891.stderr - − testsuite/tests/typecheck/should_compile/T22912.stderr - testsuite/tests/typecheck/should_compile/all.T - testsuite/tests/typecheck/should_fail/T20666.stderr - testsuite/tests/typecheck/should_fail/T20666a.stderr - testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs - + testsuite/tests/typecheck/should_fail/T20666b.stderr - testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs - + testsuite/tests/typecheck/should_fail/T22891.stderr - testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs - + testsuite/tests/typecheck/should_fail/T22912.stderr - testsuite/tests/typecheck/should_fail/T6161.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail223.stderr Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -688,7 +688,7 @@ data WarningFlag = | Opt_WarnGADTMonoLocalBinds -- Since 9.4 | Opt_WarnTypeEqualityOutOfScope -- Since 9.4 | Opt_WarnTypeEqualityRequiresOperators -- Since 9.4 - | Opt_WarnLoopySuperclassSolve -- Since 9.6 + | Opt_WarnLoopySuperclassSolve -- Since 9.6, has no effect since 9.10 | Opt_WarnTermVariableCapture -- Since 9.8 | Opt_WarnMissingRoleAnnotations -- Since 9.8 | Opt_WarnImplicitRhsQuantification -- Since 9.8 @@ -948,7 +948,6 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnForallIdentifier, Opt_WarnUnicodeBidirectionalFormatCharacters, Opt_WarnGADTMonoLocalBinds, - Opt_WarnLoopySuperclassSolve, Opt_WarnBadlyStagedTypes, Opt_WarnTypeEqualityRequiresOperators, Opt_WarnInconsistentFlags, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2198,7 +2198,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of Opt_WarnInconsistentFlags -> warnSpec x Opt_WarnInlineRuleShadowing -> warnSpec x Opt_WarnIdentities -> warnSpec x - Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnLoopySuperclassSolve -> depWarnSpec x "it is now an error" Opt_WarnMissingFields -> warnSpec x Opt_WarnMissingImportList -> warnSpec x Opt_WarnMissingExportList -> warnSpec x ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1349,18 +1349,6 @@ instance Diagnostic TcRnMessage where , text "Combine alternative minimal complete definitions with `|'" ] where sigs = sig1 : sig2 : otherSigs - TcRnLoopySuperclassSolve wtd_loc wtd_pty -> - mkSimpleDecorated $ vcat [ header, warning, user_manual ] - where - header, warning, user_manual :: SDoc - header - = vcat [ text "I am solving the constraint" <+> quotes (ppr wtd_pty) <> comma - , nest 2 $ pprCtOrigin (ctLocOrigin wtd_loc) <> comma - , text "in a way that might turn out to loop at runtime." ] - warning - = vcat [ text "Starting from GHC 9.10, this warning will turn into an error." ] - user_manual = - vcat [ text "See the user manual, § Undecidable instances and loopy superclasses." ] TcRnUnexpectedStandaloneDerivingDecl -> mkSimpleDecorated $ text "Illegal standalone deriving declaration" TcRnUnusedVariableInRuleDecl name var -> mkSimpleDecorated $ @@ -2311,8 +2299,6 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnDuplicateMinimalSig{} -> ErrorWithoutFlag - TcRnLoopySuperclassSolve{} - -> WarningWithFlag Opt_WarnLoopySuperclassSolve TcRnUnexpectedStandaloneDerivingDecl{} -> ErrorWithoutFlag TcRnUnusedVariableInRuleDecl{} @@ -2962,13 +2948,6 @@ instance Diagnostic TcRnMessage where -> [suggestExtension LangExt.DefaultSignatures] TcRnDuplicateMinimalSig{} -> noHints - TcRnLoopySuperclassSolve wtd_loc wtd_pty - -> [LoopySuperclassSolveHint wtd_pty cls_or_qc] - where - cls_or_qc :: ClsInstOrQC - cls_or_qc = case ctLocOrigin wtd_loc of - ScOrigin c_or_q _ -> c_or_q - _ -> IsClsInst -- shouldn't happen TcRnUnexpectedStandaloneDerivingDecl{} -> [suggestExtension LangExt.StandaloneDeriving] TcRnUnusedVariableInRuleDecl{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3134,23 +3134,6 @@ data TcRnMessage where TcRnDeprecatedInvisTyArgInConPat :: TcRnMessage - {-| TcRnLoopySuperclassSolve is a warning, controlled by @-Wloopy-superclass-solve@, - that is triggered when GHC solves a constraint in a possibly-loopy way, - violating the class instance termination rules described in the section - "Undecidable instances and loopy superclasses" of the user's guide. - - Example: - - class Foo f - class Foo f => Bar f g - instance Bar f f => Bar f (h k) - - Test cases: T20666, T20666{a,b}, T22891, T22912. - -} - TcRnLoopySuperclassSolve :: CtLoc -- ^ Wanted 'CtLoc' - -> PredType -- ^ Wanted 'PredType' - -> TcRnMessage - {-| TcRnUnexpectedStandaloneDerivingDecl is an error thrown when a user uses standalone deriving without enabling the StandaloneDeriving extension. ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -98,7 +98,6 @@ solveDict dict_ct@(DictCt { di_ev = ev, di_cls = cls, di_tys = tys }) ; doTopFunDepImprovement dict_ct - ; tryLastResortProhibitedSuperClass dict_ct ; simpleStage (updInertDicts dict_ct) ; stopWithStage (dictCtEvidence dict_ct) "Kept inert DictCt" } @@ -1367,38 +1366,6 @@ with the least superclass depth (see Note [Replacement vs keeping]), but that doesn't work for the example from #22216. -} -{- ******************************************************************* -* * - Last resort prohibited superclass -* * -**********************************************************************-} - -tryLastResortProhibitedSuperClass :: DictCt -> SolverStage () --- ^ As a last resort, we TEMPORARILY allow a prohibited superclass solve, --- emitting a loud warning when doing so: we might be creating non-terminating --- evidence (as we are in T22912 for example). --- --- See Note [Migrating away from loopy superclass solving] in GHC.Tc.TyCl.Instance. -tryLastResortProhibitedSuperClass dict_ct - = Stage $ do { inerts <- getInertCans - ; last_resort inerts dict_ct } - -last_resort :: InertCans -> DictCt -> TcS (StopOrContinue ()) -last_resort inerts (DictCt { di_ev = ev_w, di_cls = cls, di_tys = xis }) - | let loc_w = ctEvLoc ev_w - orig_w = ctLocOrigin loc_w - , ScOrigin _ NakedSc <- orig_w -- work_item is definitely Wanted - , Just ct_i <- lookupInertDict inerts loc_w cls xis - , let ev_i = dictCtEvidence ct_i - , isGiven ev_i - = do { setEvBindIfWanted ev_w True (ctEvTerm ev_i) - ; ctLocWarnTcS loc_w $ - TcRnLoopySuperclassSolve loc_w (ctEvPred ev_w) - ; return $ Stop ev_w (text "Loopy superclass") } - | otherwise - = continueWith () - - {- ********************************************************************* * * * Functional dependencies, instantiation of equations ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1696,20 +1696,6 @@ Answer: superclass selection, except at a smaller type. This test is implemented by GHC.Tc.Solver.InertSet.prohibitedSuperClassSolve -Note [Migrating away from loopy superclass solving] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The logic from Note [Solving superclass constraints] was implemented in GHC 9.6. -However, we want to provide a migration strategy for users, to avoid suddenly -breaking their code going when upgrading to GHC 9.6. To this effect, we temporarily -continue to allow the constraint solver to create these potentially non-terminating -solutions, but emit a loud warning when doing so: see -GHC.Tc.Solver.Dict.tryLastResortProhibitedSuperclass. - -Users can silence the warning by manually adding the necessary constraint to the -context. GHC will then keep this user-written Given, dropping the Given arising -from superclass expansion which has greater SC depth, as explained in -Note [Replacement vs keeping] in GHC.Tc.Solver.Dict. - Note [Silent superclass arguments] (historical interest only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB1: this note describes our *old* solution to the ===================================== compiler/GHC/Tc/Types/Origin.hs-boot ===================================== @@ -16,8 +16,4 @@ data FixedRuntimeRepOrigin mkFRRUnboxedTuple :: Int -> FixedRuntimeRepContext mkFRRUnboxedSum :: Maybe Int -> FixedRuntimeRepContext -data CtOrigin -data ClsInstOrQC = IsClsInst - | IsQC CtOrigin - unkSkol :: HasCallStack => SkolemInfo ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -520,7 +520,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnMisplacedSigDecl" = 87866 GhcDiagnosticCode "TcRnUnexpectedDefaultSig" = 40700 GhcDiagnosticCode "TcRnDuplicateMinimalSig" = 85346 - GhcDiagnosticCode "TcRnLoopySuperclassSolve" = 36038 + GhcDiagnosticCode "TcRnLoopySuperclassSolve" = Outdated 36038 GhcDiagnosticCode "TcRnUnexpectedStandaloneDerivingDecl" = 95159 GhcDiagnosticCode "TcRnUnusedVariableInRuleDecl" = 65669 GhcDiagnosticCode "TcRnUnexpectedStandaloneKindSig" = 45906 ===================================== compiler/GHC/Types/Hint.hs ===================================== @@ -35,13 +35,12 @@ import GHC.Hs.Extension (GhcTc, GhcRn) import GHC.Core.Coercion import GHC.Core.FamInstEnv (FamFlavor) import GHC.Core.TyCon (TyCon) -import GHC.Core.Type (PredType, Type) +import GHC.Core.Type (Type) import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Types.Name (Name, NameSpace, OccName (occNameFS), isSymOcc, nameOccName) import GHC.Types.Name.Reader (RdrName (Unqual), ImpDeclSpec) import GHC.Types.SrcLoc (SrcSpan) import GHC.Types.Basic (Activation, RuleName) -import {-# SOURCE #-} GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Parser.Errors.Basic import GHC.Utils.Outputable import GHC.Data.FastString (fsLit, FastString) @@ -433,8 +432,6 @@ data GhcHint -} | SuggestRenameTypeVariable - | LoopySuperclassSolveHint PredType ClsInstOrQC - | SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn] {-| Suggest enabling one of the SafeHaskell modes Safe, Unsafe or ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -16,7 +16,6 @@ import GHC.Core.FamInstEnv (FamFlavor(..)) import GHC.Core.TyCon import GHC.Core.TyCo.Rep ( mkVisFunTyMany ) import GHC.Hs.Expr () -- instance Outputable -import GHC.Tc.Types.Origin ( ClsInstOrQC(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace) @@ -217,14 +216,6 @@ instance Outputable GhcHint where mod = nameModule name SuggestRenameTypeVariable -> text "Consider renaming the type variable." - LoopySuperclassSolveHint pty cls_or_qc - -> vcat [ text "Add the constraint" <+> quotes (ppr pty) <+> text "to the" <+> what <> comma - , text "even though it seems logically implied by other constraints in the context." ] - where - what :: SDoc - what = case cls_or_qc of - IsClsInst -> text "instance context" - IsQC {} -> text "context of the quantified constraint" SuggestExplicitBidiPatSyn name pat args -> hang (text "Instead use an explicitly bidirectional" <+> text "pattern synonym, e.g.") ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2422,20 +2422,17 @@ of ``-W(no-)*``. extension. .. ghc-flag:: -Wloopy-superclass-solve - :shortdesc: warn when creating potentially-loopy superclass constraint evidence + :shortdesc: *(deprecated)* warn when creating potentially-loopy superclass constraint evidence :type: dynamic :reverse: -Wno-loopy-superclass-solve :since: 9.6.1 - As explained in :ref:`undecidable-instances`, when using - :extension:`UndecidableInstances` it is possible for GHC to construct + This warning is deprecated. It no longer has any effect since GHC 9.10. + In the past, :extension:`UndecidableInstances` allowed potentially non-terminating evidence for certain superclass constraints. - - This behaviour is scheduled to be removed in a future GHC version. - In the meantime, GHC emits this warning to inform users of potential - non-termination. Users can manually add the required constraint to the context - to avoid the problem (thus silencing the warning). + This is no longer allowed, as explained in :ref:`undecidable-instances`. + This warning was used during the transition period. .. ghc-flag:: -Wterm-variable-capture :shortdesc: warn when an implicitly quantified type variable captures a term's name ===================================== testsuite/tests/typecheck/should_compile/T20666b.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22891.stderr deleted ===================================== @@ -1,10 +0,0 @@ - -T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Foo f’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Foo f’ to the instance context, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/T22912.stderr deleted ===================================== @@ -1,12 +0,0 @@ - -T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Implies c’, - arising from the head of a quantified constraint - arising from a use of ‘go’, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Implies - c’ to the context of the quantified constraint, - even though it seems logically implied by other constraints in the context. ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -866,9 +866,6 @@ test('T22647', normal, compile, ['']) test('T19577', normal, compile, ['']) test('T22383', normal, compile, ['']) test('T21501', normal, compile, ['']) -test('T20666b', normal, compile, ['']) -test('T22891', normal, compile, ['']) -test('T22912', normal, compile, ['']) test('T22924', normal, compile, ['']) test('T22985a', normal, compile, ['-O']) test('T22985b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T20666.stderr ===================================== @@ -1,20 +1,20 @@ -T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:13:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d) + bound by the instance declaration at T20666.hs:13:10-31 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C1 c’ -T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Show (T c)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Show (T c)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666.hs:17:10: error: [GHC-39999] + • Could not deduce ‘Show (T c)’ + arising from the superclasses of an instance declaration + from the context: (D d, c ~ S d, c' ~ c) + bound by the instance declaration at T20666.hs:17:10-40 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C2 c'’ ===================================== testsuite/tests/typecheck/should_fail/T20666a.stderr ===================================== @@ -1,10 +1,10 @@ -T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Eq (F [a])’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Eq (F [a])’ to the instance context, - even though it seems logically implied by other constraints in the context. +T20666a.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666a.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T20666b.hs → testsuite/tests/typecheck/should_fail/T20666b.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T20666b.stderr ===================================== @@ -0,0 +1,10 @@ + +T20666b.hs:11:10: error: [GHC-39999] + • Could not deduce ‘Eq (F [a])’ + arising from the superclasses of an instance declaration + from the context: D [a] + bound by the instance declaration at T20666b.hs:11:10-23 + Possible fix: + If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the instance declaration for ‘C [a]’ ===================================== testsuite/tests/typecheck/should_compile/T22891.hs → testsuite/tests/typecheck/should_fail/T22891.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22891.stderr ===================================== @@ -0,0 +1,9 @@ + +T22891.hs:9:10: error: [GHC-39999] + • Could not deduce ‘Foo f’ + arising from the superclasses of an instance declaration + from the context: Bar f f + bound by the instance declaration at T22891.hs:9:10-31 + Possible fix: + add (Foo f) to the context of the instance declaration + • In the instance declaration for ‘Bar f (h k3)’ ===================================== testsuite/tests/typecheck/should_compile/T22912.hs → testsuite/tests/typecheck/should_fail/T22912.hs ===================================== ===================================== testsuite/tests/typecheck/should_fail/T22912.stderr ===================================== @@ -0,0 +1,20 @@ + +T22912.hs:17:16: error: [GHC-39999] + • Could not deduce ‘Implies c’ + arising from the head of a quantified constraint + arising from a use of ‘go’ + from the context: Exactly (Implies c) + bound by a quantified context at T22912.hs:17:16-17 + Possible fix: + add (Implies c) to the context of + the type signature for: + anythingDict :: forall (c :: Constraint). Dict c + or If the constraint looks soluble from a superclass of the instance context, + read 'Undecidable instances and loopy superclasses' in the user manual + • In the expression: go + In an equation for ‘anythingDict’: + anythingDict + = go + where + go :: (Exactly (Implies c) => Implies c) => Dict c + go = Dict ===================================== testsuite/tests/typecheck/should_fail/T6161.stderr ===================================== @@ -1,10 +1,7 @@ -T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Super (Fam a)’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Super (Fam a)’ to the instance context, - even though it seems logically implied by other constraints in the context. +T6161.hs:19:10: error: [GHC-39999] + • Could not deduce ‘Super (Fam a)’ + arising from the superclasses of an instance declaration + from the context: Foo a + bound by the instance declaration at T6161.hs:19:10-31 + • In the instance declaration for ‘Duper (Fam a)’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -241,7 +241,7 @@ test('tcfail215', normal, compile_fail, ['']) test('tcfail216', normal, compile_fail, ['']) test('tcfail217', normal, compile_fail, ['']) test('tcfail218', normal, compile_fail, ['']) -test('tcfail223', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('tcfail223', normal, compile_fail, ['']) test('tcfail224', normal, compile_fail, ['']) test('tcfail225', normal, compile_fail, ['']) @@ -293,7 +293,7 @@ test('T19187a', normal, compile_fail, ['']) test('T2534', normal, compile_fail, ['']) test('T7175', normal, compile_fail, ['']) test('T7210', normal, compile_fail, ['']) -test('T6161', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T6161', normal, compile_fail, ['']) test('T7368', normal, compile_fail, ['']) test('T7264', normal, compile_fail, ['']) test('T6069', normal, compile_fail, ['']) @@ -668,8 +668,11 @@ test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) test('T22570', normal, compile_fail, ['']) test('T22645', normal, compile_fail, ['']) -test('T20666', normal, compile, ['']) # To become compile_fail after migration period (see #22912) -test('T20666a', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T20666', normal, compile_fail, ['']) +test('T20666a', normal, compile_fail, ['']) +test('T20666b', normal, compile_fail, ['']) +test('T22891', normal, compile_fail, ['']) +test('T22912', normal, compile_fail, ['']) test('T22924a', normal, compile_fail, ['']) test('T22924b', normal, compile_fail, ['']) test('T22940', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/tcfail223.stderr ===================================== @@ -1,10 +1,9 @@ -tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] - I am solving the constraint ‘Class1 a’, - arising from the superclasses of an instance declaration, - in a way that might turn out to loop at runtime. - Starting from GHC 9.10, this warning will turn into an error. - See the user manual, § Undecidable instances and loopy superclasses. - Suggested fix: - Add the constraint ‘Class1 a’ to the instance context, - even though it seems logically implied by other constraints in the context. +tcfail223.hs:10:10: error: [GHC-39999] + • Could not deduce ‘Class1 a’ + arising from the superclasses of an instance declaration + from the context: Class3 a + bound by the instance declaration at tcfail223.hs:10:10-29 + Possible fix: + add (Class1 a) to the context of the instance declaration + • In the instance declaration for ‘Class2 a’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99ced73bf5b2f5f82a2e09accbf01eceaa3ce0ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99ced73bf5b2f5f82a2e09accbf01eceaa3ce0ca You're receiving 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 Nov 15 18:23:47 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:23:47 -0500 Subject: [Git][ghc/ghc][master] EPA: splitLHsForAllTyInvis does not return ann Message-ID: <65550cb344318_1b47145000d6245135ce@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - 1 changed file: - compiler/GHC/Hs/Type.hs Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -701,10 +701,10 @@ splitLHsPatSynTy ty = (univs, reqs, exis, provs, ty4) HsOuterImplicit{} -> ([], ignoreParens body) HsOuterExplicit{hso_bndrs = exp_bndrs} -> (exp_bndrs, body) - (univs, ty1) = split_sig_ty ty - (reqs, ty2) = splitLHsQualTy ty1 - ((_an, exis), ty3) = splitLHsForAllTyInvis ty2 - (provs, ty4) = splitLHsQualTy ty3 + (univs, ty1) = split_sig_ty ty + (reqs, ty2) = splitLHsQualTy ty1 + (exis, ty3) = splitLHsForAllTyInvis ty2 + (provs, ty4) = splitLHsQualTy ty3 -- | Decompose a sigma type (of the form @forall . context => body@) -- into its constituent parts. @@ -724,8 +724,8 @@ splitLHsSigmaTyInvis :: LHsType (GhcPass p) -> ([LHsTyVarBndr Specificity (GhcPass p)] , Maybe (LHsContext (GhcPass p)), LHsType (GhcPass p)) splitLHsSigmaTyInvis ty - | ((_an,tvs), ty1) <- splitLHsForAllTyInvis ty - , (ctxt, ty2) <- splitLHsQualTy ty1 + | (tvs, ty1) <- splitLHsForAllTyInvis ty + , (ctxt, ty2) <- splitLHsQualTy ty1 = (tvs, ctxt, ty2) -- | Decompose a GADT type into its constituent parts. @@ -770,11 +770,11 @@ splitLHsGadtTy (L _ sig_ty) -- Unlike 'splitLHsSigmaTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis :: - LHsType (GhcPass pass) -> ( (EpAnnForallTy, [LHsTyVarBndr Specificity (GhcPass pass)]) + LHsType (GhcPass pass) -> ( [LHsTyVarBndr Specificity (GhcPass pass)] , LHsType (GhcPass pass)) splitLHsForAllTyInvis ty | ((mb_tvbs), body) <- splitLHsForAllTyInvis_KP (ignoreParens ty) - = (fromMaybe (EpAnnNotUsed,[]) mb_tvbs, body) + = (fromMaybe [] mb_tvbs, body) -- | Decompose a type of the form @forall . body@ into its constituent -- parts. Only splits type variable binders that @@ -788,14 +788,13 @@ splitLHsForAllTyInvis ty -- Unlike 'splitLHsForAllTyInvis', this function does not look through -- parentheses, hence the suffix @_KP@ (short for \"Keep Parentheses\"). splitLHsForAllTyInvis_KP :: - LHsType (GhcPass pass) -> (Maybe (EpAnnForallTy, [LHsTyVarBndr Specificity (GhcPass pass)]) + LHsType (GhcPass pass) -> (Maybe ([LHsTyVarBndr Specificity (GhcPass pass)]) , LHsType (GhcPass pass)) splitLHsForAllTyInvis_KP lty@(L _ ty) = case ty of - HsForAllTy { hst_tele = HsForAllInvis { hsf_xinvis = an - , hsf_invis_bndrs = tvs } + HsForAllTy { hst_tele = HsForAllInvis {hsf_invis_bndrs = tvs } , hst_body = body } - -> (Just (an, tvs), body) + -> (Just tvs, body) _ -> (Nothing, lty) -- | Decompose a type of the form @context => body@ into its constituent parts. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27981facd9907089ee3c8ff39d30b8921dff89fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/27981facd9907089ee3c8ff39d30b8921dff89fd You're receiving 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 Nov 15 18:23:37 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:23:37 -0500 Subject: [Git][ghc/ghc][master] users-guide: Fix links to libraries from the users-guide. Message-ID: <65550ca972c93_1b47144fe7a384513314@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 1 changed file: - docs/users_guide/conf.py Changes: ===================================== docs/users_guide/conf.py ===================================== @@ -225,7 +225,7 @@ def haddock_role(lib): # for the template_haskell.rst example this will be '..' current_doc_to_topdir = os.path.relpath(topdir, os.path.dirname(current_doc)) - relative_path = '%s/%s/%s-%s' % (current_doc_to_topdir, libs_base_uri, lib, lib_version) + relative_path = '%s/%s/%s' % (current_doc_to_topdir, libs_base_uri, lib_version) uri = '%s/%s.html%s' % (relative_path, module, anchor) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2aff23616d8eaa7fa1a0c83bf0a50fb2b96193b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2aff23616d8eaa7fa1a0c83bf0a50fb2b96193b6 You're receiving 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 Nov 15 18:52:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 13:52:24 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: Suppress duplicate librares linker warning of new macOS linker Message-ID: <65551368bcda4_1b47145022e05c535143@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - 38293284 by Krzysztof Gogolewski at 2023-11-15T13:52:19-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - a6b446e8 by Simon Peyton Jones at 2023-11-15T13:52:20-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/conf.py - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/src/Rules/Generate.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9fdfbd801a97481a74dc5951d395d2599806c9e2...a6b446e81d42bc83689d25d512221679f7aa6d3a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9fdfbd801a97481a74dc5951d395d2599806c9e2...a6b446e81d42bc83689d25d512221679f7aa6d3a You're receiving 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 Nov 15 19:12:43 2023 From: gitlab at gitlab.haskell.org (Bodigrim (@Bodigrim)) Date: Wed, 15 Nov 2023 14:12:43 -0500 Subject: [Git][ghc/ghc] Pushed new tag wip/trac-kindaro/feature-base-nonempty-permutations Message-ID: <6555182b21385_1b4714519ac1ac5475da@gitlab.mail> Bodigrim pushed new tag wip/trac-kindaro/feature-base-nonempty-permutations at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/trac-kindaro/feature-base-nonempty-permutations You're receiving 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 Nov 15 21:21:43 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 15 Nov 2023 16:21:43 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <655536676e6dc_1b4714557245e8552471@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 715c0f44 by Matthew Pickering at 2023-11-15T21:21:33+00:00 testsuite: Add mechanism to collect generic metrics TODO - - - - - 5 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -396,6 +396,9 @@ class TestOptions: # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Does this test define a generic stats test? + self.generic_stats_test = None + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -99,6 +99,11 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + print(opts.generic_stats_test) + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +604,43 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'static/size', deviation, lambda: os.path.getsize(path) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_stat(name : TestName, opts, get_stat): + + opts.generic_stats_test = get_stat + + for (metric, info) in get_stat.items(): + + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + + opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, + deviation=info['deviation']) + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -1733,6 +1775,54 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) + + +def check_generic_stats(name, way, get_stats, range_fields): + + for (metric, baseline_and_dev) in range_fields.items(): + if metric in get_stats: + actual_val = get_stats[metric]['action']() + basline_and_dev = range_fields[metric] + return report_stats(name, way, metric, basline_and_dev, actual_val) + +def report_stats(name, way, metric, baseline_and_dev, actual_val): + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None + if head_commit is None: + return passed() + + result = passed() + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = baseline_and_dev.baseline(way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + tolerance_dev = baseline_and_dev.deviation + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + tolerance_dev, + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result + return result + # ----------------------------------------------------------------------------- # Check test stats. This prints the results for the user. # name: name of the test. @@ -1746,9 +1836,6 @@ def check_stats(name: TestName, stats_file: Path, range_fields: Dict[MetricName, MetricOracles] ) -> PassFail: - head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None - if head_commit is None: - return passed() result = passed() if range_fields: @@ -1771,36 +1858,8 @@ def check_stats(name: TestName, assert val is not None actual_val = int(val) - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) + result = report_stats(name, way, metric, baseline_and_dev, actual_val) - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result return result @@ -1918,6 +1977,11 @@ async def simple_build(name: Union[TestName, str], if badResult(statsResult): return statsResult + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + return passed() # ----------------------------------------------------------------------------- @@ -2002,8 +2066,14 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # Check runtime stats if desired. if stats_file is not None: return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + + # Check other generic stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('static/size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/715c0f44b829f94618e59394622755e1ac1f610f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/715c0f44b829f94618e59394622755e1ac1f610f You're receiving 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 Nov 15 23:13:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 18:13:00 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Document defaulting of RuntimeReps Message-ID: <6555507c5ac4f_1b47145839a668566052@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 13627867 by Krzysztof Gogolewski at 2023-11-15T18:12:52-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - c2325536 by Simon Peyton Jones at 2023-11-15T18:12:53-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 9 changed files: - compiler/GHC/Tc/Gen/HsType.hs - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst - + testsuite/tests/polykinds/T24083a.hs - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2569,23 +2569,19 @@ kcCheckDeclHeader_sig sig_kind name flav -- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'. -- -- Also see Note [Arity of type families and type synonyms] - ; ctx_k <- kc_res_ki + ; res_kind :: ContextKind <- kc_res_ki ; let sig_res_kind' = mkTyConKind excess_sig_tcbs sig_res_kind ; traceTc "kcCheckDeclHeader_sig 2" $ vcat [ text "excess_sig_tcbs" <+> ppr excess_sig_tcbs - , text "ctx_k" <+> ppr ctx_k + , text "res_kind" <+> ppr res_kind , text "sig_res_kind'" <+> ppr sig_res_kind' ] - -- Unify res_ki (from the type declaration) with the residual kind from - -- the kind signature. Don't forget to apply the skolemising 'subst' first. - ; case ctx_k of - AnyKind -> return () -- No signature - _ -> do - res_ki <- newExpectedKind ctx_k - check_exp_res_ki sig_res_kind' res_ki + -- Unify res_ki (from the type declaration) with + -- sig_res_kind', the residual kind from the kind signature. + ; checkExpectedResKind sig_res_kind' res_kind -- Add more binders for data/newtype, so the result kind has no arrows -- See Note [Datatype return kinds] @@ -2608,7 +2604,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2650,18 +2646,23 @@ kcCheckDeclHeader_sig sig_kind name flav -- | Check the result kind annotation on a type constructor against -- the corresponding section of the standalone kind signature. -- Drops invisible binders that interfere with unification. -check_exp_res_ki :: TcKind -- ^ the actual kind - -> TcKind -- ^ the expected kind - -> TcM () -check_exp_res_ki act_kind exp_kind - = discardResult $ unifyKind Nothing act_kind' exp_kind - where - (_, act_kind') = splitInvisPiTysN n_to_inst act_kind +checkExpectedResKind :: TcKind -- ^ the result kind from the separate kind signature + -> ContextKind -- ^ the result kind from the declaration header + -> TcM () +checkExpectedResKind _ AnyKind + = return () -- No signature in the declaration header +checkExpectedResKind sig_kind res_ki + = do { actual_res_ki <- newExpectedKind res_ki - -- by analogy with checkExpectedKind - n_exp_invis_bndrs = invisibleTyBndrCount exp_kind - n_act_invis_bndrs = invisibleTyBndrCount act_kind - n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + ; let -- Drop invisible binders from sig_kind until they match up + -- with res_ki. By analogy with checkExpectedKind. + n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki + n_sig_invis_bndrs = invisibleTyBndrCount sig_kind + n_to_inst = n_sig_invis_bndrs - n_res_invis_bndrs + + (_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind + + ; discardResult $ unifyKind Nothing sig_kind' actual_res_ki } matchUpSigWithDecl :: Name -- Name of the type constructor for error messages @@ -2964,13 +2965,16 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] + -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars sig_tcbs scoped_prs - = mapM_ report_disconnected (filterOut ok scoped_prs) +checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs + = when (needsEtaExpansion flav) $ + -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] + mapM_ report_disconnected (filterOut ok scoped_prs) where sig_tvs = mkVarSet (binderVars sig_tcbs) ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs @@ -3047,6 +3051,25 @@ phantom synonym that just discards its argument. So our plan is this: See #24083 for dicussion of alternatives, none satisfactory. Also the fix is easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` explicitly, rather than binding it implicitly via unification. + +(DTV1) We only want to make this check when there /are/ scoped type variables; and + that is determined by needsEtaExpansion. Examples: + + type C :: x -> y -> Constraint + class C a :: b -> Constraint where { ... } + -- The a,b scope over the "..." + + type D :: forall k. k -> Type + data family D :: kk -> Type + -- Nothing for `kk` to scope over! + + In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will + return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty. So if we do + the check-for-disconnected-tyvars check we'll complain that `kk` is not bound + to one of `all_tcbs` (see #24083, comments about the `singletons` package). + + The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, + where needsEtaExpansion is True. -} {- ********************************************************************* ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -1383,6 +1383,7 @@ The plugin has type ``WantedConstraints -> [DefaultingProposal]``. * It is given the currently unsolved constraints. * It returns a list of independent "defaulting proposals". * Each proposal of type ``DefaultingProposal`` specifies: + * ``deProposals``: specifies a list, in priority order, of sets of type variable assignments * ``deProposalCts :: [Ct]`` gives a set of constraints (always a ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -100,13 +100,13 @@ The following kinds and promoted data constructors can be used even when :extension:`DataKinds` is not enabled: - ``Type`` -- ``TYPE`` (see :ref:`_runtime-rep`) +- ``TYPE`` (see :ref:`runtime-rep`) - ``Constraint`` (see :ref:`constraint-kind`) - ``CONSTRAINT`` - ``Multiplicity`` and its promoted data constructors (see :extension:`LinearTypes`) -- ``LiftedRep`` (see :ref:`_runtime-rep`) -- ``RuntimeRep`` and its promoted data constructors (see :ref:`_runtime-rep`) -- ``Levity`` and its promoted data constructors (see :ref:`_runtime-rep`) +- ``LiftedRep`` (see :ref:`runtime-rep`) +- ``RuntimeRep`` and its promoted data constructors (see :ref:`runtime-rep`) +- ``Levity`` and its promoted data constructors (see :ref:`runtime-rep`) - ``VecCount`` and its promoted data constructors - ``VecElem`` and its promoted data constructors @@ -231,7 +231,7 @@ See also :ghc-ticket:`7347`. :extension:`DataKinds` and type synonyms ---------------------------------------- -The :extensions:`DataKinds` extension interacts with type synonyms in the +The :extension:`DataKinds` extension interacts with type synonyms in the following ways: 1. In a *type* context: :extension:`DataKinds` is not required to use a type ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -1,3 +1,5 @@ +.. _linear-types: + Linear types ============ @@ -58,7 +60,8 @@ partially. See, however :ref:`linear-types-limitations`. Linear and multiplicity-polymorphic arrows are *always declared*, never inferred. That is, if you don't give an appropriate type signature to a function, it will be inferred as being a regular -function of type ``a -> b``. +function of type ``a -> b``. The same principle holds for +representation polymorphism (see :ref:`representation-polymorphism-defaulting`). Data types ---------- ===================================== docs/users_guide/exts/primitives.rst ===================================== @@ -438,7 +438,7 @@ You may even declare levity-polymorphic data types: :: While ``f`` above could reasonably be levity-polymorphic (as it evaluates its argument either way), GHC currently disallows the more general type ``PEither @l Int Bool -> Bool``. This is a consequence of the -`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__, +`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__. Pattern matching against an unlifted data type work just like that for lifted types; but see :ref:`recursive-and-polymorphic-let-bindings` for the semantics of ===================================== docs/users_guide/exts/representation_polymorphism.rst ===================================== @@ -108,6 +108,35 @@ These functions do not bind a representation-polymorphic variable, and so are accepted. Their polymorphism allows users to use these to conveniently stub out functions that return unboxed types. +.. _representation-polymorphism-defaulting: + +Inference and defaulting +------------------------ + +GHC does not infer representation-polymorphic types. +If the representation of a variable is not specified, it will be assumed +to be ``LiftedRep``. +For example, if you write ``f a b = a b``, the inferred type of ``f`` +will be :: + + f :: forall {a :: Type} {b :: Type}. (a -> b) -> a -> b + +even though :: + + f :: forall {rep} {a :: Type} {b :: TYPE rep}. (a -> b) -> a -> b + +would also be legal, as described above. + +Likewise, in a user-written signature ``f :: forall a b. (a -> b) -> a -> b`` +GHC will assume that both ``a`` and ``b`` have kind ``Type``. To use +a different representation, you have to specify the kinds of ``a`` and ``b``. + +During type inference, GHC does not quantify over variables of kind +``RuntimeRep`` nor ``Levity``. +Instead, they are defaulted to ``LiftedRep`` and ``Lifted`` respectively. +Likewise, ``Multiplicity`` variables (:ref:`linear-types`) are defaulted +to ``Many``. + .. _printing-representation-polymorphic-types: Printing representation-polymorphic types ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2574,7 +2574,7 @@ of ``-W(no-)*``. Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind (without having enabled the :extension:`DataKinds` extension) is caught in the typechecker (hence the ``-tc`` suffix). These warnings complement the - existing :extensions:`DataKinds` checks (that have existed since + existing :extension:`DataKinds` checks (that have existed since :extension:`DataKinds` was first introduced), which result in errors instead of warnings. ===================================== testsuite/tests/polykinds/T24083a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ScopedTypeVariables, RankNTypes #-} + +module T24083a where + +type TyCon :: (k1 -> k2) -> unmatchable_fun +data family TyCon :: (k1 -> k2) -> unmatchable_fun ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -244,3 +244,4 @@ test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) test('T24083', normal, compile_fail, ['']) +test('T24083a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6b446e81d42bc83689d25d512221679f7aa6d3a...c2325536a245eece7c96fc615a20523127c12047 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6b446e81d42bc83689d25d512221679f7aa6d3a...c2325536a245eece7c96fc615a20523127c12047 You're receiving 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 Nov 16 00:29:46 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 15 Nov 2023 19:29:46 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24197 Message-ID: <6555627a9759c_1b47145a0e8f945780bf@gitlab.mail> Ben Gamari pushed new branch wip/T24197 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24197 You're receiving 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 Nov 16 03:23:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 22:23:30 -0500 Subject: [Git][ghc/ghc][master] Document defaulting of RuntimeReps Message-ID: <65558b324f9c_1b47145dea3bb85913f7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 6 changed files: - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -1383,6 +1383,7 @@ The plugin has type ``WantedConstraints -> [DefaultingProposal]``. * It is given the currently unsolved constraints. * It returns a list of independent "defaulting proposals". * Each proposal of type ``DefaultingProposal`` specifies: + * ``deProposals``: specifies a list, in priority order, of sets of type variable assignments * ``deProposalCts :: [Ct]`` gives a set of constraints (always a ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -100,13 +100,13 @@ The following kinds and promoted data constructors can be used even when :extension:`DataKinds` is not enabled: - ``Type`` -- ``TYPE`` (see :ref:`_runtime-rep`) +- ``TYPE`` (see :ref:`runtime-rep`) - ``Constraint`` (see :ref:`constraint-kind`) - ``CONSTRAINT`` - ``Multiplicity`` and its promoted data constructors (see :extension:`LinearTypes`) -- ``LiftedRep`` (see :ref:`_runtime-rep`) -- ``RuntimeRep`` and its promoted data constructors (see :ref:`_runtime-rep`) -- ``Levity`` and its promoted data constructors (see :ref:`_runtime-rep`) +- ``LiftedRep`` (see :ref:`runtime-rep`) +- ``RuntimeRep`` and its promoted data constructors (see :ref:`runtime-rep`) +- ``Levity`` and its promoted data constructors (see :ref:`runtime-rep`) - ``VecCount`` and its promoted data constructors - ``VecElem`` and its promoted data constructors @@ -231,7 +231,7 @@ See also :ghc-ticket:`7347`. :extension:`DataKinds` and type synonyms ---------------------------------------- -The :extensions:`DataKinds` extension interacts with type synonyms in the +The :extension:`DataKinds` extension interacts with type synonyms in the following ways: 1. In a *type* context: :extension:`DataKinds` is not required to use a type ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -1,3 +1,5 @@ +.. _linear-types: + Linear types ============ @@ -58,7 +60,8 @@ partially. See, however :ref:`linear-types-limitations`. Linear and multiplicity-polymorphic arrows are *always declared*, never inferred. That is, if you don't give an appropriate type signature to a function, it will be inferred as being a regular -function of type ``a -> b``. +function of type ``a -> b``. The same principle holds for +representation polymorphism (see :ref:`representation-polymorphism-defaulting`). Data types ---------- ===================================== docs/users_guide/exts/primitives.rst ===================================== @@ -438,7 +438,7 @@ You may even declare levity-polymorphic data types: :: While ``f`` above could reasonably be levity-polymorphic (as it evaluates its argument either way), GHC currently disallows the more general type ``PEither @l Int Bool -> Bool``. This is a consequence of the -`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__, +`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__. Pattern matching against an unlifted data type work just like that for lifted types; but see :ref:`recursive-and-polymorphic-let-bindings` for the semantics of ===================================== docs/users_guide/exts/representation_polymorphism.rst ===================================== @@ -108,6 +108,35 @@ These functions do not bind a representation-polymorphic variable, and so are accepted. Their polymorphism allows users to use these to conveniently stub out functions that return unboxed types. +.. _representation-polymorphism-defaulting: + +Inference and defaulting +------------------------ + +GHC does not infer representation-polymorphic types. +If the representation of a variable is not specified, it will be assumed +to be ``LiftedRep``. +For example, if you write ``f a b = a b``, the inferred type of ``f`` +will be :: + + f :: forall {a :: Type} {b :: Type}. (a -> b) -> a -> b + +even though :: + + f :: forall {rep} {a :: Type} {b :: TYPE rep}. (a -> b) -> a -> b + +would also be legal, as described above. + +Likewise, in a user-written signature ``f :: forall a b. (a -> b) -> a -> b`` +GHC will assume that both ``a`` and ``b`` have kind ``Type``. To use +a different representation, you have to specify the kinds of ``a`` and ``b``. + +During type inference, GHC does not quantify over variables of kind +``RuntimeRep`` nor ``Levity``. +Instead, they are defaulted to ``LiftedRep`` and ``Lifted`` respectively. +Likewise, ``Multiplicity`` variables (:ref:`linear-types`) are defaulted +to ``Many``. + .. _printing-representation-polymorphic-types: Printing representation-polymorphic types ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2574,7 +2574,7 @@ of ``-W(no-)*``. Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind (without having enabled the :extension:`DataKinds` extension) is caught in the typechecker (hence the ``-tc`` suffix). These warnings complement the - existing :extensions:`DataKinds` checks (that have existed since + existing :extension:`DataKinds` checks (that have existed since :extension:`DataKinds` was first introduced), which result in errors instead of warnings. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a64678343d7f977bc87fe6d97c6a89a8c20e1fb8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a64678343d7f977bc87fe6d97c6a89a8c20e1fb8 You're receiving 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 Nov 16 03:23:59 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 15 Nov 2023 22:23:59 -0500 Subject: [Git][ghc/ghc][master] Second fix to #24083 Message-ID: <65558b4ef1910_1b47145dea3bb8594683@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 3 changed files: - compiler/GHC/Tc/Gen/HsType.hs - + testsuite/tests/polykinds/T24083a.hs - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2569,23 +2569,19 @@ kcCheckDeclHeader_sig sig_kind name flav -- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'. -- -- Also see Note [Arity of type families and type synonyms] - ; ctx_k <- kc_res_ki + ; res_kind :: ContextKind <- kc_res_ki ; let sig_res_kind' = mkTyConKind excess_sig_tcbs sig_res_kind ; traceTc "kcCheckDeclHeader_sig 2" $ vcat [ text "excess_sig_tcbs" <+> ppr excess_sig_tcbs - , text "ctx_k" <+> ppr ctx_k + , text "res_kind" <+> ppr res_kind , text "sig_res_kind'" <+> ppr sig_res_kind' ] - -- Unify res_ki (from the type declaration) with the residual kind from - -- the kind signature. Don't forget to apply the skolemising 'subst' first. - ; case ctx_k of - AnyKind -> return () -- No signature - _ -> do - res_ki <- newExpectedKind ctx_k - check_exp_res_ki sig_res_kind' res_ki + -- Unify res_ki (from the type declaration) with + -- sig_res_kind', the residual kind from the kind signature. + ; checkExpectedResKind sig_res_kind' res_kind -- Add more binders for data/newtype, so the result kind has no arrows -- See Note [Datatype return kinds] @@ -2608,7 +2604,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2650,18 +2646,23 @@ kcCheckDeclHeader_sig sig_kind name flav -- | Check the result kind annotation on a type constructor against -- the corresponding section of the standalone kind signature. -- Drops invisible binders that interfere with unification. -check_exp_res_ki :: TcKind -- ^ the actual kind - -> TcKind -- ^ the expected kind - -> TcM () -check_exp_res_ki act_kind exp_kind - = discardResult $ unifyKind Nothing act_kind' exp_kind - where - (_, act_kind') = splitInvisPiTysN n_to_inst act_kind +checkExpectedResKind :: TcKind -- ^ the result kind from the separate kind signature + -> ContextKind -- ^ the result kind from the declaration header + -> TcM () +checkExpectedResKind _ AnyKind + = return () -- No signature in the declaration header +checkExpectedResKind sig_kind res_ki + = do { actual_res_ki <- newExpectedKind res_ki - -- by analogy with checkExpectedKind - n_exp_invis_bndrs = invisibleTyBndrCount exp_kind - n_act_invis_bndrs = invisibleTyBndrCount act_kind - n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + ; let -- Drop invisible binders from sig_kind until they match up + -- with res_ki. By analogy with checkExpectedKind. + n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki + n_sig_invis_bndrs = invisibleTyBndrCount sig_kind + n_to_inst = n_sig_invis_bndrs - n_res_invis_bndrs + + (_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind + + ; discardResult $ unifyKind Nothing sig_kind' actual_res_ki } matchUpSigWithDecl :: Name -- Name of the type constructor for error messages @@ -2964,13 +2965,16 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] + -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars sig_tcbs scoped_prs - = mapM_ report_disconnected (filterOut ok scoped_prs) +checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs + = when (needsEtaExpansion flav) $ + -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] + mapM_ report_disconnected (filterOut ok scoped_prs) where sig_tvs = mkVarSet (binderVars sig_tcbs) ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs @@ -3047,6 +3051,25 @@ phantom synonym that just discards its argument. So our plan is this: See #24083 for dicussion of alternatives, none satisfactory. Also the fix is easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` explicitly, rather than binding it implicitly via unification. + +(DTV1) We only want to make this check when there /are/ scoped type variables; and + that is determined by needsEtaExpansion. Examples: + + type C :: x -> y -> Constraint + class C a :: b -> Constraint where { ... } + -- The a,b scope over the "..." + + type D :: forall k. k -> Type + data family D :: kk -> Type + -- Nothing for `kk` to scope over! + + In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will + return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty. So if we do + the check-for-disconnected-tyvars check we'll complain that `kk` is not bound + to one of `all_tcbs` (see #24083, comments about the `singletons` package). + + The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, + where needsEtaExpansion is True. -} {- ********************************************************************* ===================================== testsuite/tests/polykinds/T24083a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ScopedTypeVariables, RankNTypes #-} + +module T24083a where + +type TyCon :: (k1 -> k2) -> unmatchable_fun +data family TyCon :: (k1 -> k2) -> unmatchable_fun ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -244,3 +244,4 @@ test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) test('T24083', normal, compile_fail, ['']) +test('T24083a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2776920e642544477a38d0ed9205d4f0b48a782e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2776920e642544477a38d0ed9205d4f0b48a782e You're receiving 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 Nov 16 05:14:22 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 16 Nov 2023 00:14:22 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 15 commits: EPA: get rid of AnchorOperation Message-ID: <6555a52e8c1a3_1b4714616058cc60164@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - 77bec677 by Apoorv Ingle at 2023-11-15T22:13:02-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 7ddc341f by Apoorv Ingle at 2023-11-15T22:13:03-06:00 - Kill mc_what in HsMatchCtxt and rename `HsMatchCtxt` to `TcMatchAltChecker` - - - - - 3f8c624a by Apoorv Ingle at 2023-11-15T23:14:06-06:00 1. Make records Expand and not desugar before typechecking. 2. Push HsDo expansion inside tcDoStmts rather than tcExpr - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f084eb5b0cbdcd4c10753b9996f91b76bf81435...3f8c624af41bdf8b78157049442a3948378a6a14 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f084eb5b0cbdcd4c10753b9996f91b76bf81435...3f8c624af41bdf8b78157049442a3948378a6a14 You're receiving 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 Nov 16 09:15:36 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 04:15:36 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <6555ddb8e56bb_1b4714670a2cf86160d9@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 4d40f8f1 by Matthew Pickering at 2023-11-16T09:15:27+00:00 testsuite: Add mechanism to collect generic metrics TODO - - - - - 5 changed files: - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/testglobals.py ===================================== @@ -396,6 +396,9 @@ class TestOptions: # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Does this test define a generic stats test? + self.generic_stats_test = None + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -99,6 +99,11 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + print(opts.generic_stats_test) + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +604,43 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'static/size', deviation, lambda: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_stat(name : TestName, opts, get_stat): + + opts.generic_stats_test = get_stat + + for (metric, info) in get_stat.items(): + + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + + opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, + deviation=info['deviation']) + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -1733,6 +1775,54 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) + + +def check_generic_stats(name, way, get_stats, range_fields): + + for (metric, baseline_and_dev) in range_fields.items(): + if metric in get_stats: + actual_val = get_stats[metric]['action']() + basline_and_dev = range_fields[metric] + return report_stats(name, way, metric, basline_and_dev, actual_val) + +def report_stats(name, way, metric, baseline_and_dev, actual_val): + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None + if head_commit is None: + return passed() + + result = passed() + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = baseline_and_dev.baseline(way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + tolerance_dev = baseline_and_dev.deviation + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + tolerance_dev, + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result + return result + # ----------------------------------------------------------------------------- # Check test stats. This prints the results for the user. # name: name of the test. @@ -1746,9 +1836,6 @@ def check_stats(name: TestName, stats_file: Path, range_fields: Dict[MetricName, MetricOracles] ) -> PassFail: - head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None - if head_commit is None: - return passed() result = passed() if range_fields: @@ -1771,36 +1858,8 @@ def check_stats(name: TestName, assert val is not None actual_val = int(val) - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) + result = report_stats(name, way, metric, baseline_and_dev, actual_val) - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result return result @@ -1918,6 +1977,11 @@ async def simple_build(name: Union[TestName, str], if badResult(statsResult): return statsResult + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + return passed() # ----------------------------------------------------------------------------- @@ -2002,8 +2066,14 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # Check runtime stats if desired. if stats_file is not None: return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + + # Check other generic stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test, opts.stats_range_fields) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('static/size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d40f8f1eb903e55b106f33e7482f1985f524627 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d40f8f1eb903e55b106f33e7482f1985f524627 You're receiving 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 Nov 16 12:09:53 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 16 Nov 2023 07:09:53 -0500 Subject: [Git][ghc/ghc][wip/andreask/unpack_unboxed_tuples] 39 commits: Add NCG support for common 64bit operations to the x86 backend. Message-ID: <6556069150098_d535c121423c489b2@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/unpack_unboxed_tuples at Glasgow Haskell Compiler / GHC Commits: 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 8badd5ed by Andreas Klebinger at 2023-11-16T12:57:37+01:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/JS/JStg/Monad.hs - compiler/GHC/JS/Make.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e62daab393ef906fe6479827941e51e3e8ccce4...8badd5ed21c6510cd34afe5cd77db1cf7f05147c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e62daab393ef906fe6479827941e51e3e8ccce4...8badd5ed21c6510cd34afe5cd77db1cf7f05147c You're receiving 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 Nov 16 12:28:02 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 07:28:02 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Document defaulting of RuntimeReps Message-ID: <65560ad2c3a00_d535c1917408540e0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - 5d03c316 by Sylvain Henry at 2023-11-16T07:27:36-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 17924162 by Krzysztof Gogolewski at 2023-11-16T07:27:36-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 30 changed files: - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/State.hs - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst - + testsuite/tests/driver/T21097/Makefile - + testsuite/tests/driver/T21097/T21097.stderr - + testsuite/tests/driver/T21097/Test.hs - + testsuite/tests/driver/T21097/all.T - + testsuite/tests/driver/T21097/pkgdb/a.conf - + testsuite/tests/driver/T21097/pkgdb/b.conf - + testsuite/tests/driver/T21097/pkgdb/c.conf - + testsuite/tests/driver/T21097b/Makefile - + testsuite/tests/driver/T21097b/T21097b.stdout - + testsuite/tests/driver/T21097b/Test.hs - + testsuite/tests/driver/T21097b/all.T - + testsuite/tests/driver/T21097b/pkgdb/a.conf - + testsuite/tests/driver/T21097b/pkgdb/b.conf - + testsuite/tests/driver/T21097b/pkgdb/c.conf - + testsuite/tests/polykinds/T24083a.hs - testsuite/tests/polykinds/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/ipe/all.T Changes: ===================================== compiler/GHC/Iface/Errors/Ppr.hs ===================================== @@ -279,9 +279,10 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst mod_hidden pkg = text "it is a hidden module in the package" <+> quotes (ppr pkg) - unusable (pkg, reason) - = text "It is a member of the package" - <+> quotes (ppr pkg) + unusable (UnusableUnit unit reason reexport) + = text "It is " <> (if reexport then text "reexported from the package" + else text "a member of the package") + <+> quotes (ppr unit) $$ pprReason (text "which is") reason ===================================== compiler/GHC/Iface/Errors/Types.hs ===================================== @@ -25,7 +25,7 @@ import GHC.Prelude import GHC.Types.Name (Name) import GHC.Types.TyThing (TyThing) import GHC.Unit.Types (Module, InstalledModule, UnitId, Unit) -import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnitReason, UnitInfo) +import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnit, UnitInfo) import GHC.Exception.Type (SomeException) import GHC.Unit.Types ( IsBootInterface ) import Language.Haskell.Syntax.Module.Name ( ModuleName ) @@ -80,7 +80,7 @@ data CantFindInstalledReason | CouldntFindInFiles [FilePath] | GenericMissing [(Unit, Maybe UnitInfo)] [Unit] - [(Unit, UnusableUnitReason)] [FilePath] + [UnusableUnit] [FilePath] | MultiplePackages [(Module, ModuleOrigin)] deriving Generic ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -2569,23 +2569,19 @@ kcCheckDeclHeader_sig sig_kind name flav -- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'. -- -- Also see Note [Arity of type families and type synonyms] - ; ctx_k <- kc_res_ki + ; res_kind :: ContextKind <- kc_res_ki ; let sig_res_kind' = mkTyConKind excess_sig_tcbs sig_res_kind ; traceTc "kcCheckDeclHeader_sig 2" $ vcat [ text "excess_sig_tcbs" <+> ppr excess_sig_tcbs - , text "ctx_k" <+> ppr ctx_k + , text "res_kind" <+> ppr res_kind , text "sig_res_kind'" <+> ppr sig_res_kind' ] - -- Unify res_ki (from the type declaration) with the residual kind from - -- the kind signature. Don't forget to apply the skolemising 'subst' first. - ; case ctx_k of - AnyKind -> return () -- No signature - _ -> do - res_ki <- newExpectedKind ctx_k - check_exp_res_ki sig_res_kind' res_ki + -- Unify res_ki (from the type declaration) with + -- sig_res_kind', the residual kind from the kind signature. + ; checkExpectedResKind sig_res_kind' res_kind -- Add more binders for data/newtype, so the result kind has no arrows -- See Note [Datatype return kinds] @@ -2608,7 +2604,7 @@ kcCheckDeclHeader_sig sig_kind name flav ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs ; let implicit_prs = implicit_nms `zip` implicit_tvs ; checkForDuplicateScopedTyVars implicit_prs - ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs + ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs -- Swizzle the Names so that the TyCon uses the user-declared implicit names -- E.g type T :: k -> Type @@ -2650,18 +2646,23 @@ kcCheckDeclHeader_sig sig_kind name flav -- | Check the result kind annotation on a type constructor against -- the corresponding section of the standalone kind signature. -- Drops invisible binders that interfere with unification. -check_exp_res_ki :: TcKind -- ^ the actual kind - -> TcKind -- ^ the expected kind - -> TcM () -check_exp_res_ki act_kind exp_kind - = discardResult $ unifyKind Nothing act_kind' exp_kind - where - (_, act_kind') = splitInvisPiTysN n_to_inst act_kind +checkExpectedResKind :: TcKind -- ^ the result kind from the separate kind signature + -> ContextKind -- ^ the result kind from the declaration header + -> TcM () +checkExpectedResKind _ AnyKind + = return () -- No signature in the declaration header +checkExpectedResKind sig_kind res_ki + = do { actual_res_ki <- newExpectedKind res_ki - -- by analogy with checkExpectedKind - n_exp_invis_bndrs = invisibleTyBndrCount exp_kind - n_act_invis_bndrs = invisibleTyBndrCount act_kind - n_to_inst = n_act_invis_bndrs - n_exp_invis_bndrs + ; let -- Drop invisible binders from sig_kind until they match up + -- with res_ki. By analogy with checkExpectedKind. + n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki + n_sig_invis_bndrs = invisibleTyBndrCount sig_kind + n_to_inst = n_sig_invis_bndrs - n_res_invis_bndrs + + (_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind + + ; discardResult $ unifyKind Nothing sig_kind' actual_res_ki } matchUpSigWithDecl :: Name -- Name of the type constructor for error messages @@ -2964,13 +2965,16 @@ expectedKindInCtxt _ = OpenKind * * ********************************************************************* -} -checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM () +checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder] + -> [(Name,TcTyVar)] -> TcM () -- See Note [Disconnected type variables] -- `scoped_prs` is the mapping gotten by unifying -- - the standalone kind signature for T, with -- - the header of the type/class declaration for T -checkForDisconnectedScopedTyVars sig_tcbs scoped_prs - = mapM_ report_disconnected (filterOut ok scoped_prs) +checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs + = when (needsEtaExpansion flav) $ + -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables] + mapM_ report_disconnected (filterOut ok scoped_prs) where sig_tvs = mkVarSet (binderVars sig_tcbs) ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs @@ -3047,6 +3051,25 @@ phantom synonym that just discards its argument. So our plan is this: See #24083 for dicussion of alternatives, none satisfactory. Also the fix is easy: just add an explicit `@kk` parameter to the declaration, to bind `kk` explicitly, rather than binding it implicitly via unification. + +(DTV1) We only want to make this check when there /are/ scoped type variables; and + that is determined by needsEtaExpansion. Examples: + + type C :: x -> y -> Constraint + class C a :: b -> Constraint where { ... } + -- The a,b scope over the "..." + + type D :: forall k. k -> Type + data family D :: kk -> Type + -- Nothing for `kk` to scope over! + + In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will + return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty. So if we do + the check-for-disconnected-tyvars check we'll complain that `kk` is not bound + to one of `all_tcbs` (see #24083, comments about the `singletons` package). + + The scoped-tyvar stuff is needed precisely for data/class/newtype declarations, + where needsEtaExpansion is True. -} {- ********************************************************************* ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -301,7 +301,7 @@ findLookupResult fc fopts r = case r of , fr_suggestions = [] }) LookupUnusable unusable -> let unusables' = map get_unusable unusable - get_unusable (m, ModUnusable r) = (moduleUnit m, r) + get_unusable (_, ModUnusable r) = r get_unusable (_, r) = pprPanic "findLookupResult: unexpected origin" (ppr r) in return (NotFound{ fr_paths = [], fr_pkg = Nothing ===================================== compiler/GHC/Unit/Finder/Types.hs ===================================== @@ -61,7 +61,7 @@ data FindResult -- but the *unit* is hidden -- | Module is in these units, but it is unusable - , fr_unusables :: [(Unit, UnusableUnitReason)] + , fr_unusables :: [UnusableUnit] , fr_suggestions :: [ModuleSuggestion] -- ^ Possible mis-spelled modules } ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -43,6 +43,7 @@ module GHC.Unit.State ( LookupResult(..), ModuleSuggestion(..), ModuleOrigin(..), + UnusableUnit(..), UnusableUnitReason(..), pprReason, @@ -173,8 +174,10 @@ data ModuleOrigin = -- (But maybe the user didn't realize), so we'll still keep track -- of these modules.) ModHidden - -- | Module is unavailable because the package is unusable. - | ModUnusable UnusableUnitReason + + -- | Module is unavailable because the unit is unusable. + | ModUnusable !UnusableUnit + -- | Module is public, and could have come from some places. | ModOrigin { -- | @Just False@ means that this module is in @@ -192,6 +195,13 @@ data ModuleOrigin = , fromPackageFlag :: Bool } +-- | A unusable unit module origin +data UnusableUnit = UnusableUnit + { uuUnit :: !Unit -- ^ Unusable unit + , uuReason :: !UnusableUnitReason -- ^ Reason + , uuIsReexport :: !Bool -- ^ Is the "module" a reexport? + } + instance Outputable ModuleOrigin where ppr ModHidden = text "hidden module" ppr (ModUnusable _) = text "unusable module" @@ -236,7 +246,8 @@ instance Semigroup ModuleOrigin where text "x: " <> ppr x $$ text "y: " <> ppr y g Nothing x = x g x Nothing = x - x <> y = pprPanic "ModOrigin: hidden module redefined" $ + + x <> y = pprPanic "ModOrigin: module origin mismatch" $ text "x: " <> ppr x $$ text "y: " <> ppr y instance Monoid ModuleOrigin where @@ -1818,21 +1829,36 @@ mkUnusableModuleNameProvidersMap :: UnusableUnits -> ModuleNameProvidersMap mkUnusableModuleNameProvidersMap unusables = nonDetFoldUniqMap extend_modmap emptyUniqMap unusables where - extend_modmap (_uid, (pkg, reason)) modmap = addListTo modmap bindings + extend_modmap (_uid, (unit_info, reason)) modmap = addListTo modmap bindings where bindings :: [(ModuleName, UniqMap Module ModuleOrigin)] bindings = exposed ++ hidden - origin = ModUnusable reason - pkg_id = mkUnit pkg + origin_reexport = ModUnusable (UnusableUnit unit reason True) + origin_normal = ModUnusable (UnusableUnit unit reason False) + unit = mkUnit unit_info exposed = map get_exposed exposed_mods - hidden = [(m, mkModMap pkg_id m origin) | m <- hidden_mods] - - get_exposed (mod, Just mod') = (mod, unitUniqMap mod' origin) - get_exposed (mod, _) = (mod, mkModMap pkg_id mod origin) - - exposed_mods = unitExposedModules pkg - hidden_mods = unitHiddenModules pkg + hidden = [(m, mkModMap unit m origin_normal) | m <- hidden_mods] + + -- with re-exports, c:Foo can be reexported from two (or more) + -- unusable packages: + -- Foo -> a:Foo (unusable reason A) -> c:Foo + -- -> b:Foo (unusable reason B) -> c:Foo + -- + -- We must be careful to not record the following (#21097): + -- Foo -> c:Foo (unusable reason A) + -- -> c:Foo (unusable reason B) + -- But: + -- Foo -> a:Foo (unusable reason A) + -- -> b:Foo (unusable reason B) + -- + get_exposed (mod, Just _) = (mod, mkModMap unit mod origin_reexport) + get_exposed (mod, _) = (mod, mkModMap unit mod origin_normal) + -- in the reexport case, we create a virtual module that doesn't + -- exist but we don't care as it's only used as a key in the map. + + exposed_mods = unitExposedModules unit_info + hidden_mods = unitHiddenModules unit_info -- | Add a list of key/value pairs to a nested map. -- ===================================== docs/users_guide/extending_ghc.rst ===================================== @@ -1383,6 +1383,7 @@ The plugin has type ``WantedConstraints -> [DefaultingProposal]``. * It is given the currently unsolved constraints. * It returns a list of independent "defaulting proposals". * Each proposal of type ``DefaultingProposal`` specifies: + * ``deProposals``: specifies a list, in priority order, of sets of type variable assignments * ``deProposalCts :: [Ct]`` gives a set of constraints (always a ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -100,13 +100,13 @@ The following kinds and promoted data constructors can be used even when :extension:`DataKinds` is not enabled: - ``Type`` -- ``TYPE`` (see :ref:`_runtime-rep`) +- ``TYPE`` (see :ref:`runtime-rep`) - ``Constraint`` (see :ref:`constraint-kind`) - ``CONSTRAINT`` - ``Multiplicity`` and its promoted data constructors (see :extension:`LinearTypes`) -- ``LiftedRep`` (see :ref:`_runtime-rep`) -- ``RuntimeRep`` and its promoted data constructors (see :ref:`_runtime-rep`) -- ``Levity`` and its promoted data constructors (see :ref:`_runtime-rep`) +- ``LiftedRep`` (see :ref:`runtime-rep`) +- ``RuntimeRep`` and its promoted data constructors (see :ref:`runtime-rep`) +- ``Levity`` and its promoted data constructors (see :ref:`runtime-rep`) - ``VecCount`` and its promoted data constructors - ``VecElem`` and its promoted data constructors @@ -231,7 +231,7 @@ See also :ghc-ticket:`7347`. :extension:`DataKinds` and type synonyms ---------------------------------------- -The :extensions:`DataKinds` extension interacts with type synonyms in the +The :extension:`DataKinds` extension interacts with type synonyms in the following ways: 1. In a *type* context: :extension:`DataKinds` is not required to use a type ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -1,3 +1,5 @@ +.. _linear-types: + Linear types ============ @@ -58,7 +60,8 @@ partially. See, however :ref:`linear-types-limitations`. Linear and multiplicity-polymorphic arrows are *always declared*, never inferred. That is, if you don't give an appropriate type signature to a function, it will be inferred as being a regular -function of type ``a -> b``. +function of type ``a -> b``. The same principle holds for +representation polymorphism (see :ref:`representation-polymorphism-defaulting`). Data types ---------- ===================================== docs/users_guide/exts/primitives.rst ===================================== @@ -438,7 +438,7 @@ You may even declare levity-polymorphic data types: :: While ``f`` above could reasonably be levity-polymorphic (as it evaluates its argument either way), GHC currently disallows the more general type ``PEither @l Int Bool -> Bool``. This is a consequence of the -`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__, +`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__. Pattern matching against an unlifted data type work just like that for lifted types; but see :ref:`recursive-and-polymorphic-let-bindings` for the semantics of ===================================== docs/users_guide/exts/representation_polymorphism.rst ===================================== @@ -108,6 +108,35 @@ These functions do not bind a representation-polymorphic variable, and so are accepted. Their polymorphism allows users to use these to conveniently stub out functions that return unboxed types. +.. _representation-polymorphism-defaulting: + +Inference and defaulting +------------------------ + +GHC does not infer representation-polymorphic types. +If the representation of a variable is not specified, it will be assumed +to be ``LiftedRep``. +For example, if you write ``f a b = a b``, the inferred type of ``f`` +will be :: + + f :: forall {a :: Type} {b :: Type}. (a -> b) -> a -> b + +even though :: + + f :: forall {rep} {a :: Type} {b :: TYPE rep}. (a -> b) -> a -> b + +would also be legal, as described above. + +Likewise, in a user-written signature ``f :: forall a b. (a -> b) -> a -> b`` +GHC will assume that both ``a`` and ``b`` have kind ``Type``. To use +a different representation, you have to specify the kinds of ``a`` and ``b``. + +During type inference, GHC does not quantify over variables of kind +``RuntimeRep`` nor ``Levity``. +Instead, they are defaulted to ``LiftedRep`` and ``Lifted`` respectively. +Likewise, ``Multiplicity`` variables (:ref:`linear-types`) are defaulted +to ``Many``. + .. _printing-representation-polymorphic-types: Printing representation-polymorphic types ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2574,7 +2574,7 @@ of ``-W(no-)*``. Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind (without having enabled the :extension:`DataKinds` extension) is caught in the typechecker (hence the ``-tc`` suffix). These warnings complement the - existing :extensions:`DataKinds` checks (that have existed since + existing :extension:`DataKinds` checks (that have existed since :extension:`DataKinds` was first introduced), which result in errors instead of warnings. ===================================== testsuite/tests/driver/T21097/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T21097: + '$(GHC_PKG)' recache --package-db pkgdb + - '$(TEST_HC)' -package-db pkgdb -v0 Test.hs; test $$? -eq 2 ===================================== testsuite/tests/driver/T21097/T21097.stderr ===================================== @@ -0,0 +1,16 @@ + +Test.hs:3:1: error: [GHC-87110] + Could not load module ‘Foo’. + It is a member of the package ‘c-0.1’ + which is unusable due to missing dependencies: + d-0.1 + It is reexported from the package ‘b-0.1’ + which is unusable due to missing dependencies: + c-0.1 + It is reexported from the package ‘a-0.1’ + which is unusable due to missing dependencies: + c-0.1 + Use -v to see a list of the files searched for. + | +3 | import Foo + | ^^^^^^^^^^ ===================================== testsuite/tests/driver/T21097/Test.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +import Foo ===================================== testsuite/tests/driver/T21097/all.T ===================================== @@ -0,0 +1,4 @@ +# Package a and b both depend on c which is broken (depends on non-existing d) +test('T21097', + [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "pkgdb/c.conf", "Test.hs"]) + ], makefile_test, []) ===================================== testsuite/tests/driver/T21097/pkgdb/a.conf ===================================== @@ -0,0 +1,12 @@ +name: a +version: 0.1 +visibility: public +id: a-0.1 +key: a-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from c-0.1:Foo + +depends: c-0.1 ===================================== testsuite/tests/driver/T21097/pkgdb/b.conf ===================================== @@ -0,0 +1,12 @@ +name: b +version: 0.1 +visibility: public +id: b-0.1 +key: b-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from c-0.1:Foo + +depends: c-0.1 ===================================== testsuite/tests/driver/T21097/pkgdb/c.conf ===================================== @@ -0,0 +1,12 @@ +name: c +version: 0.1 +visibility: public +id: c-0.1 +key: c-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo + +depends: d-0.1 ===================================== testsuite/tests/driver/T21097b/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T21097b: + '$(GHC_PKG)' recache --package-db pkgdb + '$(TEST_HC)' -no-global-package-db -no-user-package-db -package-db pkgdb -v0 Test.hs -ddump-mod-map ===================================== testsuite/tests/driver/T21097b/T21097b.stdout ===================================== @@ -0,0 +1,5 @@ + +==================== Module Map ==================== +Foo a-0.1 (exposed package) + + ===================================== testsuite/tests/driver/T21097b/Test.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +import Foo ===================================== testsuite/tests/driver/T21097b/all.T ===================================== @@ -0,0 +1,6 @@ +# Package b is unusable (broken dependency) and reexport Foo from a (which is usable) +test('T21097b', + [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "Test.hs"]) + , ignore_stderr + , exit_code(2) + ], makefile_test, []) ===================================== testsuite/tests/driver/T21097b/pkgdb/a.conf ===================================== @@ -0,0 +1,10 @@ +name: a +version: 0.1 +visibility: public +id: a-0.1 +key: a-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo ===================================== testsuite/tests/driver/T21097b/pkgdb/b.conf ===================================== @@ -0,0 +1,12 @@ +name: b +version: 0.1 +visibility: public +id: b-0.1 +key: b-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from a-0.1:Foo + +depends: a-0.1, missing-0.1 ===================================== testsuite/tests/driver/T21097b/pkgdb/c.conf ===================================== @@ -0,0 +1,12 @@ +name: c +version: 0.1 +visibility: public +id: c-0.1 +key: c-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo + +depends: d-0.1 ===================================== testsuite/tests/polykinds/T24083a.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ScopedTypeVariables, RankNTypes #-} + +module T24083a where + +type TyCon :: (k1 -> k2) -> unmatchable_fun +data family TyCon :: (k1 -> k2) -> unmatchable_fun ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -244,3 +244,4 @@ test('T22743', normal, compile_fail, ['']) test('T22742', normal, compile_fail, ['']) test('T22793', normal, compile_fail, ['']) test('T24083', normal, compile_fail, ['']) +test('T24083a', normal, compile, ['']) ===================================== testsuite/tests/rts/all.T ===================================== @@ -216,10 +216,6 @@ test('EventlogOutput_IPE', ], makefile_test, ['EventlogOutput_IPE']) -# Remove the capability prefix from IPE event log lines. -def noCapabilityOutputFilter(s): - return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) - test('T4059', req_c, makefile_test, ['T4059']) # Test for #4274 ===================================== testsuite/tests/rts/ipe/all.T ===================================== @@ -1,3 +1,7 @@ +# Remove the capability prefix from IPE event log lines. +def noCapabilityOutputFilter(s): + return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) + test('ipeMap', [extra_files(['ipe_lib.c', 'ipe_lib.h']), c_src, omit_ghci], compile_and_run, ['ipe_lib.c']) # Manually create IPE entries and dump them to event log (stderr). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2325536a245eece7c96fc615a20523127c12047...17924162f6d59ba32b22871b2abad7985d75e3b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2325536a245eece7c96fc615a20523127c12047...17924162f6d59ba32b22871b2abad7985d75e3b4 You're receiving 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 Nov 16 13:05:34 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 16 Nov 2023 08:05:34 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/no-libghc-pvp Message-ID: <6556139e961c9_d535c28e66186064d@gitlab.mail> Bryan R pushed new branch wip/no-libghc-pvp at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no-libghc-pvp You're receiving 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 Nov 16 14:58:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 09:58:17 -0500 Subject: [Git][ghc/ghc][master] Fix unusable units and module reexport interaction (#21097) Message-ID: <65562e0973d70_d535c5675aac8495b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 19 changed files: - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/State.hs - + testsuite/tests/driver/T21097/Makefile - + testsuite/tests/driver/T21097/T21097.stderr - + testsuite/tests/driver/T21097/Test.hs - + testsuite/tests/driver/T21097/all.T - + testsuite/tests/driver/T21097/pkgdb/a.conf - + testsuite/tests/driver/T21097/pkgdb/b.conf - + testsuite/tests/driver/T21097/pkgdb/c.conf - + testsuite/tests/driver/T21097b/Makefile - + testsuite/tests/driver/T21097b/T21097b.stdout - + testsuite/tests/driver/T21097b/Test.hs - + testsuite/tests/driver/T21097b/all.T - + testsuite/tests/driver/T21097b/pkgdb/a.conf - + testsuite/tests/driver/T21097b/pkgdb/b.conf - + testsuite/tests/driver/T21097b/pkgdb/c.conf Changes: ===================================== compiler/GHC/Iface/Errors/Ppr.hs ===================================== @@ -279,9 +279,10 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst mod_hidden pkg = text "it is a hidden module in the package" <+> quotes (ppr pkg) - unusable (pkg, reason) - = text "It is a member of the package" - <+> quotes (ppr pkg) + unusable (UnusableUnit unit reason reexport) + = text "It is " <> (if reexport then text "reexported from the package" + else text "a member of the package") + <+> quotes (ppr unit) $$ pprReason (text "which is") reason ===================================== compiler/GHC/Iface/Errors/Types.hs ===================================== @@ -25,7 +25,7 @@ import GHC.Prelude import GHC.Types.Name (Name) import GHC.Types.TyThing (TyThing) import GHC.Unit.Types (Module, InstalledModule, UnitId, Unit) -import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnitReason, UnitInfo) +import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnit, UnitInfo) import GHC.Exception.Type (SomeException) import GHC.Unit.Types ( IsBootInterface ) import Language.Haskell.Syntax.Module.Name ( ModuleName ) @@ -80,7 +80,7 @@ data CantFindInstalledReason | CouldntFindInFiles [FilePath] | GenericMissing [(Unit, Maybe UnitInfo)] [Unit] - [(Unit, UnusableUnitReason)] [FilePath] + [UnusableUnit] [FilePath] | MultiplePackages [(Module, ModuleOrigin)] deriving Generic ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -301,7 +301,7 @@ findLookupResult fc fopts r = case r of , fr_suggestions = [] }) LookupUnusable unusable -> let unusables' = map get_unusable unusable - get_unusable (m, ModUnusable r) = (moduleUnit m, r) + get_unusable (_, ModUnusable r) = r get_unusable (_, r) = pprPanic "findLookupResult: unexpected origin" (ppr r) in return (NotFound{ fr_paths = [], fr_pkg = Nothing ===================================== compiler/GHC/Unit/Finder/Types.hs ===================================== @@ -61,7 +61,7 @@ data FindResult -- but the *unit* is hidden -- | Module is in these units, but it is unusable - , fr_unusables :: [(Unit, UnusableUnitReason)] + , fr_unusables :: [UnusableUnit] , fr_suggestions :: [ModuleSuggestion] -- ^ Possible mis-spelled modules } ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -43,6 +43,7 @@ module GHC.Unit.State ( LookupResult(..), ModuleSuggestion(..), ModuleOrigin(..), + UnusableUnit(..), UnusableUnitReason(..), pprReason, @@ -173,8 +174,10 @@ data ModuleOrigin = -- (But maybe the user didn't realize), so we'll still keep track -- of these modules.) ModHidden - -- | Module is unavailable because the package is unusable. - | ModUnusable UnusableUnitReason + + -- | Module is unavailable because the unit is unusable. + | ModUnusable !UnusableUnit + -- | Module is public, and could have come from some places. | ModOrigin { -- | @Just False@ means that this module is in @@ -192,6 +195,13 @@ data ModuleOrigin = , fromPackageFlag :: Bool } +-- | A unusable unit module origin +data UnusableUnit = UnusableUnit + { uuUnit :: !Unit -- ^ Unusable unit + , uuReason :: !UnusableUnitReason -- ^ Reason + , uuIsReexport :: !Bool -- ^ Is the "module" a reexport? + } + instance Outputable ModuleOrigin where ppr ModHidden = text "hidden module" ppr (ModUnusable _) = text "unusable module" @@ -236,7 +246,8 @@ instance Semigroup ModuleOrigin where text "x: " <> ppr x $$ text "y: " <> ppr y g Nothing x = x g x Nothing = x - x <> y = pprPanic "ModOrigin: hidden module redefined" $ + + x <> y = pprPanic "ModOrigin: module origin mismatch" $ text "x: " <> ppr x $$ text "y: " <> ppr y instance Monoid ModuleOrigin where @@ -1818,21 +1829,36 @@ mkUnusableModuleNameProvidersMap :: UnusableUnits -> ModuleNameProvidersMap mkUnusableModuleNameProvidersMap unusables = nonDetFoldUniqMap extend_modmap emptyUniqMap unusables where - extend_modmap (_uid, (pkg, reason)) modmap = addListTo modmap bindings + extend_modmap (_uid, (unit_info, reason)) modmap = addListTo modmap bindings where bindings :: [(ModuleName, UniqMap Module ModuleOrigin)] bindings = exposed ++ hidden - origin = ModUnusable reason - pkg_id = mkUnit pkg + origin_reexport = ModUnusable (UnusableUnit unit reason True) + origin_normal = ModUnusable (UnusableUnit unit reason False) + unit = mkUnit unit_info exposed = map get_exposed exposed_mods - hidden = [(m, mkModMap pkg_id m origin) | m <- hidden_mods] - - get_exposed (mod, Just mod') = (mod, unitUniqMap mod' origin) - get_exposed (mod, _) = (mod, mkModMap pkg_id mod origin) - - exposed_mods = unitExposedModules pkg - hidden_mods = unitHiddenModules pkg + hidden = [(m, mkModMap unit m origin_normal) | m <- hidden_mods] + + -- with re-exports, c:Foo can be reexported from two (or more) + -- unusable packages: + -- Foo -> a:Foo (unusable reason A) -> c:Foo + -- -> b:Foo (unusable reason B) -> c:Foo + -- + -- We must be careful to not record the following (#21097): + -- Foo -> c:Foo (unusable reason A) + -- -> c:Foo (unusable reason B) + -- But: + -- Foo -> a:Foo (unusable reason A) + -- -> b:Foo (unusable reason B) + -- + get_exposed (mod, Just _) = (mod, mkModMap unit mod origin_reexport) + get_exposed (mod, _) = (mod, mkModMap unit mod origin_normal) + -- in the reexport case, we create a virtual module that doesn't + -- exist but we don't care as it's only used as a key in the map. + + exposed_mods = unitExposedModules unit_info + hidden_mods = unitHiddenModules unit_info -- | Add a list of key/value pairs to a nested map. -- ===================================== testsuite/tests/driver/T21097/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T21097: + '$(GHC_PKG)' recache --package-db pkgdb + - '$(TEST_HC)' -package-db pkgdb -v0 Test.hs; test $$? -eq 2 ===================================== testsuite/tests/driver/T21097/T21097.stderr ===================================== @@ -0,0 +1,16 @@ + +Test.hs:3:1: error: [GHC-87110] + Could not load module ‘Foo’. + It is a member of the package ‘c-0.1’ + which is unusable due to missing dependencies: + d-0.1 + It is reexported from the package ‘b-0.1’ + which is unusable due to missing dependencies: + c-0.1 + It is reexported from the package ‘a-0.1’ + which is unusable due to missing dependencies: + c-0.1 + Use -v to see a list of the files searched for. + | +3 | import Foo + | ^^^^^^^^^^ ===================================== testsuite/tests/driver/T21097/Test.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +import Foo ===================================== testsuite/tests/driver/T21097/all.T ===================================== @@ -0,0 +1,4 @@ +# Package a and b both depend on c which is broken (depends on non-existing d) +test('T21097', + [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "pkgdb/c.conf", "Test.hs"]) + ], makefile_test, []) ===================================== testsuite/tests/driver/T21097/pkgdb/a.conf ===================================== @@ -0,0 +1,12 @@ +name: a +version: 0.1 +visibility: public +id: a-0.1 +key: a-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from c-0.1:Foo + +depends: c-0.1 ===================================== testsuite/tests/driver/T21097/pkgdb/b.conf ===================================== @@ -0,0 +1,12 @@ +name: b +version: 0.1 +visibility: public +id: b-0.1 +key: b-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from c-0.1:Foo + +depends: c-0.1 ===================================== testsuite/tests/driver/T21097/pkgdb/c.conf ===================================== @@ -0,0 +1,12 @@ +name: c +version: 0.1 +visibility: public +id: c-0.1 +key: c-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo + +depends: d-0.1 ===================================== testsuite/tests/driver/T21097b/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T21097b: + '$(GHC_PKG)' recache --package-db pkgdb + '$(TEST_HC)' -no-global-package-db -no-user-package-db -package-db pkgdb -v0 Test.hs -ddump-mod-map ===================================== testsuite/tests/driver/T21097b/T21097b.stdout ===================================== @@ -0,0 +1,5 @@ + +==================== Module Map ==================== +Foo a-0.1 (exposed package) + + ===================================== testsuite/tests/driver/T21097b/Test.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +import Foo ===================================== testsuite/tests/driver/T21097b/all.T ===================================== @@ -0,0 +1,6 @@ +# Package b is unusable (broken dependency) and reexport Foo from a (which is usable) +test('T21097b', + [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "Test.hs"]) + , ignore_stderr + , exit_code(2) + ], makefile_test, []) ===================================== testsuite/tests/driver/T21097b/pkgdb/a.conf ===================================== @@ -0,0 +1,10 @@ +name: a +version: 0.1 +visibility: public +id: a-0.1 +key: a-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo ===================================== testsuite/tests/driver/T21097b/pkgdb/b.conf ===================================== @@ -0,0 +1,12 @@ +name: b +version: 0.1 +visibility: public +id: b-0.1 +key: b-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo from a-0.1:Foo + +depends: a-0.1, missing-0.1 ===================================== testsuite/tests/driver/T21097b/pkgdb/c.conf ===================================== @@ -0,0 +1,12 @@ +name: c +version: 0.1 +visibility: public +id: c-0.1 +key: c-0.1 +abi: 4e313a9f18a8df7d71cc2283205935c4 +exposed: True + +exposed-modules: + Foo + +depends: d-0.1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cee81370cd6ef256f66035e3116878d4cb82e28b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cee81370cd6ef256f66035e3116878d4cb82e28b You're receiving 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 Nov 16 14:58:46 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 09:58:46 -0500 Subject: [Git][ghc/ghc][master] Fix IPE test Message-ID: <65562e26656f_d535c5675aac882b8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 2 changed files: - testsuite/tests/rts/all.T - testsuite/tests/rts/ipe/all.T Changes: ===================================== testsuite/tests/rts/all.T ===================================== @@ -216,10 +216,6 @@ test('EventlogOutput_IPE', ], makefile_test, ['EventlogOutput_IPE']) -# Remove the capability prefix from IPE event log lines. -def noCapabilityOutputFilter(s): - return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) - test('T4059', req_c, makefile_test, ['T4059']) # Test for #4274 ===================================== testsuite/tests/rts/ipe/all.T ===================================== @@ -1,3 +1,7 @@ +# Remove the capability prefix from IPE event log lines. +def noCapabilityOutputFilter(s): + return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s) + test('ipeMap', [extra_files(['ipe_lib.c', 'ipe_lib.h']), c_src, omit_ghci], compile_and_run, ['ipe_lib.c']) # Manually create IPE entries and dump them to event log (stderr). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e606230e904482f900a43a25aa4584567f25d87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e606230e904482f900a43a25aa4584567f25d87 You're receiving 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 Nov 16 15:18:32 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 16 Nov 2023 10:18:32 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/time-profile-tick Message-ID: <655632c8cc841_d535c67805e088469@gitlab.mail> Ben Gamari pushed new branch wip/time-profile-tick at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/time-profile-tick You're receiving 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 Nov 16 15:23:34 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 16 Nov 2023 10:23:34 -0500 Subject: [Git][ghc/ghc][wip/time-profile-tick] Introduce timeProfileTick# Message-ID: <655633f6bc86b_d535c6737e089036b@gitlab.mail> Ben Gamari pushed to branch wip/time-profile-tick at Glasgow Haskell Compiler / GHC Commits: 68699d7f by Ben Gamari at 2023-11-16T10:23:25-05:00 Introduce timeProfileTick# - - - - - 6 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - rts/PrimOps.cmm - rts/Proftimer.c - rts/Proftimer.h Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3799,6 +3799,12 @@ primop ClearCCSOp "clearCCS#" GenPrimOp with out_of_line = True +primop TimeProfileTickOp "timeProfileTick#" GenPrimOp + State# s -> State# s + { Register a time profile tick. } + with + out_of_line = True + ------------------------------------------------------------------------ section "Info Table Origin" ------------------------------------------------------------------------ ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1649,6 +1649,7 @@ emitPrimOp cfg primop = WhereFromOp -> alwaysExternal GetApStackValOp -> alwaysExternal ClearCCSOp -> alwaysExternal + TimeProfileTickOp -> alwaysExternal TraceEventOp -> alwaysExternal TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -979,6 +979,8 @@ genPrim prof bound ty op = case op of ClearCCSOp -> \[_r] [x] -> PRPrimCall $ ReturnStat (app "h$clearCCS" [x]) + TimeProfileTickOp -> \[] [] -> PrimInline $ appS "h$timeProfTick" [] + ------------------------------ Eventlog ------------------- TraceEventOp -> \[] [ed,eo] -> PrimInline $ appS "h$traceEvent" [ed,eo] ===================================== rts/PrimOps.cmm ===================================== @@ -2957,3 +2957,11 @@ INFO_TABLE_RET(stg_keepAlive_frame, RET_SMALL, KEEP_ALIVE_FRAME_FIELDS(W_,P_, in { return (ret); } + +// timeProfileTick# :: IO () +stg_timeProfileTickzh () +{ +#if defined(PROFILING) + ccall timeProfTick(MyCapability()); +#endif +} ===================================== rts/Proftimer.c ===================================== @@ -115,6 +115,16 @@ initProfTimer( void ) uint32_t total_ticks = 0; +void +timeProfTick(Capability *cap STG_UNUSED) +{ +#if defined(PROFILING) + CostCentreStack *cccs = RELAXED_LOAD(&cap->r.rCCCS); + cccs->time_ticks++; + traceProfSampleCostCentre(cap, cccs, total_ticks); +#endif +} + void handleProfTick(void) { @@ -124,8 +134,7 @@ handleProfTick(void) uint32_t n; for (n=0; n < getNumCapabilities(); n++) { Capability *cap = getCapability(n); - cap->r.rCCCS->time_ticks++; - traceProfSampleCostCentre(cap, cap->r.rCCCS, total_ticks); + timeProfTick(cap); } } #endif ===================================== rts/Proftimer.h ===================================== @@ -10,10 +10,11 @@ #include "BeginPrivate.h" -void initProfTimer ( void ); -void handleProfTick ( void ); +void initProfTimer ( void ); +void handleProfTick ( void ); void pauseHeapProfTimer ( void ); void resumeHeapProfTimer ( void ); +void timeProfTick ( Capability *cap ); extern bool performHeapProfile; extern bool performTickySample; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68699d7fcbebf5af2f8e7152ba2c992c94da3bba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68699d7fcbebf5af2f8e7152ba2c992c94da3bba You're receiving 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 Nov 16 15:41:05 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 16 Nov 2023 10:41:05 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/fix-6 Message-ID: <65563811f9c_d535c6ddebd095891@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/fix-6 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/fix-6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Nov 16 16:11:17 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 16 Nov 2023 11:11:17 -0500 Subject: [Git][ghc/ghc][wip/romes/fix-6] Improve error message when reading invalid `.target` files Message-ID: <65563f25b5710_d535c7c88b1899967@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fix-6 at Glasgow Haskell Compiler / GHC Commits: 20f36c00 by Rodrigo Mesquita at 2023-11-16T16:07:58+00:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 1 changed file: - hadrian/src/Hadrian/Oracles/TextFile.hs Changes: ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -19,6 +19,7 @@ module Hadrian.Oracles.TextFile ( queryBuildTarget, queryHostTarget, queryTargetTarget ) where +import Debug.Trace import Control.Monad import qualified Data.HashMap.Strict as Map import Data.Maybe @@ -163,14 +164,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20f36c0073ea6cd1baea279eaad9d6b648b8cf13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20f36c0073ea6cd1baea279eaad9d6b648b8cf13 You're receiving 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 Nov 16 16:13:53 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Thu, 16 Nov 2023 11:13:53 -0500 Subject: [Git][ghc/ghc][wip/romes/fix-6] Improve error message when reading invalid `.target` files Message-ID: <65563fc17efc5_d535c7a9a7c010336b@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/fix-6 at Glasgow Haskell Compiler / GHC Commits: bf20564d by Rodrigo Mesquita at 2023-11-16T16:13:44+00:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 1 changed file: - hadrian/src/Hadrian/Oracles/TextFile.hs Changes: ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -163,14 +163,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf20564d64d09c1fb49352800c308760ba2d0c05 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf20564d64d09c1fb49352800c308760ba2d0c05 You're receiving 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 Nov 16 17:12:14 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 16 Nov 2023 12:12:14 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 141 commits: gitlab-ci: Mark T22012 as broken on CentOS 7 Message-ID: <65564d6eddcc7_d535c934fcc01152ed@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 4674b16e by Ben Gamari at 2023-11-16T12:01:46-05:00 rts/CloneStack: Bounds check array write - - - - - f45bab34 by Ben Gamari at 2023-11-16T12:01:46-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - 34f476cb by Ben Gamari at 2023-11-16T12:07:08-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 5124bad9 by Ben Gamari at 2023-11-16T12:07:13-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 82bff412 by Ben Gamari at 2023-11-16T12:07:13-05:00 rts/IPE: Don't expose helper in header - - - - - bf4e32cf by Ben Gamari at 2023-11-16T12:07:13-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 586be6af by Ben Gamari at 2023-11-16T12:12:01-05:00 IPE: Include unit id - - - - - d60546d4 by Ben Gamari at 2023-11-16T12:12:01-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - ae45d71d by Ben Gamari at 2023-11-16T12:12:01-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 30 changed files: - .ghcid - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6816ed1a8963b0f49635159e7f0a6fba293e9bac...ae45d71da82cb7e0ae9be264e06d23b26c2cb435 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6816ed1a8963b0f49635159e7f0a6fba293e9bac...ae45d71da82cb7e0ae9be264e06d23b26c2cb435 You're receiving 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 Nov 16 17:41:42 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Thu, 16 Nov 2023 12:41:42 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/unify-hpc-testsuites Message-ID: <65565456b79f5_d535ca0507f8116159@gitlab.mail> BinderDavid pushed new branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/unify-hpc-testsuites You're receiving 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 Nov 16 18:01:46 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Thu, 16 Nov 2023 13:01:46 -0500 Subject: [Git][ghc/ghc][wip/unify-hpc-testsuites] Adjust Makefiles in testsuite/tests/hpc/* Message-ID: <6556590ac9f0d_d535cacc39401220df@gitlab.mail> BinderDavid pushed to branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC Commits: 5a3e9857 by David Binder at 2023-11-16T19:00:30+01:00 Adjust Makefiles in testsuite/tests/hpc/* The paths configured in these Makefiles were relative to the old location of the tests in libraries/hpc/tests. This Commit adjusts them to the new location in testsuite/tests/hpc. - - - - - 6 changed files: - testsuite/tests/hpc/fork/Makefile - testsuite/tests/hpc/function/Makefile - testsuite/tests/hpc/function2/Makefile - testsuite/tests/hpc/ghc_ghci/Makefile - testsuite/tests/hpc/raytrace/Makefile - testsuite/tests/hpc/simple/Makefile Changes: ===================================== testsuite/tests/hpc/fork/Makefile ===================================== @@ -1,8 +1,4 @@ -# This Makefile runs the tests using GHC's testsuite framework. It -# assumes the package is part of a GHC build tree with the testsuite -# installed in ../../../testsuite. - -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk ===================================== testsuite/tests/hpc/function/Makefile ===================================== @@ -1,8 +1,4 @@ -# This Makefile runs the tests using GHC's testsuite framework. It -# assumes the package is part of a GHC build tree with the testsuite -# installed in ../../../testsuite. - -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk ===================================== testsuite/tests/hpc/function2/Makefile ===================================== @@ -1,8 +1,4 @@ -# This Makefile runs the tests using GHC's testsuite framework. It -# assumes the package is part of a GHC build tree with the testsuite -# installed in ../../../testsuite. - -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk ===================================== testsuite/tests/hpc/ghc_ghci/Makefile ===================================== @@ -1,8 +1,4 @@ -# This Makefile runs the tests using GHC's testsuite framework. It -# assumes the package is part of a GHC build tree with the testsuite -# installed in ../../../testsuite. - -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk ===================================== testsuite/tests/hpc/raytrace/Makefile ===================================== @@ -1,4 +1,4 @@ -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk ===================================== testsuite/tests/hpc/simple/Makefile ===================================== @@ -1,8 +1,4 @@ -# This Makefile runs the tests using GHC's testsuite framework. It -# assumes the package is part of a GHC build tree with the testsuite -# installed in ../../../testsuite. - -TOP=../../../../testsuite +TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a3e985706b3d017e8acc3bd4ad77d2520c89ecf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a3e985706b3d017e8acc3bd4ad77d2520c89ecf You're receiving 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 Nov 16 18:12:27 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 13:12:27 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] 15 commits: Suppress duplicate librares linker warning of new macOS linker Message-ID: <65565b8b2a04e_d535cb03e87c12275d@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - d8d324aa by Matthew Pickering at 2023-11-16T18:12:13+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/State.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/conf.py - docs/users_guide/extending_ghc.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/exts/primitives.rst - docs/users_guide/exts/representation_polymorphism.rst - docs/users_guide/using-warnings.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d40f8f1eb903e55b106f33e7482f1985f524627...d8d324aaf3350d27cdfec90d51c2c57b3ed739fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d40f8f1eb903e55b106f33e7482f1985f524627...d8d324aaf3350d27cdfec90d51c2c57b3ed739fa You're receiving 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 Nov 16 18:18:12 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 13:18:12 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <65565ce42dac6_d535cb2e9270127962@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: c7982955 by Matthew Pickering at 2023-11-16T18:17:57+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 8 changed files: - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test = {} + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -625,6 +667,9 @@ def collect_compiler_stats(metric='all',deviation=20): def collect_stats(metric='all', deviation=20): return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def statsFile(comp_test, name): + return name + ('.comp' if comp_test else '') + '.stats' + # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. # If the boolean is set to true, it indicates that this test is one that @@ -664,15 +709,33 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": lambda way: read_stats_file(way, metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1644,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1785,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - async def static_stats( name, way, stats_file ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_tests) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1797,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1910,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1960,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +1996,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2042,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7982955ec753d7c02bbf29ce5ad0f456fd63fa7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7982955ec753d7c02bbf29ce5ad0f456fd63fa7 You're receiving 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 Nov 16 18:20:31 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 13:20:31 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <65565d6fa2931_d535cb110db8128725@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 91f7ac4b by Matthew Pickering at 2023-11-16T18:20:19+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 8 changed files: - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test = {} + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -625,6 +667,9 @@ def collect_compiler_stats(metric='all',deviation=20): def collect_stats(metric='all', deviation=20): return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def statsFile(comp_test :: bool, name :: str): + return name + ('.comp' if comp_test else '') + '.stats' + # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. # If the boolean is set to true, it indicates that this test is one that @@ -664,15 +709,33 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": lambda way: read_stats_file(way, metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1644,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1785,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - async def static_stats( name, way, stats_file ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_tests) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1797,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1910,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1960,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +1996,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2042,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91f7ac4ba511e0cbe7fcc27ffe8cfceb5ce8063e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91f7ac4ba511e0cbe7fcc27ffe8cfceb5ce8063e You're receiving 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 Nov 16 18:24:18 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 13:24:18 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <65565e52e7a02_d535cb8c0bf812939b@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 7134ef0f by Matthew Pickering at 2023-11-16T18:24:06+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 8 changed files: - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test = {} + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -625,6 +667,9 @@ def collect_compiler_stats(metric='all',deviation=20): def collect_stats(metric='all', deviation=20): return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def statsFile(comp_test: bool, name: str): + return name + ('.comp' if comp_test else '') + '.stats' + # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. # If the boolean is set to true, it indicates that this test is one that @@ -664,15 +709,33 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": lambda way: read_stats_file(way, metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1644,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1785,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - async def static_stats( name, way, stats_file ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_tests) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1797,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1910,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1960,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +1996,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2042,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7134ef0fff724f32d8d88c0cf6dff4874807ef17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7134ef0fff724f32d8d88c0cf6dff4874807ef17 You're receiving 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 Nov 16 18:35:04 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 16 Nov 2023 13:35:04 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <655660d867f22_d535cbb5b8f413192d@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: f51e88d1 by Matthew Pickering at 2023-11-16T18:34:47+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 8 changed files: - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test: Dict = {} # Dict + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -625,6 +667,9 @@ def collect_compiler_stats(metric='all',deviation=20): def collect_stats(metric='all', deviation=20): return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def statsFile(comp_test: bool, name: str) -> str: + return name + ('.comp' if comp_test else '') + '.stats' + # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. # If the boolean is set to true, it indicates that this test is one that @@ -664,15 +709,33 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": lambda way: read_stats_file(way, metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1644,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1785,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - async def static_stats( name, way, stats_file ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_tests) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1797,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1910,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1960,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +1996,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2042,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f51e88d1641ea9f9e276e15c70ffcbfdc4beef84 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f51e88d1641ea9f9e276e15c70ffcbfdc4beef84 You're receiving 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 Nov 16 19:58:31 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 16 Nov 2023 14:58:31 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-noann-not-monoid Message-ID: <65567467c053e_d535cdc0b69414861c@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-noann-not-monoid at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-noann-not-monoid You're receiving 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 Nov 16 20:16:14 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 16 Nov 2023 15:16:14 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 7 commits: base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Message-ID: <6556788e67931_d535ce2d347c1510d3@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: acafac7e by Ben Gamari at 2023-11-16T15:15:54-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - 095c611d by Ben Gamari at 2023-11-16T15:15:54-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 805b3671 by Ben Gamari at 2023-11-16T15:15:54-05:00 rts/IPE: Don't expose helper in header - - - - - f992eb54 by Ben Gamari at 2023-11-16T15:15:54-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - e5a7e91b by Ben Gamari at 2023-11-16T15:15:54-05:00 IPE: Include unit id - - - - - e98cd9d0 by Ben Gamari at 2023-11-16T15:15:54-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 9f3eb252 by Ben Gamari at 2023-11-16T15:15:54-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 26 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/InfoTableProv.hs - libraries/base/base.cabal - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/InfoProv.hsc → libraries/base/src/GHC/InfoProv.hs - + libraries/base/src/GHC/InfoProv/Types.hsc - libraries/base/src/GHC/Stack/CloneStack.hs - rts/CloneStack.c - rts/CloneStack.h - rts/IPE.c - rts/IPE.h - rts/PrimOps.cmm - rts/Trace.c - rts/include/rts/IPE.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/profiling/should_run/staticcallstack001.stdout - testsuite/tests/profiling/should_run/staticcallstack002.stdout - testsuite/tests/rts/ipe/ipeEventLog.stderr - testsuite/tests/rts/ipe/ipeEventLog_fromMap.c - testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr - testsuite/tests/rts/ipe/ipeMap.c - testsuite/tests/rts/ipe/ipe_lib.c Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3803,10 +3803,9 @@ primop ClearCCSOp "clearCCS#" GenPrimOp section "Info Table Origin" ------------------------------------------------------------------------ primop WhereFromOp "whereFrom#" GenPrimOp - a -> State# s -> (# State# s, Addr# #) - { Returns the @InfoProvEnt @ for the info table of the given object - (value is @NULL@ if the table does not exist or there is no information - about the closure).} + a -> Addr# -> State# s -> (# State# s, Int# #) + { Fills the given buffer with the @InfoProvEnt@ for the info table of the + given object. Returns @1#@ on success and @0#@ otherwise.} with out_of_line = True ===================================== compiler/GHC/StgToCmm/InfoTableProv.hs ===================================== @@ -83,9 +83,11 @@ emitIpeBufferListNode this_mod ents = do platform = stgToCmmPlatform cfg int n = mkIntCLit platform n - (cg_ipes, strtab) = flip runState emptyStringTable $ do - module_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr this_mod) - mapM (toCgIPE platform ctx module_name) ents + ((cg_ipes, unit_id, module_name), strtab) = flip runState emptyStringTable $ do + unit_id <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr $ moduleName this_mod) + module_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (ppr $ moduleUnit this_mod) + cg_ipes <- mapM (toCgIPE platform ctx) ents + return (cg_ipes, unit_id, module_name) tables :: [CmmStatic] tables = map (CmmStaticLit . CmmLabel . ipeInfoTablePtr) cg_ipes @@ -136,6 +138,12 @@ emitIpeBufferListNode this_mod ents = do -- 'string_table_size' field (decompressed size) , int $ BS.length uncompressed_strings + + -- 'module_name' field + , CmmInt (fromIntegral module_name) W32 + + -- 'unit_id' field + , CmmInt (fromIntegral unit_id) W32 ] -- Emit the list of info table pointers @@ -173,10 +181,8 @@ toIpeBufferEntries byte_order cg_ipes = , ipeClosureDesc cg_ipe , ipeTypeDesc cg_ipe , ipeLabel cg_ipe - , ipeModuleName cg_ipe , ipeSrcFile cg_ipe , ipeSrcSpan cg_ipe - , 0 -- padding ] word32Builder :: Word32 -> BSB.Builder @@ -184,8 +190,8 @@ toIpeBufferEntries byte_order cg_ipes = BigEndian -> BSB.word32BE LittleEndian -> BSB.word32LE -toCgIPE :: Platform -> SDocContext -> StrTabOffset -> InfoProvEnt -> State StringTable CgInfoProvEnt -toCgIPE platform ctx module_name ipe = do +toCgIPE :: Platform -> SDocContext -> InfoProvEnt -> State StringTable CgInfoProvEnt +toCgIPE platform ctx ipe = do table_name <- lookupStringTable $ ST.pack $ renderWithContext ctx (pprCLabel platform (infoTablePtr ipe)) closure_desc <- lookupStringTable $ ST.pack $ show (infoProvEntClosureType ipe) type_desc <- lookupStringTable $ ST.pack $ infoTableType ipe @@ -205,7 +211,6 @@ toCgIPE platform ctx module_name ipe = do , ipeClosureDesc = closure_desc , ipeTypeDesc = type_desc , ipeLabel = label - , ipeModuleName = module_name , ipeSrcFile = src_file , ipeSrcSpan = src_span } @@ -216,7 +221,6 @@ data CgInfoProvEnt = CgInfoProvEnt , ipeClosureDesc :: !StrTabOffset , ipeTypeDesc :: !StrTabOffset , ipeLabel :: !StrTabOffset - , ipeModuleName :: !StrTabOffset , ipeSrcFile :: !StrTabOffset , ipeSrcSpan :: !StrTabOffset } ===================================== libraries/base/base.cabal ===================================== @@ -339,6 +339,7 @@ Library Data.Semigroup.Internal Data.Typeable.Internal Foreign.ForeignPtr.Imp + GHC.InfoProv.Types GHC.IO.Handle.Lock.Common GHC.IO.Handle.Lock.Flock GHC.IO.Handle.Lock.LinuxOFD ===================================== libraries/base/changelog.md ===================================== @@ -11,6 +11,8 @@ * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) + * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce ) +import GHC.Prim hiding ( coerce, whereFrom# ) import GHC.Types hiding ( IO -- Exported from "GHC.IO" , Type -- Exported from "Data.Kind" ===================================== libraries/base/src/GHC/InfoProv.hsc → libraries/base/src/GHC/InfoProv.hs ===================================== @@ -26,72 +26,15 @@ module GHC.InfoProv ( InfoProv(..) , ipLoc - , ipeProv , whereFrom -- * Internals , InfoProvEnt + , ipeProv , peekInfoProv ) where -#include "Rts.h" - import GHC.Base -import GHC.Show -import GHC.Ptr (Ptr(..), plusPtr, nullPtr) -import GHC.Foreign (CString, peekCString) -import GHC.IO.Encoding (utf8) -import Foreign.Storable (peekByteOff) - -data InfoProv = InfoProv { - ipName :: String, - ipDesc :: String, - ipTyDesc :: String, - ipLabel :: String, - ipMod :: String, - ipSrcFile :: String, - ipSrcSpan :: String -} deriving (Eq, Show) - -data InfoProvEnt - -ipLoc :: InfoProv -> String -ipLoc ipe = ipSrcFile ipe ++ ":" ++ ipSrcSpan ipe - -getIPE :: a -> IO (Ptr InfoProvEnt) -getIPE obj = IO $ \s -> - case whereFrom## obj s of - (## s', addr ##) -> (## s', Ptr addr ##) - -ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv -ipeProv p = (#ptr InfoProvEnt, prov) p - -peekIpName, peekIpDesc, peekIpLabel, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p -peekIpDesc p = (# peek InfoProv, closure_desc) p -peekIpLabel p = (# peek InfoProv, label) p -peekIpModule p = (# peek InfoProv, module) p -peekIpSrcFile p = (# peek InfoProv, src_file) p -peekIpSrcSpan p = (# peek InfoProv, src_span) p -peekIpTyDesc p = (# peek InfoProv, ty_desc) p - -peekInfoProv :: Ptr InfoProv -> IO InfoProv -peekInfoProv infop = do - name <- peekCString utf8 =<< peekIpName infop - desc <- peekCString utf8 =<< peekIpDesc infop - tyDesc <- peekCString utf8 =<< peekIpTyDesc infop - label <- peekCString utf8 =<< peekIpLabel infop - mod <- peekCString utf8 =<< peekIpModule infop - file <- peekCString utf8 =<< peekIpSrcFile infop - span <- peekCString utf8 =<< peekIpSrcSpan infop - return InfoProv { - ipName = name, - ipDesc = desc, - ipTyDesc = tyDesc, - ipLabel = label, - ipMod = mod, - ipSrcFile = file, - ipSrcSpan = span - } +import GHC.InfoProv.Types -- | Get information about where a value originated from. -- This information is stored statically in a binary when `-finfo-table-map` is @@ -105,14 +48,5 @@ peekInfoProv infop = do -- -- @since 4.16.0.0 whereFrom :: a -> IO (Maybe InfoProv) -whereFrom obj = do - ipe <- getIPE obj - -- The primop returns the null pointer in two situations at the moment - -- 1. The lookup fails for whatever reason - -- 2. -finfo-table-map is not enabled. - -- It would be good to distinguish between these two cases somehow. - if ipe == nullPtr - then return Nothing - else do - infoProv <- peekInfoProv (ipeProv ipe) - return $ Just infoProv +whereFrom obj = getIPE obj Nothing $ \p -> + Just `fmap` peekInfoProv (ipeProv p) ===================================== libraries/base/src/GHC/InfoProv/Types.hsc ===================================== @@ -0,0 +1,96 @@ +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE NoImplicitPrelude #-} + +#include "Rts.h" + +module GHC.InfoProv.Types + ( InfoProv(..) + , ipLoc + , ipeProv + , InfoProvEnt + , peekInfoProv + , getIPE + , StgInfoTable + , lookupIPE + ) where + +import GHC.Base +import GHC.Show (Show) +import GHC.Ptr (Ptr(..), plusPtr) +import GHC.Foreign (CString, peekCString) +import Foreign.C.Types (CBool(..)) +import Foreign.Marshal.Alloc (allocaBytes) +import GHC.IO.Encoding (utf8) +import Foreign.Storable (peekByteOff) + +data InfoProv = InfoProv { + ipName :: String, + ipDesc :: String, + ipTyDesc :: String, + ipLabel :: String, + ipUnitId :: String, + ipMod :: String, + ipSrcFile :: String, + ipSrcSpan :: String +} deriving (Eq, Show) + +ipLoc :: InfoProv -> String +ipLoc ipe = ipSrcFile ipe ++ ":" ++ ipSrcSpan ipe + +data InfoProvEnt + +data StgInfoTable + +foreign import ccall "lookupIPE" c_lookupIPE :: Ptr StgInfoTable -> Ptr InfoProvEnt -> IO CBool + +lookupIPE :: Ptr StgInfoTable -> IO (Maybe InfoProv) +lookupIPE itbl = allocaBytes (#size InfoProvEnt) $ \p -> do + res <- c_lookupIPE itbl p + case res of + 1 -> Just `fmap` peekInfoProv (ipeProv p) + _ -> return Nothing + +getIPE :: a -> r -> (Ptr InfoProvEnt -> IO r) -> IO r +getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s -> + case whereFrom## obj (unPtr p) s of + (## s', 1## ##) -> unIO (k p) s' + (## s', _ ##) -> (## s', fail ##) + where + unPtr (Ptr p) = p + +ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv +ipeProv p = (#ptr InfoProvEnt, prov) p + +peekIpName, peekIpDesc, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc p = (# peek InfoProv, closure_desc) p +peekIpLabel p = (# peek InfoProv, label) p +peekIpUnitId p = (# peek InfoProv, unit_id) p +peekIpModule p = (# peek InfoProv, module) p +peekIpSrcFile p = (# peek InfoProv, src_file) p +peekIpSrcSpan p = (# peek InfoProv, src_span) p +peekIpTyDesc p = (# peek InfoProv, ty_desc) p + +peekInfoProv :: Ptr InfoProv -> IO InfoProv +peekInfoProv infop = do + name <- peekCString utf8 =<< peekIpName infop + desc <- peekCString utf8 =<< peekIpDesc infop + tyDesc <- peekCString utf8 =<< peekIpTyDesc infop + label <- peekCString utf8 =<< peekIpLabel infop + unit_id <- peekCString utf8 =<< peekIpUnitId infop + mod <- peekCString utf8 =<< peekIpModule infop + file <- peekCString utf8 =<< peekIpSrcFile infop + span <- peekCString utf8 =<< peekIpSrcSpan infop + return InfoProv { + ipName = name, + ipDesc = desc, + ipTyDesc = tyDesc, + ipLabel = label, + ipUnitId = unit_id, + ipMod = mod, + ipSrcFile = file, + ipSrcSpan = span + } + ===================================== libraries/base/src/GHC/Stack/CloneStack.hs ===================================== @@ -26,9 +26,10 @@ import Control.Concurrent.MVar import Data.Maybe (catMaybes) import Foreign import GHC.Conc.Sync -import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#) -import GHC.IO (IO (..)) -import GHC.InfoProv (InfoProv (..), InfoProvEnt, ipLoc, ipeProv, peekInfoProv) +import GHC.Ptr (Ptr(..)) +import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, ByteArray#, sizeofByteArray#, indexAddrArray#, State#, StablePtr#) +import GHC.IO (IO (..), unIO, unsafeInterleaveIO) +import GHC.InfoProv.Types (InfoProv (..), ipLoc, lookupIPE, StgInfoTable) import GHC.Stable -- | A frozen snapshot of the state of an execution stack. @@ -36,7 +37,7 @@ import GHC.Stable -- @since 4.17.0.0 data StackSnapshot = StackSnapshot !StackSnapshot# -foreign import prim "stg_decodeStackzh" decodeStack# :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, Array# (Ptr InfoProvEnt) #) +foreign import prim "stg_decodeStackzh" decodeStack# :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, ByteArray# #) foreign import prim "stg_cloneMyStackzh" cloneMyStack# :: State# RealWorld -> (# State# RealWorld, StackSnapshot# #) @@ -228,37 +229,31 @@ data StackEntry = StackEntry -- -- @since 4.17.0.0 decode :: StackSnapshot -> IO [StackEntry] -decode stackSnapshot = do - stackEntries <- getDecodedStackArray stackSnapshot - ipes <- mapM unmarshal stackEntries - return $ catMaybes ipes - - where - unmarshal :: Ptr InfoProvEnt -> IO (Maybe StackEntry) - unmarshal ipe = if ipe == nullPtr then - pure Nothing - else do - infoProv <- (peekInfoProv . ipeProv) ipe - pure $ Just (toStackEntry infoProv) - toStackEntry :: InfoProv -> StackEntry - toStackEntry infoProv = - StackEntry - { 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 - } - -getDecodedStackArray :: StackSnapshot -> IO [Ptr InfoProvEnt] +decode stackSnapshot = catMaybes <$> getDecodedStackArray stackSnapshot + +toStackEntry :: InfoProv -> StackEntry +toStackEntry infoProv = + StackEntry + { 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 + } + +getDecodedStackArray :: StackSnapshot -> IO [Maybe StackEntry] getDecodedStackArray (StackSnapshot s) = IO $ \s0 -> case decodeStack# s s0 of - (# s1, a #) -> (# s1, (go a ((I# (sizeofArray# a)) - 1)) #) + (# s1, arr #) -> + let n = I# (sizeofByteArray# arr) `div` 8 - 1 + in unIO (go arr n) s1 where - go :: Array# (Ptr InfoProvEnt) -> Int -> [Ptr InfoProvEnt] - go stack 0 = [stackEntryAt stack 0] - go stack i = (stackEntryAt stack i) : go stack (i - 1) - - stackEntryAt :: Array# (Ptr InfoProvEnt) -> Int -> Ptr InfoProvEnt - stackEntryAt stack (I# i) = case indexArray# stack i of - (# se #) -> se + go :: ByteArray# -> Int -> IO [Maybe StackEntry] + go _stack (-1) = return [] + go stack i = do + infoProv <- lookupIPE (stackEntryAt stack i) + rest <- unsafeInterleaveIO $ go stack (i-1) + return ((toStackEntry `fmap` infoProv) : rest) + + stackEntryAt :: ByteArray# -> Int -> Ptr StgInfoTable + stackEntryAt stack (I# i) = Ptr (indexAddrArray# stack i) ===================================== rts/CloneStack.c ===================================== @@ -27,9 +27,8 @@ static StgWord getStackFrameCount(StgStack* stack); static StgWord getStackChunkClosureCount(StgStack* stack); -static void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack); -static StgClosure* createPtrClosure(Capability* cap, InfoProvEnt* ipe); -static StgMutArrPtrs* allocateMutableArray(StgWord size); +static StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes); +static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack); static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack) { @@ -115,12 +114,12 @@ void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) // array is the count of stack frames. // Each InfoProvEnt* is looked up by lookupIPE(). If there's no IPE for a stack // frame it's represented by null. -StgMutArrPtrs* decodeClonedStack(Capability *cap, StgStack* stack) { +StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack) { StgWord closureCount = getStackFrameCount(stack); - StgMutArrPtrs* array = allocateMutableArray(closureCount); + StgArrBytes* array = allocateByteArray(cap, sizeof(StgInfoTable*) * closureCount); - copyPtrsToArray(cap, array, stack); + copyPtrsToArray(array, stack); return array; } @@ -156,54 +155,33 @@ StgWord getStackChunkClosureCount(StgStack* stack) { return closureCount; } -// Allocate and initialize memory for a MutableArray# (Haskell representation). -StgMutArrPtrs* allocateMutableArray(StgWord closureCount) { +// Allocate and initialize memory for a ByteArray# (Haskell representation). +StgArrBytes* allocateByteArray(Capability *cap, StgWord bytes) { // Idea stolen from PrimOps.cmm:stg_newArrayzh() - StgWord size = closureCount + mutArrPtrsCardTableSize(closureCount); - StgWord words = sizeofW(StgMutArrPtrs) + size; + StgWord words = sizeofW(StgArrBytes) + bytes; - StgMutArrPtrs* array = (StgMutArrPtrs*) allocate(myTask()->cap, words); - - SET_HDR(array, &stg_MUT_ARR_PTRS_DIRTY_info, CCS_SYSTEM); - array->ptrs = closureCount; - array->size = size; + StgArrBytes* array = (StgArrBytes*) allocate(cap, words); + SET_HDR(array, &stg_ARR_WORDS_info, CCS_SYSTEM); + array->bytes = bytes; return array; } - -void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack) { +static void copyPtrsToArray(StgArrBytes* arr, StgStack* stack) { StgWord index = 0; StgStack *last_stack = stack; + const StgInfoTable **result = (const StgInfoTable **) arr->payload; while (true) { StgPtr sp = last_stack->sp; StgPtr spBottom = last_stack->stack + last_stack->stack_size; for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { - const StgInfoTable* infoTable = get_itbl((StgClosure *)sp); - - // Add the IPE that was looked up by lookupIPE() to the MutableArray#. - // The "Info Table Provernance Entry Map" (IPE) idea is to use a pointer - // (address) to the info table to lookup entries, this is fulfilled in - // non-"Tables Next to Code" builds. - // When "Tables Next to Code" is used, the assembly label of the info table - // is between the info table and it's code. There's no other label in the - // assembly code which could be used instead, thus lookupIPE() is actually - // called with the code pointer of the info table. - // (As long as it's used consistently, this doesn't really matter - IPE uses - // the pointer only to connect an info table to it's provenance entry in the - // IPE map.) -#if defined(TABLES_NEXT_TO_CODE) - InfoProvEnt* ipe = lookupIPE((StgInfoTable*) infoTable->code); -#else - InfoProvEnt* ipe = lookupIPE(infoTable); -#endif - arr->payload[index] = createPtrClosure(cap, ipe); - + const StgInfoTable* infoTable = ((StgClosure *)sp)->header.info; + result[index] = infoTable; index++; } // Ensure that we didn't overflow the result array - ASSERT(index-1 < arr->ptrs); + ASSERT(index-1 < arr->bytes / sizeof(StgInfoTable*)); // check whether the stack ends in an underflow frame StgUnderflowFrame *frame = (StgUnderflowFrame *) (last_stack->stack @@ -215,12 +193,3 @@ void copyPtrsToArray(Capability *cap, StgMutArrPtrs* arr, StgStack* stack) { } } } - -// Create a GHC.Ptr (Haskell constructor: `Ptr InfoProvEnt`) pointing to the -// IPE. -StgClosure* createPtrClosure(Capability *cap, InfoProvEnt* ipe) { - StgClosure *p = (StgClosure *) allocate(cap, CONSTR_sizeW(0,1)); - SET_HDR(p, &base_GHCziPtr_Ptr_con_info, CCS_SYSTEM); - p->payload[0] = (StgClosure*) ipe; - return TAG_CLOSURE(1, p); -} ===================================== rts/CloneStack.h ===================================== @@ -15,7 +15,7 @@ StgStack* cloneStack(Capability* capability, const StgStack* stack); void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); -StgMutArrPtrs* decodeClonedStack(Capability *cap, StgStack* stack); +StgArrBytes* decodeClonedStack(Capability *cap, StgStack* stack); #include "BeginPrivate.h" ===================================== rts/IPE.c ===================================== @@ -52,16 +52,23 @@ of InfoProvEnt are represented in IpeBufferEntry as 32-bit offsets into the string table. This allows us to halve the size of the buffer entries on 64-bit machines while significantly reducing the number of needed relocations, reducing linking cost. Moreover, the code generator takes care -to deduplicate strings when generating the string table. When we insert a -set of IpeBufferEntrys into the IPE hash-map we convert them to InfoProvEnts, -which contain proper string pointers. +to deduplicate strings when generating the string table. Building the hash map is done lazily, i.e. on first lookup or traversal. For this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. +This involves allocating a IpeMapEntry for each IPE entry, pointing to the +entry's containing IpeBufferListNode and its index in that node. + +When the user looks up an IPE entry, we convert it to the user-facing +InfoProvEnt representation. -After the content of a IpeBufferListNode has been inserted, it's freed. */ +typedef struct { + IpeBufferListNode *node; + uint32_t idx; +} IpeMapEntry; + #if defined(THREADED_RTS) static Mutex ipeMapLock; #endif @@ -71,6 +78,9 @@ static HashTable *ipeMap = NULL; // Accessed atomically static IpeBufferListNode *ipeBufferList = NULL; +static void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode*); +static void updateIpeMap(void); + #if defined(THREADED_RTS) void initIpe(void) { initMutex(&ipeMapLock); } @@ -85,18 +95,23 @@ void exitIpe(void) { } #endif // THREADED_RTS -static InfoProvEnt ipeBufferEntryToIpe(const char *strings, const StgInfoTable *tbl, const IpeBufferEntry ent) +static InfoProvEnt ipeBufferEntryToIpe(const IpeBufferListNode *node, uint32_t idx) { + CHECK(idx < node->count); + CHECK(!node->compressed); + const char *strings = node->string_table; + const IpeBufferEntry *ent = &node->entries[idx]; return (InfoProvEnt) { - .info = tbl, + .info = node->tables[idx], .prov = { - .table_name = &strings[ent.table_name], - .closure_desc = &strings[ent.closure_desc], - .ty_desc = &strings[ent.ty_desc], - .label = &strings[ent.label], - .module = &strings[ent.module_name], - .src_file = &strings[ent.src_file], - .src_span = &strings[ent.src_span] + .table_name = &strings[ent->table_name], + .closure_desc = &strings[ent->closure_desc], + .ty_desc = &strings[ent->ty_desc], + .label = &strings[ent->label], + .unit_id = &strings[node->unit_id], + .module = &strings[node->module_name], + .src_file = &strings[ent->src_file], + .src_span = &strings[ent->src_span] } }; } @@ -105,29 +120,22 @@ static InfoProvEnt ipeBufferEntryToIpe(const char *strings, const StgInfoTable * #if defined(TRACING) static void traceIPEFromHashTable(void *data STG_UNUSED, StgWord key STG_UNUSED, const void *value) { - InfoProvEnt *ipe = (InfoProvEnt *)value; - traceIPE(ipe); + const IpeMapEntry *map_ent = (const IpeMapEntry *)value; + const InfoProvEnt ipe = ipeBufferEntryToIpe(map_ent->node, map_ent->idx); + traceIPE(&ipe); } void dumpIPEToEventLog(void) { // Dump pending entries - IpeBufferListNode *cursor = RELAXED_LOAD(&ipeBufferList); - while (cursor != NULL) { - IpeBufferEntry *entries; - const char *strings; + IpeBufferListNode *node = RELAXED_LOAD(&ipeBufferList); + while (node != NULL) { + decompressIPEBufferListNodeIfCompressed(node); - // Decompress if compressed - decompressIPEBufferListNodeIfCompressed(cursor, &entries, &strings); - - for (uint32_t i = 0; i < cursor->count; i++) { - const InfoProvEnt ent = ipeBufferEntryToIpe( - strings, - cursor->tables[i], - entries[i] - ); + for (uint32_t i = 0; i < node->count; i++) { + const InfoProvEnt ent = ipeBufferEntryToIpe(node, i); traceIPE(&ent); } - cursor = cursor->next; + node = node->next; } // Dump entries already in hashmap @@ -168,9 +176,15 @@ void registerInfoProvList(IpeBufferListNode *node) { } } -InfoProvEnt *lookupIPE(const StgInfoTable *info) { +bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out) { updateIpeMap(); - return lookupHashTable(ipeMap, (StgWord)info); + IpeMapEntry *map_ent = (IpeMapEntry *) lookupHashTable(ipeMap, (StgWord)info); + if (map_ent) { + *out = ipeBufferEntryToIpe(map_ent->node, map_ent->idx); + return true; + } else { + return false; + } } void updateIpeMap(void) { @@ -188,47 +202,40 @@ void updateIpeMap(void) { } while (pending != NULL) { - IpeBufferListNode *current_node = pending; - IpeBufferEntry *entries; - const char *strings; + IpeBufferListNode *node = pending; // Decompress if compressed - decompressIPEBufferListNodeIfCompressed(current_node, &entries, &strings); - - // Convert the on-disk IPE buffer entry representation (IpeBufferEntry) - // into the runtime representation (InfoProvEnt) - InfoProvEnt *ip_ents = stgMallocBytes( - sizeof(InfoProvEnt) * current_node->count, - "updateIpeMap: ip_ents" - ); - for (uint32_t i = 0; i < current_node->count; i++) { - const IpeBufferEntry ent = entries[i]; - const StgInfoTable *tbl = current_node->tables[i]; - ip_ents[i] = ipeBufferEntryToIpe(strings, tbl, ent); - insertHashTable(ipeMap, (StgWord) tbl, &ip_ents[i]); + decompressIPEBufferListNodeIfCompressed(node); + + // Insert entries into ipeMap + IpeMapEntry *map_ents = stgMallocBytes(node->count * sizeof(IpeMapEntry), "updateIpeMap: ip_ents"); + for (uint32_t i = 0; i < node->count; i++) { + const StgInfoTable *tbl = node->tables[i]; + map_ents[i].node = node; + map_ents[i].idx = i; + insertHashTable(ipeMap, (StgWord) tbl, &map_ents[i]); } - pending = current_node->next; + pending = node->next; } RELEASE_LOCK(&ipeMapLock); } /* Decompress the IPE data and strings table referenced by an IPE buffer list -node if it is compressed. No matter whether the data is compressed, the pointers -referenced by the 'entries_dst' and 'string_table_dst' parameters will point at -the decompressed IPE data and string table for the given node, respectively, -upon return from this function. -*/ -void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferEntry **entries_dst, const char **string_table_dst) { + * node if it is compressed. After returning node->compressed with be 0 and the + * string_table and entries fields will have their uncompressed values. + */ +void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node) { if (node->compressed == 1) { + node->compressed = 0; + // The IPE list buffer node indicates that the strings table and // entries list has been compressed. If zstd is not available, fail. // If zstd is available, decompress. #if HAVE_LIBZSTD == 0 barf("An IPE buffer list node has been compressed, but the " - "decompression library (zstd) is not available." -); + "decompression library (zstd) is not available."); #else size_t compressed_sz = ZSTD_findFrameCompressedSize( node->string_table, @@ -244,7 +251,7 @@ void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferE node->string_table, compressed_sz ); - *string_table_dst = decompressed_strings; + node->string_table = (const char *) decompressed_strings; // Decompress the IPE data compressed_sz = ZSTD_findFrameCompressedSize( @@ -261,12 +268,8 @@ void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode *node, IpeBufferE node->entries, compressed_sz ); - *entries_dst = decompressed_entries; + node->entries = decompressed_entries; #endif // HAVE_LIBZSTD == 0 - } else { - // Not compressed, no need to decompress - *entries_dst = node->entries; - *string_table_dst = node->string_table; } } ===================================== rts/IPE.h ===================================== @@ -14,9 +14,7 @@ #include "BeginPrivate.h" void dumpIPEToEventLog(void); -void updateIpeMap(void); void initIpe(void); void exitIpe(void); -void decompressIPEBufferListNodeIfCompressed(IpeBufferListNode*, IpeBufferEntry**, const char**); #include "EndPrivate.h" ===================================== rts/PrimOps.cmm ===================================== @@ -2539,13 +2539,13 @@ stg_closureSizzezh (P_ clos) return (len); } -stg_whereFromzh (P_ clos) +stg_whereFromzh (P_ clos, W_ buf) { - P_ ipe; + CBool success; W_ info; info = GET_INFO(UNTAG(clos)); - (ipe) = foreign "C" lookupIPE(info "ptr"); - return (ipe); + (success) = foreign "C" lookupIPE(info, buf); + return (TO_W_(success)); } /* ----------------------------------------------------------------------------- ===================================== rts/Trace.c ===================================== @@ -689,9 +689,10 @@ void traceIPE(const InfoProvEnt *ipe) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, module %s, srcloc %s:%s\n", + debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, unit %s, module %s, srcloc %s:%s\n", ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc, - ipe->prov.label, ipe->prov.module, ipe->prov.src_file, ipe->prov.src_span); + ipe->prov.label, ipe->prov.unit_id, ipe->prov.module, + ipe->prov.src_file, ipe->prov.src_span); RELEASE_LOCK(&trace_utx); } else ===================================== rts/include/rts/IPE.h ===================================== @@ -18,6 +18,7 @@ typedef struct InfoProv_ { const char *closure_desc; const char *ty_desc; const char *label; + const char *unit_id; const char *module; const char *src_file; const char *src_span; @@ -56,10 +57,8 @@ typedef struct { StringIdx closure_desc; StringIdx ty_desc; StringIdx label; - StringIdx module_name; StringIdx src_file; StringIdx src_span; - uint32_t _padding; } IpeBufferEntry; GHC_STATIC_ASSERT(sizeof(IpeBufferEntry) % (WORD_SIZE_IN_BITS / 8) == 0, "sizeof(IpeBufferEntry) must be a multiple of the word size"); @@ -77,13 +76,18 @@ typedef struct IpeBufferListNode_ { // When TNTC is enabled, these will point to the entry code // not the info table itself. const StgInfoTable **tables; - IpeBufferEntry *entries; StgWord entries_size; // decompressed size const char *string_table; StgWord string_table_size; // decompressed size + + // Shared by all entries + StringIdx unit_id; + StringIdx module_name; } IpeBufferListNode; void registerInfoProvList(IpeBufferListNode *node); -InfoProvEnt *lookupIPE(const StgInfoTable *info); + +// Returns true on success, initializes `out`. +bool lookupIPE(const StgInfoTable *info, InfoProvEnt *out); ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4679,7 +4679,7 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6730,7 +6730,7 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -7960,7 +7960,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Trustworthy type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipUnitId :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Base.String @@ -12063,7 +12063,7 @@ instance GHC.Show.Show GHC.RTS.Flags.RTSFlags -- Defined in ‘GHC.RTS.Flags’ instance GHC.Show.Show GHC.RTS.Flags.TickyFlags -- Defined in ‘GHC.RTS.Flags’ instance GHC.Show.Show GHC.RTS.Flags.TraceFlags -- Defined in ‘GHC.RTS.Flags’ instance GHC.Show.Show GHC.IOPort.IOPortException -- Defined in ‘GHC.IOPort’ -instance GHC.Show.Show GHC.InfoProv.InfoProv -- Defined in ‘GHC.InfoProv’ +instance GHC.Show.Show base-4.19.0.0:GHC.InfoProv.Types.InfoProv -- Defined in ‘base-4.19.0.0:GHC.InfoProv.Types’ instance GHC.Show.Show GHC.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Stack.CloneStack’ instance GHC.Show.Show GHC.StaticPtr.StaticPtrInfo -- Defined in ‘GHC.StaticPtr’ instance GHC.Show.Show GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ @@ -12253,7 +12253,7 @@ instance GHC.Classes.Eq GHC.IO.IOMode.IOMode -- Defined in ‘GHC.IO.IOMode’ instance GHC.Classes.Eq GHC.RTS.Flags.IoSubSystem -- Defined in ‘GHC.RTS.Flags’ instance forall i e. GHC.Classes.Eq (GHC.IOArray.IOArray i e) -- Defined in ‘GHC.IOArray’ instance forall a. GHC.Classes.Eq (GHC.IOPort.IOPort a) -- Defined in ‘GHC.IOPort’ -instance GHC.Classes.Eq GHC.InfoProv.InfoProv -- Defined in ‘GHC.InfoProv’ +instance GHC.Classes.Eq base-4.19.0.0:GHC.InfoProv.Types.InfoProv -- Defined in ‘base-4.19.0.0:GHC.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ instance GHC.Classes.Eq GHC.Num.Natural.Natural -- Defined in ‘GHC.Num.Natural’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4679,7 +4679,7 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6699,7 +6699,7 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -7929,7 +7929,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Trustworthy type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipUnitId :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Base.String ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4682,7 +4682,7 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6879,7 +6879,7 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -8184,7 +8184,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Trustworthy type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipUnitId :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Base.String @@ -12341,7 +12341,7 @@ instance GHC.Show.Show GHC.IO.Windows.Handle.CONSOLE_READCONSOLE_CONTROL -- Defi instance GHC.Show.Show (GHC.IO.Windows.Handle.Io GHC.IO.Windows.Handle.NativeHandle) -- Defined in ‘GHC.IO.Windows.Handle’ instance GHC.Show.Show (GHC.IO.Windows.Handle.Io GHC.IO.Windows.Handle.ConsoleHandle) -- Defined in ‘GHC.IO.Windows.Handle’ instance GHC.Show.Show GHC.IOPort.IOPortException -- Defined in ‘GHC.IOPort’ -instance GHC.Show.Show GHC.InfoProv.InfoProv -- Defined in ‘GHC.InfoProv’ +instance GHC.Show.Show base-4.19.0.0:GHC.InfoProv.Types.InfoProv -- Defined in ‘base-4.19.0.0:GHC.InfoProv.Types’ instance GHC.Show.Show GHC.Stack.CloneStack.StackEntry -- Defined in ‘GHC.Stack.CloneStack’ instance GHC.Show.Show GHC.StaticPtr.StaticPtrInfo -- Defined in ‘GHC.StaticPtr’ instance GHC.Show.Show GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ @@ -12529,7 +12529,7 @@ instance GHC.Classes.Eq GHC.RTS.Flags.IoSubSystem -- Defined in ‘GHC.RTS.Flags instance GHC.Classes.Eq GHC.IO.Windows.Handle.TempFileOptions -- Defined in ‘GHC.IO.Windows.Handle’ instance forall i e. GHC.Classes.Eq (GHC.IOArray.IOArray i e) -- Defined in ‘GHC.IOArray’ instance forall a. GHC.Classes.Eq (GHC.IOPort.IOPort a) -- Defined in ‘GHC.IOPort’ -instance GHC.Classes.Eq GHC.InfoProv.InfoProv -- Defined in ‘GHC.InfoProv’ +instance GHC.Classes.Eq base-4.19.0.0:GHC.InfoProv.Types.InfoProv -- Defined in ‘base-4.19.0.0:GHC.InfoProv.Types’ instance GHC.Classes.Eq GHC.Num.Integer.Integer -- Defined in ‘GHC.Num.Integer’ instance GHC.Classes.Eq GHC.Num.BigNat.BigNat -- Defined in ‘GHC.Num.BigNat’ instance GHC.Classes.Eq GHC.Num.Natural.Natural -- Defined in ‘GHC.Num.Natural’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4679,7 +4679,7 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6730,7 +6730,7 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> State# d -> (# State# d, Addr# #) + whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -7960,7 +7960,7 @@ module GHC.IORef where module GHC.InfoProv where -- Safety: Trustworthy type InfoProv :: * - data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} + data InfoProv = InfoProv {ipName :: GHC.Base.String, ipDesc :: GHC.Base.String, ipTyDesc :: GHC.Base.String, ipLabel :: GHC.Base.String, ipUnitId :: GHC.Base.String, ipMod :: GHC.Base.String, ipSrcFile :: GHC.Base.String, ipSrcSpan :: GHC.Base.String} type InfoProvEnt :: * data InfoProvEnt ipLoc :: InfoProv -> GHC.Base.String ===================================== testsuite/tests/profiling/should_run/staticcallstack001.stdout ===================================== @@ -1,3 +1,3 @@ -Just (InfoProv {ipName = "D_Main_4_con_info", ipDesc = "2", ipTyDesc = "D", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "16:13-27"}) -Just (InfoProv {ipName = "D_Main_2_con_info", ipDesc = "2", ipTyDesc = "D", ipLabel = "caf", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "13:1-9"}) -Just (InfoProv {ipName = "sat_s11M_info", ipDesc = "15", ipTyDesc = "D", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "18:23-32"}) +Just (InfoProv {ipName = "D_Main_4_con_info", ipDesc = "2", ipTyDesc = "D", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "16:13-27"}) +Just (InfoProv {ipName = "D_Main_2_con_info", ipDesc = "2", ipTyDesc = "D", ipLabel = "caf", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "13:1-9"}) +Just (InfoProv {ipName = "sat_s13S_info", ipDesc = "15", ipTyDesc = "D", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack001.hs", ipSrcSpan = "18:23-32"}) ===================================== testsuite/tests/profiling/should_run/staticcallstack002.stdout ===================================== @@ -1,4 +1,4 @@ -Just (InfoProv {ipName = "sat_s11p_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"}) -Just (InfoProv {ipName = "sat_s11F_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"}) -Just (InfoProv {ipName = "sat_s11V_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"}) -Just (InfoProv {ipName = "sat_s12b_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"}) +Just (InfoProv {ipName = "sat_s13u_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"}) +Just (InfoProv {ipName = "sat_s13O_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"}) +Just (InfoProv {ipName = "sat_s148_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"}) +Just (InfoProv {ipName = "sat_s14s_info", ipDesc = "15", ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"}) ===================================== testsuite/tests/rts/ipe/ipeEventLog.stderr ===================================== @@ -1,20 +1,20 @@ -7f5278bc0740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f5278bc0740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f5278bc0740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f5278bc0740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f5278bc0740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f5278bc0740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f5278bc0740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f5278bc0740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f5278bc0740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f5278bc0740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f5278bc0740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f5278bc0740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f5278bc0740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f5278bc0740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f5278bc0740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f5278bc0740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f5278bc0740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f5278bc0740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f5278bc0740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f5278bc0740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.c ===================================== @@ -19,7 +19,8 @@ int main(int argc, char *argv[]) { registerInfoProvList(list2); // Query an IPE to initialize the underlying hash map. - lookupIPE(list1->tables[0]); + InfoProvEnt ipe; + lookupIPE(list1->tables[0], &ipe); // Trace all IPE events. dumpIPEToEventLog(); ===================================== testsuite/tests/rts/ipe/ipeEventLog_fromMap.stderr ===================================== @@ -1,68 +1,20 @@ -7f86c4be8740: created capset 0 of type 2 -7f86c4be8740: created capset 1 of type 3 -7f86c4be8740: cap 0: initialised -7f86c4be8740: assigned cap 0 to capset 0 -7f86c4be8740: assigned cap 0 to capset 1 -7f86c4be8740: cap 0: created thread 1[""] -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 1[""] stopped (stack overflow, size 109) -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: created thread 2[""] -7f86c4be8740: cap 0: thread 2 has label IOManager on cap 0 -7f86c4be8740: cap 0: thread 1[""] stopped (yielding) -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (yielding) -7f86c4be8740: cap 0: running thread 1[""] (ThreadRunGHC) -7f86c4be8740: cap 0: created thread 3[""] -7f86c4be8740: cap 0: thread 3 has label TimerManager -7f86c4be8740: cap 0: thread 1[""] stopped (finished) -7f86c4be8740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f86c4be8740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f86c4be8740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f86c4be8740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f86c4be8740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f86c4be8740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f86c4be8740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f86c4be8740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f86c4be8740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f86c4be8740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f86c4be8740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, module module_009, srcloc src_file_009:src_span_009 -7f86c4be8740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, module module_008, srcloc src_file_008:src_span_008 -7f86c4be8740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, module module_007, srcloc src_file_007:src_span_007 -7f86c4be8740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, module module_006, srcloc src_file_006:src_span_006 -7f86c4be8740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, module module_005, srcloc src_file_005:src_span_005 -7f86c4be8740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, module module_004, srcloc src_file_004:src_span_004 -7f86c4be8740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, module module_003, srcloc src_file_003:src_span_003 -7f86c4be8740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, module module_002, srcloc src_file_002:src_span_002 -7f86c4be8740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, module module_001, srcloc src_file_001:src_span_001 -7f86c4be8740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, module module_000, srcloc src_file_000:src_span_000 -7f86c4be8740: cap 0: created thread 4[""] -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (suspended while making a foreign call) -7f86b5ffb640: cap 0: running thread 3["TimerManager"] (ThreadRunGHC) -7f86b5ffb640: cap 0: thread 3["TimerManager"] stopped (suspended while making a foreign call) -7f86c4be8740: cap 0: running thread 4[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 4[""] stopped (yielding) -7f86c4be8740: cap 0: running thread 4[""] (ThreadRunGHC) -7f86c4be8740: cap 0: thread 4[""] stopped (finished) -7f86b57fa640: cap 0: requesting sequential GC -7f86b57fa640: cap 0: starting GC -7f86b57fa640: cap 0: GC working -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: GC idle -7f86b57fa640: cap 0: GC done -7f86b57fa640: cap 0: Memory Return (Current: 6) (Needed: 8) (Returned: 0) -7f86b57fa640: cap 0: all caps stopped for GC -7f86b57fa640: cap 0: finished GC -7f86b5ffb640: cap 0: running thread 3["TimerManager"] (ThreadRunGHC) -7f86b5ffb640: cap 0: thread 3["TimerManager"] stopped (finished) -7f86b67fc640: cap 0: running thread 2["IOManager on cap 0"] (ThreadRunGHC) -7f86b67fc640: cap 0: thread 2["IOManager on cap 0"] stopped (finished) -7f86c4be8740: removed cap 0 from capset 0 -7f86c4be8740: removed cap 0 from capset 1 -7f86c4be8740: cap 0: shutting down -7f86c4be8740: deleted capset 0 -7f86c4be8740: deleted capset 1 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 +7ffff7a4d740: IPE: table_name table_name_009, closure_desc closure_desc_009, ty_desc ty_desc_009, label label_009, unit unit_id_000, module module_000, srcloc src_file_009:src_span_009 +7ffff7a4d740: IPE: table_name table_name_008, closure_desc closure_desc_008, ty_desc ty_desc_008, label label_008, unit unit_id_000, module module_000, srcloc src_file_008:src_span_008 +7ffff7a4d740: IPE: table_name table_name_007, closure_desc closure_desc_007, ty_desc ty_desc_007, label label_007, unit unit_id_000, module module_000, srcloc src_file_007:src_span_007 +7ffff7a4d740: IPE: table_name table_name_006, closure_desc closure_desc_006, ty_desc ty_desc_006, label label_006, unit unit_id_000, module module_000, srcloc src_file_006:src_span_006 +7ffff7a4d740: IPE: table_name table_name_005, closure_desc closure_desc_005, ty_desc ty_desc_005, label label_005, unit unit_id_000, module module_000, srcloc src_file_005:src_span_005 +7ffff7a4d740: IPE: table_name table_name_004, closure_desc closure_desc_004, ty_desc ty_desc_004, label label_004, unit unit_id_000, module module_000, srcloc src_file_004:src_span_004 +7ffff7a4d740: IPE: table_name table_name_003, closure_desc closure_desc_003, ty_desc ty_desc_003, label label_003, unit unit_id_000, module module_000, srcloc src_file_003:src_span_003 +7ffff7a4d740: IPE: table_name table_name_002, closure_desc closure_desc_002, ty_desc ty_desc_002, label label_002, unit unit_id_000, module module_000, srcloc src_file_002:src_span_002 +7ffff7a4d740: IPE: table_name table_name_001, closure_desc closure_desc_001, ty_desc ty_desc_001, label label_001, unit unit_id_000, module module_000, srcloc src_file_001:src_span_001 +7ffff7a4d740: IPE: table_name table_name_000, closure_desc closure_desc_000, ty_desc ty_desc_000, label label_000, unit unit_id_000, module module_000, srcloc src_file_000:src_span_000 ===================================== testsuite/tests/rts/ipe/ipeMap.c ===================================== @@ -28,14 +28,19 @@ int main(int argc, char *argv[]) { hs_exit(); } +static InfoProvEnt lookupIPE_(const char *where, const StgInfoTable *itbl) { + InfoProvEnt ent; + if (!lookupIPE(itbl, &ent)) { + barf("%s: Expected to find IPE entry", where); + } + return ent; +} + void shouldFindNothingInAnEmptyIPEMap(Capability *cap) { HaskellObj fortyTwo = UNTAG_CLOSURE(rts_mkInt(cap, 42)); - - InfoProvEnt *result = lookupIPE(get_itbl(fortyTwo)); - - if (result != NULL) { - errorBelch("Found entry in an empty IPE map!"); - exit(1); + InfoProvEnt ent; + if (lookupIPE(get_itbl(fortyTwo), &ent)) { + barf("Found entry in an empty IPE map!"); } } @@ -48,6 +53,9 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { StringTable st; init_string_table(&st); + node->unit_id = add_string(&st, "unit-id"); + node->module_name = add_string(&st, "TheModule"); + HaskellObj fortyTwo = UNTAG_CLOSURE(rts_mkInt(cap, 42)); node->next = NULL; node->compressed = 0; @@ -60,20 +68,16 @@ HaskellObj shouldFindOneIfItHasBeenRegistered(Capability *cap) { registerInfoProvList(node); - InfoProvEnt *result = lookupIPE(get_itbl(fortyTwo)); + InfoProvEnt result = lookupIPE_("shouldFindOneIfItHasBeenRegistered", get_itbl(fortyTwo)); - if (result == NULL) { - errorBelch("shouldFindOneIfItHasBeenRegistered: Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(result->prov.table_name, "table_name_042"); - assertStringsEqual(result->prov.closure_desc, "closure_desc_042"); - assertStringsEqual(result->prov.ty_desc, "ty_desc_042"); - assertStringsEqual(result->prov.label, "label_042"); - assertStringsEqual(result->prov.module, "module_042"); - assertStringsEqual(result->prov.src_file, "src_file_042"); - assertStringsEqual(result->prov.src_span, "src_span_042"); + assertStringsEqual(result.prov.table_name, "table_name_042"); + assertStringsEqual(result.prov.closure_desc, "closure_desc_042"); + assertStringsEqual(result.prov.ty_desc, "ty_desc_042"); + assertStringsEqual(result.prov.label, "label_042"); + assertStringsEqual(result.prov.unit_id, "unit-id"); + assertStringsEqual(result.prov.module, "TheModule"); + assertStringsEqual(result.prov.src_file, "src_file_042"); + assertStringsEqual(result.prov.src_span, "src_span_042"); return fortyTwo; } @@ -88,6 +92,9 @@ void shouldFindTwoIfTwoHaveBeenRegistered(Capability *cap, StringTable st; init_string_table(&st); + node->unit_id = add_string(&st, "unit-id"); + node->module_name = add_string(&st, "TheModule"); + HaskellObj twentyThree = UNTAG_CLOSURE(rts_mkInt8(cap, 23)); node->next = NULL; node->compressed = 0; @@ -100,22 +107,11 @@ void shouldFindTwoIfTwoHaveBeenRegistered(Capability *cap, registerInfoProvList(node); - InfoProvEnt *resultFortyTwo = - lookupIPE(get_itbl(fortyTwo)); - InfoProvEnt *resultTwentyThree = - lookupIPE(get_itbl(twentyThree)); + InfoProvEnt resultFortyTwo = lookupIPE_("shouldFindTwoIfTwoHaveBeenRegistered", get_itbl(fortyTwo)); + assertStringsEqual(resultFortyTwo.prov.table_name, "table_name_042"); - if (resultFortyTwo == NULL) { - errorBelch("shouldFindTwoIfTwoHaveBeenRegistered(42): Found no entry in IPE map!"); - exit(1); - } - if (resultTwentyThree == NULL) { - errorBelch("shouldFindTwoIfTwoHaveBeenRegistered(23): Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(resultFortyTwo->prov.table_name, "table_name_042"); - assertStringsEqual(resultTwentyThree->prov.table_name, "table_name_023"); + InfoProvEnt resultTwentyThree = lookupIPE_("shouldFindTwoIfTwoHaveBeenRegistered", get_itbl(twentyThree)); + assertStringsEqual(resultTwentyThree.prov.table_name, "table_name_023"); } void shouldFindTwoFromTheSameList(Capability *cap) { @@ -142,20 +138,11 @@ void shouldFindTwoFromTheSameList(Capability *cap) { registerInfoProvList(node); - InfoProvEnt *resultOne = lookupIPE(get_itbl(one)); - InfoProvEnt *resultTwo = lookupIPE(get_itbl(two)); - - if (resultOne == NULL) { - errorBelch("shouldFindTwoFromTheSameList(1): Found no entry in IPE map!"); - exit(1); - } - if (resultTwo == NULL) { - errorBelch("shouldFindTwoFromTheSameList(2): Found no entry in IPE map!"); - exit(1); - } + InfoProvEnt resultOne = lookupIPE_("shouldFindTwoFromTheSameList", get_itbl(one)); + assertStringsEqual(resultOne.prov.table_name, "table_name_001"); - assertStringsEqual(resultOne->prov.table_name, "table_name_001"); - assertStringsEqual(resultTwo->prov.table_name, "table_name_002"); + InfoProvEnt resultTwo = lookupIPE_("shouldFindTwoFromTheSameList", get_itbl(two)); + assertStringsEqual(resultTwo.prov.table_name, "table_name_002"); } void shouldDealWithAnEmptyList(Capability *cap, HaskellObj fortyTwo) { @@ -166,15 +153,8 @@ void shouldDealWithAnEmptyList(Capability *cap, HaskellObj fortyTwo) { registerInfoProvList(node); - InfoProvEnt *resultFortyTwo = - lookupIPE(get_itbl(fortyTwo)); - - if (resultFortyTwo == NULL) { - errorBelch("shouldDealWithAnEmptyList: Found no entry in IPE map!"); - exit(1); - } - - assertStringsEqual(resultFortyTwo->prov.table_name, "table_name_042"); + InfoProvEnt resultFortyTwo = lookupIPE_("shouldDealWithAnEmptyList", get_itbl(fortyTwo)); + assertStringsEqual(resultFortyTwo.prov.table_name, "table_name_042"); } void assertStringsEqual(const char *s1, const char *s2) { ===================================== testsuite/tests/rts/ipe/ipe_lib.c ===================================== @@ -48,11 +48,6 @@ IpeBufferEntry makeAnyProvEntry(Capability *cap, StringTable *st, int i) { snprintf(label, labelLength, "label_%03i", i); provEnt.label = add_string(st, label); - unsigned int moduleLength = strlen("module_") + 3 /* digits */ + 1 /* null character */; - char *module = malloc(sizeof(char) * moduleLength); - snprintf(module, moduleLength, "module_%03i", i); - provEnt.module_name = add_string(st, module); - unsigned int srcFileLength = strlen("src_file_") + 3 /* digits */ + 1 /* null character */; char *srcFile = malloc(sizeof(char) * srcFileLength); snprintf(srcFile, srcFileLength, "src_file_%03i", i); @@ -77,6 +72,16 @@ IpeBufferListNode *makeAnyProvEntries(Capability *cap, int start, int end) { StringTable st; init_string_table(&st); + unsigned int unitIdLength = strlen("unit_id_") + 3 /* digits */ + 1 /* null character */; + char *unitId = malloc(sizeof(char) * unitIdLength); + snprintf(unitId, unitIdLength, "unit_id_%03i", start); + node->unit_id = add_string(&st, unitId); + + unsigned int moduleLength = strlen("module_") + 3 /* digits */ + 1 /* null character */; + char *module = malloc(sizeof(char) * moduleLength); + snprintf(module, moduleLength, "module_%03i", start); + node->module_name = add_string(&st, module); + // Make the entries and fill the buffers for (int i=start; i < end; i++) { HaskellObj closure = rts_mkInt(cap, 42); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae45d71da82cb7e0ae9be264e06d23b26c2cb435...9f3eb25215bd7f509b6b8c198b3dcb73fe35e881 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae45d71da82cb7e0ae9be264e06d23b26c2cb435...9f3eb25215bd7f509b6b8c198b3dcb73fe35e881 You're receiving 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 Nov 16 20:16:22 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 16 Nov 2023 15:16:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/asan Message-ID: <6556789647f62_d535ce2d5e5c15123@gitlab.mail> Ben Gamari pushed new branch wip/asan at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/asan You're receiving 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 Nov 16 22:00:57 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 16 Nov 2023 17:00:57 -0500 Subject: [Git][ghc/ghc][wip/az/epa-noann-not-monoid] EPA: Replace Monoid with NoAnn Message-ID: <655691191ba0a_d535c10c6ce3c15537@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-noann-not-monoid at Glasgow Haskell Compiler / GHC Commits: 0f63b876 by Alan Zimmerman at 2023-11-16T22:00:03+00:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 2 changed files: - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f63b876652bc0a05d925c22873159014554fcfe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f63b876652bc0a05d925c22873159014554fcfe You're receiving 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 Nov 16 23:00:39 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 16 Nov 2023 18:00:39 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 28 commits: EPA: get rid of AnchorOperation Message-ID: <65569f17176b7_d535c11f0d4ec17076a@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - cff55a4b by Alan Zimmerman at 2023-11-16T19:57:31+00:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. - - - - - 14d57374 by Alan Zimmerman at 2023-11-16T21:16:26+00:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - 0a25b51f by Alan Zimmerman at 2023-11-16T21:16:33+00:00 EPA: Present no longer has annotation - - - - - c269b3fe by Alan Zimmerman at 2023-11-16T21:16:33+00:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 071d8e10 by Alan Zimmerman at 2023-11-16T21:16:33+00:00 EPA: Remove parenthesizeHsType - - - - - 4c3a8937 by Alan Zimmerman at 2023-11-16T21:16:33+00:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - 04e1427b by Alan Zimmerman at 2023-11-16T21:16:34+00:00 EPA: Remove SrcSpanAnn [2023-10-12 Thu] Failures HsDocTy T15242 - - - - - 9b3a7bda by Alan Zimmerman at 2023-11-16T21:16:34+00:00 EPA: Remove SrcSpanAnn completely - - - - - 6f02e0b3 by Alan Zimmerman at 2023-11-16T21:16:34+00:00 Clean up mkScope - - - - - fa3bd7b0 by Alan Zimmerman at 2023-11-16T21:16:34+00:00 EPA: Clean up TC Monad Utils - - - - - 2ecf3957 by Alan Zimmerman at 2023-11-16T21:16:34+00:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - 36439c0d by Alan Zimmerman at 2023-11-16T21:16:35+00:00 Semigroup instances for AnnList and AnnContext - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Parser/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d62bfc30467db227ba0849b46828f4c5dddde4bc...36439c0d4504b61864117d8c1d39781306e148ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d62bfc30467db227ba0849b46828f4c5dddde4bc...36439c0d4504b61864117d8c1d39781306e148ba You're receiving 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 Nov 16 23:02:39 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 18:02:39 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix unusable units and module reexport interaction (#21097) Message-ID: <65569f8fcf40b_d535c1217c3a418085@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 5aa02dc4 by Andreas Klebinger at 2023-11-16T18:01:52-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - 4353ce25 by James Henri Haydon at 2023-11-16T18:01:56-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - d2b862b0 by Ignat Insarov at 2023-11-16T18:02:02-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 91d1c2fa by Andrew Lelechenko at 2023-11-16T18:02:02-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 3c1959b3 by Oleg Alexander at 2023-11-16T18:02:05-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 30 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/State.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - libraries/base/changelog.md - libraries/base/src/Data/Functor/Compose.hs - libraries/base/src/Data/List/NonEmpty.hs - libraries/base/src/Debug/Trace.hs - + testsuite/tests/driver/T21097/Makefile - + testsuite/tests/driver/T21097/T21097.stderr - + testsuite/tests/driver/T21097/Test.hs - + testsuite/tests/driver/T21097/all.T - + testsuite/tests/driver/T21097/pkgdb/a.conf - + testsuite/tests/driver/T21097/pkgdb/b.conf - + testsuite/tests/driver/T21097/pkgdb/c.conf - + testsuite/tests/driver/T21097b/Makefile - + testsuite/tests/driver/T21097b/T21097b.stdout - + testsuite/tests/driver/T21097b/Test.hs - + testsuite/tests/driver/T21097b/all.T - + testsuite/tests/driver/T21097b/pkgdb/a.conf - + testsuite/tests/driver/T21097b/pkgdb/b.conf - + testsuite/tests/driver/T21097b/pkgdb/c.conf - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/17924162f6d59ba32b22871b2abad7985d75e3b4...3c1959b3850452547aa59ced8d94c32121c77d37 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/17924162f6d59ba32b22871b2abad7985d75e3b4...3c1959b3850452547aa59ced8d94c32121c77d37 You're receiving 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 Nov 16 23:38:48 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Thu, 16 Nov 2023 18:38:48 -0500 Subject: [Git][ghc/ghc][wip/unify-hpc-testsuites] Adjust Makefiles in testsuite/tests/hpc/* Message-ID: <6556a808922a7_d535c1321f97c1812e0@gitlab.mail> BinderDavid pushed to branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC Commits: 17c48e24 by David Binder at 2023-11-17T00:38:25+01:00 Adjust Makefiles in testsuite/tests/hpc/* The paths configured in these Makefiles were relative to the old location of the tests in libraries/hpc/tests. This Commit adjusts them to the new location in testsuite/tests/hpc. - - - - - 15 changed files: - testsuite/tests/hpc/fork/Makefile - testsuite/tests/hpc/function/Makefile - testsuite/tests/hpc/function2/Makefile - testsuite/tests/hpc/ghc_ghci/Makefile - testsuite/tests/hpc/raytrace/Makefile - + testsuite/tests/hpc/raytrace/tixs/.hpc/CSG.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Construct.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Data.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Eval.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Geometry.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Illumination.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Intersections.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Interval.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Main.mix - + testsuite/tests/hpc/raytrace/tixs/.hpc/Misc.mix The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17c48e245e1fdc5b5292bcf25f05bef5f24acc98 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17c48e245e1fdc5b5292bcf25f05bef5f24acc98 You're receiving 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 Nov 17 01:52:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 20:52:42 -0500 Subject: [Git][ghc/ghc][master] Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <6556c76a44e9d_d535c167661e41877d6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - 7 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -128,8 +128,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1679,9 +1679,39 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + BoxedRep{} -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -67,7 +67,7 @@ import GHC.Core.DataCon import GHC.Types.Literal import GHC.Types.SourceText -import GHC.Types.RepType ( countFunRepArgs ) +import GHC.Types.RepType ( countFunRepArgs, typePrimRep ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env @@ -1517,16 +1517,29 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + && is_small_rep) -- See Note [Unpack one-wide fields] where (rep_tys, _) = dataConArgUnpack arg_ty + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + + -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons -- iff ty is of the form @@ -1585,6 +1598,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -488,6 +488,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f5264bbebfa1c30ecbcdd9590c9bb76ac58d53 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f5264bbebfa1c30ecbcdd9590c9bb76ac58d53 You're receiving 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 Nov 17 01:53:18 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 20:53:18 -0500 Subject: [Git][ghc/ghc][master] Explicit methods for Alternative Compose Message-ID: <6556c78df26cf_d535c16769470191580@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 2 changed files: - libraries/base/changelog.md - libraries/base/src/Data/Functor/Compose.hs Changes: ===================================== libraries/base/changelog.md ===================================== @@ -11,6 +11,7 @@ * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) * The functions `GHC.Exts.dataToTag#` and `GHC.Base.getTag` have had their types changed to the following: ===================================== libraries/base/src/Data/Functor/Compose.hs ===================================== @@ -147,6 +147,10 @@ instance (Alternative f, Applicative g) => Alternative (Compose f g) where empty = Compose empty (<|>) = coerce ((<|>) :: f (g a) -> f (g a) -> f (g a)) :: forall a . Compose f g a -> Compose f g a -> Compose f g a + some = coerce (fmap sequenceA . some :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] + many = coerce (fmap sequenceA . many :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] -- | The deduction (via generativity) that if @g x :~: g y@ then @x :~: y at . -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4f84e4bfac3648864d9482b7585a01d44b5eb58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4f84e4bfac3648864d9482b7585a01d44b5eb58 You're receiving 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 Nov 17 01:54:05 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 20:54:05 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Add permutations for non-empty lists. Message-ID: <6556c7bdbc520_d535c1676947019488@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 6 changed files: - libraries/base/changelog.md - libraries/base/src/Data/List/NonEmpty.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -2,6 +2,7 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) + * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -78,6 +78,8 @@ module Data.List.NonEmpty ( , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) + , permutations + , permutations1 -- * Sublist predicates , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool -- * \"Set\" operations @@ -441,6 +443,30 @@ groupWith1 f = groupBy1 ((==) `on` f) groupAllWith1 :: (Ord b) => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) groupAllWith1 f = groupWith1 f . sortWith f +-- | The 'permutations' function returns the list of all permutations of the argument. +-- +-- @since 4.20.0.0 +permutations :: [a] -> NonEmpty [a] +permutations xs0 = xs0 :| perms xs0 [] + where + perms [] _ = [] + perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) + where interleave xs r = let (_,zs) = interleave' id xs r in zs + interleave' _ [] r = (ts, r) + interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r + in (y:us, f (t:y:us) : zs) +-- The implementation of 'permutations' is adopted from 'Data.List.permutations', +-- see there for discussion and explanations. + +-- | 'permutations1' operates like 'permutations', but uses the knowledge that its input is +-- non-empty to produce output where every element is non-empty. +-- +-- > permutations1 = fmap fromList . permutations . toList +-- +-- @since 4.20.0.0 +permutations1 :: NonEmpty a -> NonEmpty (NonEmpty a) +permutations1 xs = fromList <$> permutations (toList xs) + -- | The 'isPrefixOf' function returns 'True' if the first argument is -- a prefix of the second. isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4f84e4bfac3648864d9482b7585a01d44b5eb58...5643ecf97150805032203bd9c8c92b5ded54d724 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4f84e4bfac3648864d9482b7585a01d44b5eb58...5643ecf97150805032203bd9c8c92b5ded54d724 You're receiving 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 Nov 17 01:54:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 16 Nov 2023 20:54:54 -0500 Subject: [Git][ghc/ghc][master] Update doc string for traceShow Message-ID: <6556c7ee96cbb_d535c1676947019833e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 1 changed file: - libraries/base/src/Debug/Trace.hs Changes: ===================================== libraries/base/src/Debug/Trace.hs ===================================== @@ -143,13 +143,15 @@ traceId a = trace a a Like 'trace', but uses 'show' on the argument to convert it to a 'String'. This makes it convenient for printing the values of interesting variables or -expressions inside a function. For example here we print the value of the +expressions inside a function. For example, here we print the values of the variables @x@ and @y@: ->>> let f x y = traceShow (x,y) (x + y) in f (1+2) 5 -(3,5) +>>> let f x y = traceShow ("x", x, "y", y) (x + y) in f (1+2) 5 +("x",3,"y",5) 8 +Note in this example we also create simple labels just by including some strings. + -} traceShow :: Show a => a -> b -> b traceShow = trace . show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94ff2134c52f5c1bcc0e5f20c5f760a755c24459 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94ff2134c52f5c1bcc0e5f20c5f760a755c24459 You're receiving 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 Nov 17 11:56:01 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 17 Nov 2023 06:56:01 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_x86] Fix FMA primops generating broken assembly on x86. Message-ID: <655754d185626_d535c2518f59027511b@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/fma_x86 at Glasgow Haskell Compiler / GHC Commits: 97d0cf9c by Andreas Klebinger at 2023-11-17T12:55:39+01:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 4 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/primops/should_compile/T24160_FMA.hs - testsuite/tests/primops/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3448,32 +3448,9 @@ genFMA3Code w signs x y z = do (y_reg, y_code) <- getNonClobberedReg y (z_reg, z_code) <- getNonClobberedReg z x_code <- getAnyReg x - y_tmp <- getNewRegNat rep - z_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 - code dst - | dst == y_reg - , dst == z_reg - = y_code `appOL` - unitOL (MOV rep (OpReg y_reg) (OpReg y_tmp)) `appOL` - z_code `appOL` - unitOL (MOV rep (OpReg z_reg) (OpReg z_tmp)) `appOL` - x_code dst `snocOL` - fma213 (OpReg z_tmp) y_tmp dst - | dst == y_reg - = y_code `appOL` - unitOL (MOV rep (OpReg y_reg) (OpReg z_tmp)) `appOL` - z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_tmp dst - | dst == z_reg - = y_code `appOL` - z_code `appOL` - unitOL (MOV rep (OpReg z_reg) (OpReg z_tmp)) `appOL` - x_code dst `snocOL` - fma213 (OpReg z_tmp) y_reg dst - | otherwise + code dst -- dst == x argument = y_code `appOL` z_code `appOL` x_code dst `snocOL` ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -277,7 +277,8 @@ data Instr -- | FMA3 fused multiply-add operations. | FMA3 Format FMASign FMAPermutation Operand Reg Reg - -- src1 (r/m), src2 (r), dst (r) + -- src3 (r/m), src2 (r), dst/src1 (r) + -- The is exactly reversed from how intel lists the arguments. -- use ADD, SUB, and SQRT for arithmetic. In both cases, operands -- are Operand Reg. @@ -358,6 +359,7 @@ data Operand | OpImm Imm -- immediate value | OpAddr AddrMode -- memory reference +-- NB: As of 2023 we only use the FMA213 permutation. data FMAPermutation = FMA132 | FMA213 | FMA231 -- | Returns which registers are read and written as a (read, written) @@ -447,7 +449,7 @@ regUsageOfInstr platform instr PDEP _ src mask dst -> mkRU (use_R src $ use_R mask []) [dst] PEXT _ src mask dst -> mkRU (use_R src $ use_R mask []) [dst] - FMA3 _ _ _ src1 src2 dst -> usageFMA src1 src2 dst + FMA3 _ _ _ src3 src2 dst -> usageFMA src3 src2 dst -- note: might be a better way to do this PREFETCH _ _ src -> mkRU (use_R src []) [] ===================================== testsuite/tests/primops/should_compile/T24160_FMA.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +module TwoProdFMA where +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) ===================================== testsuite/tests/primops/should_compile/all.T ===================================== @@ -8,3 +8,8 @@ test('UnliftedStableName', normal, compile, ['']) test('KeepAliveWrapper', normal, compile, ['-O']) test('T22152', normal, compile, ['']) test('T22152b', normal, compile, ['']) +test('T24160_FMA' + , [ js_skip # JS backend doesn't have an FMA implementation ] + # , omit_ghci # fails during compilation phase, remove after !10563 + ] + , compile, ['-O']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97d0cf9c88ddd02c779e83786adcbef4d5dd78fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97d0cf9c88ddd02c779e83786adcbef4d5dd78fe You're receiving 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 Nov 17 11:56:57 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 17 Nov 2023 06:56:57 -0500 Subject: [Git][ghc/ghc][wip/andreask/fma_x86] Fix FMA primops generating broken assembly on x86. Message-ID: <65575509c4d17_d535c2538e3b4277458@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/fma_x86 at Glasgow Haskell Compiler / GHC Commits: 3b259e17 by Andreas Klebinger at 2023-11-17T12:56:43+01:00 Fix FMA primops generating broken assembly on x86. `genFMA3Code` assumed that we had to take extra precations to avoid overwriting the result of `getNonClobberedReg`. One of these special cases caused a bug resulting in broken assembly. I believe we don't need to hadle these cases specially at all, which means this MR simply deletes the special cases to fix the bug. Fixes #24160 - - - - - 4 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - + testsuite/tests/primops/should_compile/T24160_FMA.hs - testsuite/tests/primops/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -3448,32 +3448,9 @@ genFMA3Code w signs x y z = do (y_reg, y_code) <- getNonClobberedReg y (z_reg, z_code) <- getNonClobberedReg z x_code <- getAnyReg x - y_tmp <- getNewRegNat rep - z_tmp <- getNewRegNat rep let fma213 = FMA3 rep signs FMA213 code dst - | dst == y_reg - , dst == z_reg - = y_code `appOL` - unitOL (MOV rep (OpReg y_reg) (OpReg y_tmp)) `appOL` - z_code `appOL` - unitOL (MOV rep (OpReg z_reg) (OpReg z_tmp)) `appOL` - x_code dst `snocOL` - fma213 (OpReg z_tmp) y_tmp dst - | dst == y_reg - = y_code `appOL` - unitOL (MOV rep (OpReg y_reg) (OpReg z_tmp)) `appOL` - z_code `appOL` - x_code dst `snocOL` - fma213 (OpReg z_reg) y_tmp dst - | dst == z_reg - = y_code `appOL` - z_code `appOL` - unitOL (MOV rep (OpReg z_reg) (OpReg z_tmp)) `appOL` - x_code dst `snocOL` - fma213 (OpReg z_tmp) y_reg dst - | otherwise = y_code `appOL` z_code `appOL` x_code dst `snocOL` ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -277,7 +277,8 @@ data Instr -- | FMA3 fused multiply-add operations. | FMA3 Format FMASign FMAPermutation Operand Reg Reg - -- src1 (r/m), src2 (r), dst (r) + -- src3 (r/m), src2 (r), dst/src1 (r) + -- The is exactly reversed from how intel lists the arguments. -- use ADD, SUB, and SQRT for arithmetic. In both cases, operands -- are Operand Reg. @@ -358,6 +359,7 @@ data Operand | OpImm Imm -- immediate value | OpAddr AddrMode -- memory reference +-- NB: As of 2023 we only use the FMA213 permutation. data FMAPermutation = FMA132 | FMA213 | FMA231 -- | Returns which registers are read and written as a (read, written) @@ -447,7 +449,7 @@ regUsageOfInstr platform instr PDEP _ src mask dst -> mkRU (use_R src $ use_R mask []) [dst] PEXT _ src mask dst -> mkRU (use_R src $ use_R mask []) [dst] - FMA3 _ _ _ src1 src2 dst -> usageFMA src1 src2 dst + FMA3 _ _ _ src3 src2 dst -> usageFMA src3 src2 dst -- note: might be a better way to do this PREFETCH _ _ src -> mkRU (use_R src []) [] ===================================== testsuite/tests/primops/should_compile/T24160_FMA.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +module TwoProdFMA where +import GHC.Exts + +twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #) +twoProductFloat# x y = let !r = x `timesFloat#` y + in (# r, fmsubFloat# x y r #) ===================================== testsuite/tests/primops/should_compile/all.T ===================================== @@ -8,3 +8,8 @@ test('UnliftedStableName', normal, compile, ['']) test('KeepAliveWrapper', normal, compile, ['-O']) test('T22152', normal, compile, ['']) test('T22152b', normal, compile, ['']) +test('T24160_FMA' + , [ js_skip # JS backend doesn't have an FMA implementation ] + # , omit_ghci # fails during compilation phase, remove after !10563 + ] + , compile, ['-O']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b259e17b6aface99be80a34c17e7a2c92fc89b0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b259e17b6aface99be80a34c17e7a2c92fc89b0 You're receiving 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 Nov 17 12:36:22 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 17 Nov 2023 07:36:22 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] 6 commits: Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <65575e4672208_d535c265d138c284996@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 94021d18 by Matthew Pickering at 2023-11-17T12:36:03+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 23 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - libraries/base/changelog.md - libraries/base/src/Data/Functor/Compose.hs - libraries/base/src/Data/List/NonEmpty.hs - libraries/base/src/Debug/Trace.hs - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -128,8 +128,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1679,9 +1679,39 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + BoxedRep{} -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -67,7 +67,7 @@ import GHC.Core.DataCon import GHC.Types.Literal import GHC.Types.SourceText -import GHC.Types.RepType ( countFunRepArgs ) +import GHC.Types.RepType ( countFunRepArgs, typePrimRep ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env @@ -1517,16 +1517,29 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + && is_small_rep) -- See Note [Unpack one-wide fields] where (rep_tys, _) = dataConArgUnpack arg_ty + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + + -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons -- iff ty is of the form @@ -1585,6 +1598,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== libraries/base/changelog.md ===================================== @@ -2,6 +2,7 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) + * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). @@ -11,6 +12,7 @@ * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) * The functions `GHC.Exts.dataToTag#` and `GHC.Base.getTag` have had their types changed to the following: ===================================== libraries/base/src/Data/Functor/Compose.hs ===================================== @@ -147,6 +147,10 @@ instance (Alternative f, Applicative g) => Alternative (Compose f g) where empty = Compose empty (<|>) = coerce ((<|>) :: f (g a) -> f (g a) -> f (g a)) :: forall a . Compose f g a -> Compose f g a -> Compose f g a + some = coerce (fmap sequenceA . some :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] + many = coerce (fmap sequenceA . many :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] -- | The deduction (via generativity) that if @g x :~: g y@ then @x :~: y at . -- ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -78,6 +78,8 @@ module Data.List.NonEmpty ( , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) + , permutations + , permutations1 -- * Sublist predicates , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool -- * \"Set\" operations @@ -441,6 +443,30 @@ groupWith1 f = groupBy1 ((==) `on` f) groupAllWith1 :: (Ord b) => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) groupAllWith1 f = groupWith1 f . sortWith f +-- | The 'permutations' function returns the list of all permutations of the argument. +-- +-- @since 4.20.0.0 +permutations :: [a] -> NonEmpty [a] +permutations xs0 = xs0 :| perms xs0 [] + where + perms [] _ = [] + perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) + where interleave xs r = let (_,zs) = interleave' id xs r in zs + interleave' _ [] r = (ts, r) + interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r + in (y:us, f (t:y:us) : zs) +-- The implementation of 'permutations' is adopted from 'Data.List.permutations', +-- see there for discussion and explanations. + +-- | 'permutations1' operates like 'permutations', but uses the knowledge that its input is +-- non-empty to produce output where every element is non-empty. +-- +-- > permutations1 = fmap fromList . permutations . toList +-- +-- @since 4.20.0.0 +permutations1 :: NonEmpty a -> NonEmpty (NonEmpty a) +permutations1 xs = fromList <$> permutations (toList xs) + -- | The 'isPrefixOf' function returns 'True' if the first argument is -- a prefix of the second. isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool ===================================== libraries/base/src/Debug/Trace.hs ===================================== @@ -143,13 +143,15 @@ traceId a = trace a a Like 'trace', but uses 'show' on the argument to convert it to a 'String'. This makes it convenient for printing the values of interesting variables or -expressions inside a function. For example here we print the value of the +expressions inside a function. For example, here we print the values of the variables @x@ and @y@: ->>> let f x y = traceShow (x,y) (x + y) in f (1+2) 5 -(3,5) +>>> let f x y = traceShow ("x", x, "y", y) (x + y) in f (1+2) 5 +("x",3,"y",5) 8 +Note in this example we also create simple labels just by including some strings. + -} traceShow :: Show a => a -> b -> b traceShow = trace . show ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test: Dict = {} # Dict + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -625,6 +667,9 @@ def collect_compiler_stats(metric='all',deviation=20): def collect_stats(metric='all', deviation=20): return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def statsFile(comp_test: bool, name: str) -> str: + return name + ('.comp' if comp_test else '') + '.stats' + # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. # If the boolean is set to true, it indicates that this test is one that @@ -664,15 +709,35 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: + def action_generator(mn): + return lambda way: read_stats_file(way, mn) metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": action_generator(metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1646,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1787,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - async def static_stats( name, way, stats_file ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_test) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1799,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1912,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1962,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +1998,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2044,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -488,6 +488,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f51e88d1641ea9f9e276e15c70ffcbfdc4beef84...94021d18fbaef1b3ae984fe6d8c4bcb9de63adcf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f51e88d1641ea9f9e276e15c70ffcbfdc4beef84...94021d18fbaef1b3ae984fe6d8c4bcb9de63adcf You're receiving 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 Nov 17 13:48:09 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Fri, 17 Nov 2023 08:48:09 -0500 Subject: [Git][ghc/ghc][wip/unify-hpc-testsuites] Add missing tix files Message-ID: <65576f19766cf_d535c2828e42029723a@gitlab.mail> BinderDavid pushed to branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC Commits: de06791e by David Binder at 2023-11-17T14:47:57+01:00 Add missing tix files - - - - - 3 changed files: - + testsuite/tests/hpc/simple/tixs/hpc_sample_incompatible_hash.tix - + testsuite/tests/hpc/simple/tixs/hpc_sample_no_parse.tix - + testsuite/tests/hpc/simple/tixs/hpc_sample_non_existing_module.tix Changes: ===================================== testsuite/tests/hpc/simple/tixs/hpc_sample_incompatible_hash.tix ===================================== @@ -0,0 +1 @@ +Tix [ TixModule "Main" 1234567890 5 [1,0,1,1,1]] ===================================== testsuite/tests/hpc/simple/tixs/hpc_sample_no_parse.tix ===================================== @@ -0,0 +1 @@ +Tix [ TixModule "NoParse" 2454134535 5 [1,0,1,1,1]] ===================================== testsuite/tests/hpc/simple/tixs/hpc_sample_non_existing_module.tix ===================================== @@ -0,0 +1 @@ +Tix [ TixModule "NonExistingModule" 2454134535 5 [1,0,1,1,1]] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de06791e9354c677d5f6cce59c50e47a125351ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de06791e9354c677d5f6cce59c50e47a125351ff You're receiving 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 Nov 17 15:27:34 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Fri, 17 Nov 2023 10:27:34 -0500 Subject: [Git][ghc/ghc][wip/unify-hpc-testsuites] Fix Makefile Message-ID: <65578666d92e9_d535c2a6fd18030521c@gitlab.mail> BinderDavid pushed to branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC Commits: 448671a7 by David Binder at 2023-11-17T16:27:26+01:00 Fix Makefile - - - - - 1 changed file: - testsuite/tests/hpc/Makefile Changes: ===================================== testsuite/tests/hpc/Makefile ===================================== @@ -18,36 +18,3 @@ T17073: T20568: "$(TEST_HC)" $(TEST_HC_ARGS) T20568.hs -fhpc -v0 ./T20568 - -# -# This is measuring coverage of the hpc tool itself. -# In the hpc directory -# % cd $ROOT/utils/hpc -# It assumes you have make a copy of hpc that -# is not compiled with -fhpc, and called it hpc-std -# % make clean ; make boot ; make ; mv hpc-inplace hpc-std -# It assumes that the utils/hpc has been compiled with -# % make clean ; make boot ; make UseStage1=YES EXTRA_HC_OPTS=-fhpc -# -#HPCTOOLS_BORING = HpcParser HpcOverlay HpcLexer HpcDraft HpcCombine -HPCTOOLS_BORING = HpcParser -BORING_FLAGS = $(foreach BORING,$(HPCTOOLS_BORING),--exclude=$(BORING)) -COVERAGE_OUT = tool-coverage.info - -HPC_ALL_TIX = hpc-all.tix -HPC_EXC_TIX = hpc-exceptions.tix - -hpc-tool-coverage-clean:: - find . -name 'hpc.tix' -print | xargs rm -f - -hpc-tool-coverage:: - $(HPC) overlay hpc.ovr --output=$(HPC_EXC_TIX) - $(HPC) sum $(shell find . -name 'hpc-inplace.tix' -print) $(HPC_EXC_TIX) \ - --output=$(HPC_ALL_TIX) --union - date >> $(COVERAGE_OUT) - $(HPC) report $(HPC_ALL_TIX) --xml-output >> $(COVERAGE_OUT) - echo OMIT: $(HPCTOOLS_BORING) >> $(COVERAGE_OUT) - $(HPC) report $(HPC_ALL_TIX) --xml-output $(BORING_FLAGS) \ - >> $(COVERAGE_OUT) - $(HPC) markup $(HPC_ALL_TIX) $(BORING_FLAGS) --destdir=html - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/448671a7d4ad7cf8454b31fe15304f5c823542a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/448671a7d4ad7cf8454b31fe15304f5c823542a5 You're receiving 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 Nov 17 16:31:31 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 17 Nov 2023 11:31:31 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] testsuite: Add mechanism to collect generic metrics Message-ID: <65579563c6101_d535c2bebef1c32234a@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: 2501357c by Matthew Pickering at 2023-11-17T16:31:18+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 9 changed files: - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - testsuite/tests/perf/haddock/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs Changes: ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test: Dict = {} # Dict + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -619,11 +661,14 @@ def _extra_files(name, opts, files): def collect_compiler_stats(metric='all',deviation=20): def f(name, opts, m=metric, d=deviation): no_lint(name, opts) - return _collect_stats(name, opts, m, d, True) + return _collect_stats(name, opts, m, d, None, True) return f -def collect_stats(metric='all', deviation=20): - return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def collect_stats(metric='all', deviation=20, static_stats_file=None): + return lambda name, opts, m=metric, d=deviation, s=static_stats_file: _collect_stats(name, opts, m, d, s) + +def statsFile(comp_test: bool, name: str) -> str: + return name + ('.comp' if comp_test else '') + '.stats' # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. @@ -631,7 +676,7 @@ def collect_stats(metric='all', deviation=20): # measures the performance numbers of the compiler. # As this is a fairly rare case in the testsuite, it defaults to false to # indicate that it is a 'normal' performance test. -def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_test=False): +def _collect_stats(name: TestName, opts, metrics, deviation, static_stats_file, is_compiler_stats_test=False): if not re.match('^[0-9]*[a-zA-Z][a-zA-Z0-9._-]*$', name): failBecause('This test has an invalid name.') @@ -664,15 +709,41 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + + if static_stats_file: + stats_file = in_statsdir(static_stats_file) + else: + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + + + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: + def action_generator(mn): + return lambda way: read_stats_file(way, mn) metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": action_generator(metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1652,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1793,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - -async def static_stats( name, way, stats_file ): +async def static_stats( name, way ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_test) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1805,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1918,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1968,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +2004,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2050,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/haddock/all.T ===================================== @@ -19,21 +19,21 @@ test('haddock.base', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',5) + ,collect_stats('bytes allocated',5, static_stats_file='base.t') ], static_stats, - ['base.t']) + []) test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',5) + ,collect_stats('bytes allocated',5, static_stats_file='Cabal.t') ], static_stats, - ['Cabal.t']) + []) test('haddock.compiler', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',10) + ,collect_stats('bytes allocated',10, static_stats_file='ghc.t') ], static_stats, - ['ghc.t']) + []) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2501357cd055978a6ac944034b04824f9131c59a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2501357cd055978a6ac944034b04824f9131c59a You're receiving 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 Nov 17 16:43:11 2023 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Fri, 17 Nov 2023 11:43:11 -0500 Subject: [Git][ghc/ghc][wip/supersven/AArch64_remove_unused_instructions] 24 commits: nofib: bump submodule Message-ID: <6557981f10bce_d535c2c545ad43230aa@gitlab.mail> Sven Tennie pushed to branch wip/supersven/AArch64_remove_unused_instructions at Glasgow Haskell Compiler / GHC Commits: 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 940048ca by Sven Tennie at 2023-11-17T17:42:55+01:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs-boot - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Finder/Types.hs - compiler/GHC/Unit/State.hs - configure.ac The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5099b2cd1bb1251a0b9da13a47dfba3975d57a13...940048ca633803164701e278231b2221e6519608 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5099b2cd1bb1251a0b9da13a47dfba3975d57a13...940048ca633803164701e278231b2221e6519608 You're receiving 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 Nov 17 17:01:47 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Fri, 17 Nov 2023 12:01:47 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 11 commits: Document defaulting of RuntimeReps Message-ID: <65579c7b113c9_d535c2cc4f6683280a7@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - d0d40706 by Apoorv Ingle at 2023-11-17T10:58:56-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Make records Expand and not desugar before typechecking. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 7a82fe36 by Apoorv Ingle at 2023-11-17T11:01:06-06:00 - Renaming `GHC.Types.Basic.{Origin -> MatchOrigin}` - - - - - 28 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - + compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f8c624af41bdf8b78157049442a3948378a6a14...7a82fe36873243224146a4d0e6b38f60ce8d8d13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f8c624af41bdf8b78157049442a3948378a6a14...7a82fe36873243224146a4d0e6b38f60ce8d8d13 You're receiving 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 Nov 17 17:36:21 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 17 Nov 2023 12:36:21 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] 59 commits: AArch64: Delete unused LDATA pseudo-instruction Message-ID: <6557a495a5dab_d535c2d8bcbe43301bb@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 37642384 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Work in progress on unfoldings re-engineering - - - - - 77918531 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 More - - - - - 4feecf3f by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 More -- now it compiles - - - - - 21883198 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Wibbles - - - - - 3ecb5608 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Wibbles - - - - - 45f42432 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Wibbles - - - - - d29defb3 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 More wibbles In particular, respect OtherCon - - - - - 2c385bc4 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 oops remove spurious trace - - - - - ff0d0ff5 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Value args only in ExprTrees - - - - - 82c7f776 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Another wibble - - - - - 95d4e352 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Be a little bit more eager - - - - - 28a072c4 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Comment out unused arg_is_free - - - - - 71b6cfbe by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Fix scoping bug - - - - - a1f42379 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Take care with void args - - - - - 90b4cf36 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Comments - - - - - 88b781c3 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Limit case width and depth - - - - - c4a1e7ad by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 White space - - - - - a94af65c by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Simplify size calculations - - - - - cd36ad61 by Simon Peyton Jones at 2023-11-17T17:35:22+00:00 Fix egregious error - - - - - 965e69bc by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Further improvements * Fix threshold in SpecConstr * Need to recurse in keptCaseSize - - - - - 9a75f9ba by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 More care with discounts and sizes - - - - - 6d3cbf20 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 More improvements Rename et_tot to et_wc_tot (for "worst case") Fix size bug in etCaseOf - - - - - 6eb60059 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Bale out altogether on very wide cases - - - - - d5f9d6f6 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Stupid typo - - - - - dff887d0 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Wibble - - - - - ac56295a by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 More improvements Mainly doing the result-discounts as before. Some skirmishing about dealing with knownCon.. more to come - - - - - d699af4e by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Fix a bad, subtle bug in exprIsConApp_maybe In extend_in_scope We were simply overwriting useful bindings in the in-scope set, notably ones that had unfoldings. That could lead to repeated simplifier iterations. - - - - - 97ef5828 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Minor refactoring... Plus: don't be so eager to inline when argument is a non-value, but has some struture. We want *some* incentive though. - - - - - 1660fd0c by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Wibbles The significant one is a discount for arguments that have structure - - - - - 03e04ef4 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 More wibbles - - - - - e6b8b200 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Small updates * Reduce unfolding-use-threshold to 80 * Make dfun applications look like value args - - - - - b62ff4ad by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Inline on structured arguments - - - - - 244b0ff5 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Further wibbles Make unlifted cases cheaper - - - - - 5e501ed2 by Simon Peyton Jones at 2023-11-17T17:35:23+00:00 Wibbles - - - - - 29 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5b6bcc3e2cda086d2d98506a72709bba504c2e8...5e501ed27dfe1166817afa49c1fbb57ea7e41fd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5b6bcc3e2cda086d2d98506a72709bba504c2e8...5e501ed27dfe1166817afa49c1fbb57ea7e41fd2 You're receiving 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 Nov 17 18:31:14 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 17 Nov 2023 13:31:14 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <6557b172111ef_d535c2f0cc9643416eb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 9c990294 by Alan Zimmerman at 2023-11-17T13:31:03-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 24 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-optimisation.rst - libraries/base/changelog.md - libraries/base/src/Data/Functor/Compose.hs - libraries/base/src/Data/List/NonEmpty.hs - libraries/base/src/Debug/Trace.hs - libraries/base/src/GHC/JS/Foreign/Callback.hs - libraries/base/src/GHC/JS/Prim.hs - libraries/base/src/GHC/JS/Prim/Internal.hs - libraries/base/src/System/Posix/Internals.hs - + rts/js/config.js - rts/js/thread.js - rts/rts.cabal - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/simplCore/should_compile/T22309.hs - + testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -128,8 +128,8 @@ module GHC.Core.TyCon( PrimRep(..), PrimElemRep(..), Levity(..), primElemRepToPrimRep, isVoidRep, isGcPtrRep, - primRepSizeB, - primElemRepSizeB, + primRepSizeB, primRepSizeW64_B, + primElemRepSizeB, primElemRepSizeW64_B, primRepIsFloat, primRepsCompatible, primRepCompatible, @@ -1679,9 +1679,39 @@ primRepSizeB platform = \case VoidRep -> 0 (VecRep len rep) -> len * primElemRepSizeB platform rep +-- | Like primRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primRepSizeW64_B :: PrimRep -> Int +primRepSizeW64_B = \case + IntRep -> 8 + WordRep -> 8 + Int8Rep -> 1 + Int16Rep -> 2 + Int32Rep -> 4 + Int64Rep -> 8 + Word8Rep -> 1 + Word16Rep -> 2 + Word32Rep -> 4 + Word64Rep -> 8 + FloatRep -> fLOAT_SIZE + DoubleRep -> dOUBLE_SIZE + AddrRep -> 8 + BoxedRep{} -> 8 + VoidRep -> 0 + (VecRep len rep) -> len * primElemRepSizeW64_B rep + primElemRepSizeB :: Platform -> PrimElemRep -> Int primElemRepSizeB platform = primRepSizeB platform . primElemRepToPrimRep +-- | Like primElemRepSizeB but assumes pointers/words are 8 words wide. +-- +-- This can be useful to compute the size of a rep as if we were compiling +-- for a 64bit platform. +primElemRepSizeW64_B :: PrimElemRep -> Int +primElemRepSizeW64_B = primRepSizeW64_B . primElemRepToPrimRep + primElemRepToPrimRep :: PrimElemRep -> PrimRep primElemRepToPrimRep Int8ElemRep = Int8Rep primElemRepToPrimRep Int16ElemRep = Int16Rep ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -67,7 +67,7 @@ import GHC.Core.DataCon import GHC.Types.Literal import GHC.Types.SourceText -import GHC.Types.RepType ( countFunRepArgs ) +import GHC.Types.RepType ( countFunRepArgs, typePrimRep ) import GHC.Types.Name.Set import GHC.Types.Name import GHC.Types.Name.Env @@ -1517,16 +1517,29 @@ shouldUnpackArgTy bang_opts prag fam_envs arg_ty | otherwise -- Wrinkle (W4) of Note [Recursive unboxing] -> bang_opt_unbox_strict bang_opts || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + && is_small_rep) -- See Note [Unpack one-wide fields] where (rep_tys, _) = dataConArgUnpack arg_ty + -- Takes in the list of reps used to represent the dataCon after it's unpacked + -- and tells us if they can fit into 8 bytes. See Note [Unpack one-wide fields] + is_small_rep = + let -- Neccesary to look through unboxed tuples. + prim_reps = concatMap (typePrimRep . scaledThing . fst) $ rep_tys + -- Void types are erased when unpacked so we + nv_prim_reps = filter (not . isVoidRep) prim_reps + -- And then get the actual size of the unpacked constructor. + rep_size = sum $ map primRepSizeW64_B nv_prim_reps + in rep_size <= 8 + is_sum :: [DataCon] -> Bool -- We never unpack sum types automatically -- (Product types, we do. Empty types are weeded out by unpackable_type_datacons.) is_sum (_:_:_) = True is_sum _ = False + + -- Given a type already assumed to have been normalized by topNormaliseType, -- unpackable_type_datacons ty = Just datacons -- iff ty is of the form @@ -1585,6 +1598,14 @@ However Here we can represent T with an Int#. +Special care has to be taken to make sure we don't mistake fields with unboxed +tuple/sum rep or very large reps. See #22309 + +For consistency we unpack anything that fits into 8 bytes on a 64-bit platform, +even when compiling for 32bit platforms. This way unpacking decisions will be the +same for 32bit and 64bit systems. To do so we use primRepSizeW64_B instead of +primRepSizeB. See also the tests in test case T22309. + Note [Recursive unboxing] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,16 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- The flag `-funbox-small-strict-fields` will now properly recognize unboxed tuples + containing multiple elements as large. Constructors like `Foo (# Int64, Int64# )` + will no longer be considered small and therefore not unboxed by default under `-O` + even when used as strict field. :ghc-ticket:`22309`. + +- The flag `-funbox-small-strict-fields` will now always unpack things as if compiling + for a 64bit platform. Even when generating code for a 32bit platform. + This makes core optimizations more consistent between 32bit and 64bit platforms + at the cost of slightly worse 32bit performance in edge cases. + GHCi ~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1533,9 +1533,9 @@ as such you shouldn't need to set any of them explicitly. A flag default you can disable it for certain constructor fields using the ``NOUNPACK`` pragma (see :ref:`nounpack-pragma`). - Note that for consistency ``Double``, ``Word64``, and ``Int64`` - constructor fields are unpacked on 32-bit platforms, even though - they are technically larger than a pointer on those platforms. + Note that for consistency constructor fields are unpacked on 32-bit platforms + as if it we were compiling for a 64-bit target even if fields are larger + than a pointer on those platforms. .. ghc-flag:: -funbox-strict-fields :shortdesc: Flatten strict constructor fields ===================================== libraries/base/changelog.md ===================================== @@ -2,6 +2,7 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) + * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). @@ -11,6 +12,7 @@ * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * Implement `many` and `some` methods of `instance Alternative (Compose f g)` explicitly. ([CLC proposal #181](https://github.com/haskell/core-libraries-committee/issues/181)) * The functions `GHC.Exts.dataToTag#` and `GHC.Base.getTag` have had their types changed to the following: ===================================== libraries/base/src/Data/Functor/Compose.hs ===================================== @@ -147,6 +147,10 @@ instance (Alternative f, Applicative g) => Alternative (Compose f g) where empty = Compose empty (<|>) = coerce ((<|>) :: f (g a) -> f (g a) -> f (g a)) :: forall a . Compose f g a -> Compose f g a -> Compose f g a + some = coerce (fmap sequenceA . some :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] + many = coerce (fmap sequenceA . many :: f (g a) -> f (g [a])) + :: forall a . Compose f g a -> Compose f g [a] -- | The deduction (via generativity) that if @g x :~: g y@ then @x :~: y at . -- ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -78,6 +78,8 @@ module Data.List.NonEmpty ( , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) + , permutations + , permutations1 -- * Sublist predicates , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool -- * \"Set\" operations @@ -441,6 +443,30 @@ groupWith1 f = groupBy1 ((==) `on` f) groupAllWith1 :: (Ord b) => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) groupAllWith1 f = groupWith1 f . sortWith f +-- | The 'permutations' function returns the list of all permutations of the argument. +-- +-- @since 4.20.0.0 +permutations :: [a] -> NonEmpty [a] +permutations xs0 = xs0 :| perms xs0 [] + where + perms [] _ = [] + perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) + where interleave xs r = let (_,zs) = interleave' id xs r in zs + interleave' _ [] r = (ts, r) + interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r + in (y:us, f (t:y:us) : zs) +-- The implementation of 'permutations' is adopted from 'Data.List.permutations', +-- see there for discussion and explanations. + +-- | 'permutations1' operates like 'permutations', but uses the knowledge that its input is +-- non-empty to produce output where every element is non-empty. +-- +-- > permutations1 = fmap fromList . permutations . toList +-- +-- @since 4.20.0.0 +permutations1 :: NonEmpty a -> NonEmpty (NonEmpty a) +permutations1 xs = fromList <$> permutations (toList xs) + -- | The 'isPrefixOf' function returns 'True' if the first argument is -- a prefix of the second. isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool ===================================== libraries/base/src/Debug/Trace.hs ===================================== @@ -143,13 +143,15 @@ traceId a = trace a a Like 'trace', but uses 'show' on the argument to convert it to a 'String'. This makes it convenient for printing the values of interesting variables or -expressions inside a function. For example here we print the value of the +expressions inside a function. For example, here we print the values of the variables @x@ and @y@: ->>> let f x y = traceShow (x,y) (x + y) in f (1+2) 5 -(3,5) +>>> let f x y = traceShow ("x", x, "y", y) (x + y) in f (1+2) 5 +("x",3,"y",5) 8 +Note in this example we also create simple labels just by including some strings. + -} traceShow :: Show a => a -> b -> b traceShow = trace . show ===================================== libraries/base/src/GHC/JS/Foreign/Callback.hs ===================================== @@ -145,5 +145,5 @@ foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$runSyncReturn, [false], $2); })" js_syncCallbackApplyReturn :: Int -> Exts.Any -> IO (Callback b) -foreign import javascript unsafe "(($1) => { return h$release($1); })" +foreign import javascript unsafe "h$release" js_release :: Callback a -> IO () ===================================== libraries/base/src/GHC/JS/Prim.hs ===================================== @@ -259,16 +259,16 @@ seqList xs = go xs `seq` xs where go (y:ys) = y `seq` go ys go [] = () -foreign import javascript unsafe "(($1) => { return h$toHsString($1); })" +foreign import javascript unsafe "h$toHsString" js_fromJSString :: JSVal -> Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsString($1); })" +foreign import javascript unsafe "h$fromHsString" js_toJSString :: Exts.Any -> JSVal -foreign import javascript unsafe "(($1) => { return h$toHsListJSVal($1); })" +foreign import javascript unsafe "h$toHsListJSVal" js_fromJSArray :: JSVal -> IO Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsListJSVal($1); })" +foreign import javascript unsafe "h$fromHsListJSVal" js_toJSArray :: Exts.Any -> IO JSVal foreign import javascript unsafe "(($1) => { return ($1 === null); })" ===================================== libraries/base/src/GHC/JS/Prim/Internal.hs ===================================== @@ -43,14 +43,14 @@ foreign import javascript unsafe js_setCurrentThreadResultWouldBlock :: IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultJSException($1); })" + "h$setCurrentThreadResultJSException" js_setCurrentThreadResultJSException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultHaskellException($1); })" + "h$setCurrentThreadResultHaskellException" js_setCurrentThreadResultHaskellException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultValue($1); })" + "h$setCurrentThreadResultValue" js_setCurrentThreadResultValue :: JSVal -> IO () ===================================== libraries/base/src/System/Posix/Internals.hs ===================================== @@ -504,7 +504,7 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat" #if defined(javascript_HOST_ARCH) -foreign import javascript unsafe "(() => { return rts_isThreaded; })" rtsIsThreaded_ :: Int +foreign import javascript unsafe "h$rts_isThreaded" rtsIsThreaded_ :: Int foreign import javascript interruptible "h$base_access" c_access :: CString -> CInt -> IO CInt foreign import javascript interruptible "h$base_chmod" ===================================== rts/js/config.js ===================================== @@ -0,0 +1,21 @@ +function h$rts_isThreaded() { + return 0; +} + +function h$rts_isTracing() { + return 0; +} + +function h$rts_isDynamic() { + return 0; +} + +function h$rts_isDebugged() { + return 0; +} + +function h$rts_isProfiled() { + return 0; +} + + \ No newline at end of file ===================================== rts/js/thread.js ===================================== @@ -1460,5 +1460,3 @@ function h$makeMVarListener(mv, stopProp, stopImmProp, preventDefault) { function h$rs() { return h$stack[h$sp]; } - -const rts_isThreaded = 0; ===================================== rts/rts.cabal ===================================== @@ -99,6 +99,7 @@ library c-sources: version.c js-sources: + js/config.js js/structs.js js/arith.js js/compact.js ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1410,6 +1410,8 @@ module Data.List.NonEmpty where nub :: forall a. GHC.Classes.Eq a => NonEmpty a -> NonEmpty a nubBy :: forall a. (a -> a -> GHC.Types.Bool) -> NonEmpty a -> NonEmpty a partition :: forall a. (a -> GHC.Types.Bool) -> NonEmpty a -> ([a], [a]) + permutations :: forall a. [a] -> NonEmpty [a] + permutations1 :: forall a. NonEmpty a -> NonEmpty (NonEmpty a) prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a repeat :: forall a. a -> NonEmpty a reverse :: forall a. NonEmpty a -> NonEmpty a ===================================== testsuite/tests/simplCore/should_compile/T22309.hs ===================================== @@ -0,0 +1,35 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module ShouldCompile where + +import GHC.Int +import GHC.Exts + +-- These should unbox into another constructor +data UA = Mk_A !Int +data UB = Mk_B !Int64 +data UC = Mk_C !Int32 +data UD = Mk_D !Int32 !Int32 +data UE = Mk_E !(# Int# #) +data UF = Mk_F !(# Double #) + +-- These should not be unpacked into another constructor. +data NU_A = NU_MkA (# Int64, Int64 #) +data NU_B = NU_MkB !Int64 !Int64 + +-- The types we unbox into + +-- These should unpack their fields. +data WU_A = MkW_A !UA +data WU_B = MkW_B !UB +data WU_C = MkW_C !UC +data WU_D = MkW_D !UD +data WU_E = MkW_E !UE +data WU_F = MkW_F !UF + +-- These should not unpack their fields, as they are multiple words large. +data WNU_A = MkW_NA !NU_A +data WNU_B = MkW_NB !NU_B + + ===================================== testsuite/tests/simplCore/should_compile/T22309.stderr ===================================== @@ -0,0 +1,88 @@ + +==================== Final STG: ==================== +$WMkW_NB :: NU_B %1 -> WNU_B = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NB [conrep1]; }; + +$WMkW_NA :: NU_A %1 -> WNU_A = + \r [conrep] + case conrep of conrep1 { __DEFAULT -> MkW_NA [conrep1]; }; + +$WMkW_F :: UF %1 -> WU_F = + \r [conrep] case conrep of { Mk_F us -> MkW_F [us]; }; + +$WMkW_E :: UE %1 -> WU_E = + \r [conrep] case conrep of { Mk_E us -> MkW_E [us]; }; + +$WMkW_D :: UD %1 -> WU_D = + \r [conrep] + case conrep of { Mk_D unbx unbx1 -> MkW_D [unbx unbx1]; }; + +$WMkW_C :: UC %1 -> WU_C = + \r [conrep] case conrep of { Mk_C unbx -> MkW_C [unbx]; }; + +$WMkW_B :: UB %1 -> WU_B = + \r [conrep] case conrep of { Mk_B unbx -> MkW_B [unbx]; }; + +$WMkW_A :: UA %1 -> WU_A = + \r [conrep] case conrep of { Mk_A unbx -> MkW_A [unbx]; }; + +$WNU_MkB :: Int64 %1 -> Int64 %1 -> NU_B = + \r [conrep conrep1] + case conrep of { + I64# unbx -> + case conrep1 of { I64# unbx1 -> NU_MkB [unbx unbx1]; }; + }; + +$WMk_D :: Int32 %1 -> Int32 %1 -> UD = + \r [conrep conrep1] + case conrep of { + I32# unbx -> case conrep1 of { I32# unbx1 -> Mk_D [unbx unbx1]; }; + }; + +$WMk_C :: Int32 %1 -> UC = + \r [conrep] case conrep of { I32# unbx -> Mk_C [unbx]; }; + +$WMk_B :: Int64 %1 -> UB = + \r [conrep] case conrep of { I64# unbx -> Mk_B [unbx]; }; + +$WMk_A :: Int %1 -> UA = + \r [conrep] case conrep of { I# unbx -> Mk_A [unbx]; }; + +MkW_NB :: NU_B %1 -> WNU_B = + \r [eta] case eta of eta { __DEFAULT -> MkW_NB [eta]; }; + +MkW_NA :: NU_A %1 -> WNU_A = + \r [eta] case eta of eta { __DEFAULT -> MkW_NA [eta]; }; + +MkW_F :: (# Double #) %1 -> WU_F = \r [us] MkW_F [us]; + +MkW_E :: (# Int# #) %1 -> WU_E = \r [us] MkW_E [us]; + +MkW_D :: Int32# %1 -> Int32# %1 -> WU_D = + \r [eta eta] MkW_D [eta eta]; + +MkW_C :: Int32# %1 -> WU_C = \r [eta] MkW_C [eta]; + +MkW_B :: Int64# %1 -> WU_B = \r [eta] MkW_B [eta]; + +MkW_A :: Int# %1 -> WU_A = \r [eta] MkW_A [eta]; + +NU_MkB :: Int64# %1 -> Int64# %1 -> NU_B = + \r [eta eta] NU_MkB [eta eta]; + +NU_MkA :: (# Int, Int #) %1 -> NU_A = \r [us us] NU_MkA [us us]; + +Mk_F :: (# Double #) %1 -> UF = \r [us] Mk_F [us]; + +Mk_E :: (# Int# #) %1 -> UE = \r [us] Mk_E [us]; + +Mk_D :: Int32# %1 -> Int32# %1 -> UD = \r [eta eta] Mk_D [eta eta]; + +Mk_C :: Int32# %1 -> UC = \r [eta] Mk_C [eta]; + +Mk_B :: Int64# %1 -> UB = \r [eta] Mk_B [eta]; + +Mk_A :: Int# %1 -> UA = \r [eta] Mk_A [eta]; + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -488,6 +488,7 @@ test('T23307', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress test('T23307a', normal, compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) test('T23307b', normal, compile, ['-O']) test('T23307c', normal, compile, ['-O']) +test('T22309', [grep_errmsg(r'MkW'), only_ways(['optasm']) ], compile, ['-O -ddump-stg-final -dsuppress-uniques -dsuppress-all -dno-typeable-binds -dno-suppress-type-signatures -dsuppress-module-prefixes']) test('T23426', normal, compile, ['-O']) test('T23491a', [extra_files(['T23491.hs']), grep_errmsg(r'Float out')], multimod_compile, ['T23491', '-ffull-laziness -ddump-full-laziness']) test('T23491b', [extra_files(['T23491.hs']), grep_errmsg(r'Float inwards')], multimod_compile, ['T23491', '-ffloat-in -ddump-float-in']) ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c1959b3850452547aa59ced8d94c32121c77d37...9c990294c50ce777b41924a290a5ea2b6d5f883d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c1959b3850452547aa59ced8d94c32121c77d37...9c990294c50ce777b41924a290a5ea2b6d5f883d You're receiving 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 Nov 17 20:09:20 2023 From: gitlab at gitlab.haskell.org (Bodigrim (@Bodigrim)) Date: Fri, 17 Nov 2023 15:09:20 -0500 Subject: [Git][ghc/ghc] Deleted tag wip/trac-kindaro/feature-base-nonempty-permutations Message-ID: <6557c8705d9d4_d535c315184583508eb@gitlab.mail> Bodigrim deleted tag wip/trac-kindaro/feature-base-nonempty-permutations at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Nov 17 22:21:55 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 17 Nov 2023 17:21:55 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: AArch64: Remove unused instructions Message-ID: <6557e78388818_d535c34505ea43599b1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8d88d804 by Sven Tennie at 2023-11-17T17:21:46-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - a5502789 by Alan Zimmerman at 2023-11-17T17:21:47-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c990294c50ce777b41924a290a5ea2b6d5f883d...a550278921bfc01ef8c6ea8b34b0ad16bae910d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c990294c50ce777b41924a290a5ea2b6d5f883d...a550278921bfc01ef8c6ea8b34b0ad16bae910d5 You're receiving 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 Nov 17 23:54:36 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 17 Nov 2023 18:54:36 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] base: Do not expose whereFrom# from GHC.Exts Message-ID: <6557fd3c1aae4_14c49b1094ba090682@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 0e14e2cc by Ben Gamari at 2023-11-17T18:54:29-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 6 changed files: - libraries/base/changelog.md - libraries/base/src/GHC/Exts.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -11,6 +11,7 @@ * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ## 4.19.0.0 *October 2023* ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce ) +import GHC.Prim hiding ( coerce, whereFrom# ) import GHC.Types hiding ( IO -- Exported from "GHC.IO" , Type -- Exported from "Data.Kind" ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4679,7 +4679,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4679,7 +4679,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4682,7 +4682,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4679,7 +4679,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e14e2cc4ccb1684f8f5752810aff553bd36ba46 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e14e2cc4ccb1684f8f5752810aff553bd36ba46 You're receiving 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 Nov 18 00:00:24 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 17 Nov 2023 19:00:24 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] 75 commits: Explicitly require RLIMIT_AS before use in OSMem.c Message-ID: <6557fe98469e1_14c49b10858bc914d3@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 5c255a84 by Ben Gamari at 2023-11-17T18:58:48-05:00 rts/CloneStack: Bounds check array write - - - - - ef911717 by Ben Gamari at 2023-11-17T18:58:48-05:00 rts/CloneStack: Don't expose helper functions in header - - - - - 345d9a78 by Ben Gamari at 2023-11-17T18:58:48-05:00 base: Move internals of GHC.InfoProv into GHC.InfoProv.Types Such that we can add new helpers into GHC.InfoProv.Types without breakage. - - - - - c107fbcf by Ben Gamari at 2023-11-17T18:58:49-05:00 rts: Lazily decode IPE tables Previously we would eagerly allocate `InfoTableEnt`s for each info table registered in the info table provenance map. However, this costs considerable memory and initialization time. Instead we now lazily decode these tables. This allows us to use one-third the memory *and* opens the door to taking advantage of sharing opportunities within a module. This required considerable reworking since lookupIPE now must be passed its result buffer. - - - - - 88287778 by Ben Gamari at 2023-11-17T18:58:49-05:00 rts/IPE: Don't expose helper in header - - - - - 13d3e8b6 by Ben Gamari at 2023-11-17T18:58:49-05:00 rts/IPE: Share module_name within a Node This allows us to shave a 64-bit word off of the packed IPE entry size. - - - - - 5061eea1 by Ben Gamari at 2023-11-17T18:59:17-05:00 IPE: Include unit id - - - - - a0784492 by Ben Gamari at 2023-11-17T18:59:17-05:00 rts: Refactor GHC.Stack.CloneStack.decode Don't allocate a Ptr constructor per frame. - - - - - 6dec3ad5 by Ben Gamari at 2023-11-17T19:00:05-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Pmc.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0e14e2cc4ccb1684f8f5752810aff553bd36ba46...6dec3ad5727b51a1ddbf17ba33c449aebfc19c62 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0e14e2cc4ccb1684f8f5752810aff553bd36ba46...6dec3ad5727b51a1ddbf17ba33c449aebfc19c62 You're receiving 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 Nov 18 02:32:41 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 17 Nov 2023 21:32:41 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: AArch64: Remove unused instructions Message-ID: <6558224961863_14c49b4d5298410398b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f025bc8a by Sven Tennie at 2023-11-17T21:32:16-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - eaf55e5b by Alan Zimmerman at 2023-11-17T21:32:16-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a550278921bfc01ef8c6ea8b34b0ad16bae910d5...eaf55e5b4b820bf749e17a14f2506738f3cce334 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a550278921bfc01ef8c6ea8b34b0ad16bae910d5...eaf55e5b4b820bf749e17a14f2506738f3cce334 You're receiving 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 Nov 18 05:43:19 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 18 Nov 2023 00:43:19 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: AArch64: Remove unused instructions Message-ID: <65584ef6d48d0_14c49b93e8a9c1185a2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e1ef0e6a by Sven Tennie at 2023-11-18T00:43:05-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 920d12db by Alan Zimmerman at 2023-11-18T00:43:06-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eaf55e5b4b820bf749e17a14f2506738f3cce334...920d12db780c49d18e430cd5b57231794c95d363 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eaf55e5b4b820bf749e17a14f2506738f3cce334...920d12db780c49d18e430cd5b57231794c95d363 You're receiving 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 Nov 18 09:03:34 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 18 Nov 2023 04:03:34 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: AArch64: Remove unused instructions Message-ID: <65587de624fd3_14c49be84e7bc135761@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f21a891e by Sven Tennie at 2023-11-18T04:03:25-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 64d8d36b by Alan Zimmerman at 2023-11-18T04:03:25-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/920d12db780c49d18e430cd5b57231794c95d363...64d8d36be9786186033e0e0ff94b9654f248b065 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/920d12db780c49d18e430cd5b57231794c95d363...64d8d36be9786186033e0e0ff94b9654f248b065 You're receiving 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 Nov 18 11:53:59 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 18 Nov 2023 06:53:59 -0500 Subject: [Git][ghc/ghc][master] JS: clean up some foreign imports Message-ID: <6558a5d7e4559_14c49b1249ac98152879@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 7 changed files: - libraries/base/src/GHC/JS/Foreign/Callback.hs - libraries/base/src/GHC/JS/Prim.hs - libraries/base/src/GHC/JS/Prim/Internal.hs - libraries/base/src/System/Posix/Internals.hs - + rts/js/config.js - rts/js/thread.js - rts/rts.cabal Changes: ===================================== libraries/base/src/GHC/JS/Foreign/Callback.hs ===================================== @@ -145,5 +145,5 @@ foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$runSyncReturn, [false], $2); })" js_syncCallbackApplyReturn :: Int -> Exts.Any -> IO (Callback b) -foreign import javascript unsafe "(($1) => { return h$release($1); })" +foreign import javascript unsafe "h$release" js_release :: Callback a -> IO () ===================================== libraries/base/src/GHC/JS/Prim.hs ===================================== @@ -259,16 +259,16 @@ seqList xs = go xs `seq` xs where go (y:ys) = y `seq` go ys go [] = () -foreign import javascript unsafe "(($1) => { return h$toHsString($1); })" +foreign import javascript unsafe "h$toHsString" js_fromJSString :: JSVal -> Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsString($1); })" +foreign import javascript unsafe "h$fromHsString" js_toJSString :: Exts.Any -> JSVal -foreign import javascript unsafe "(($1) => { return h$toHsListJSVal($1); })" +foreign import javascript unsafe "h$toHsListJSVal" js_fromJSArray :: JSVal -> IO Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsListJSVal($1); })" +foreign import javascript unsafe "h$fromHsListJSVal" js_toJSArray :: Exts.Any -> IO JSVal foreign import javascript unsafe "(($1) => { return ($1 === null); })" ===================================== libraries/base/src/GHC/JS/Prim/Internal.hs ===================================== @@ -43,14 +43,14 @@ foreign import javascript unsafe js_setCurrentThreadResultWouldBlock :: IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultJSException($1); })" + "h$setCurrentThreadResultJSException" js_setCurrentThreadResultJSException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultHaskellException($1); })" + "h$setCurrentThreadResultHaskellException" js_setCurrentThreadResultHaskellException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultValue($1); })" + "h$setCurrentThreadResultValue" js_setCurrentThreadResultValue :: JSVal -> IO () ===================================== libraries/base/src/System/Posix/Internals.hs ===================================== @@ -504,7 +504,7 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat" #if defined(javascript_HOST_ARCH) -foreign import javascript unsafe "(() => { return rts_isThreaded; })" rtsIsThreaded_ :: Int +foreign import javascript unsafe "h$rts_isThreaded" rtsIsThreaded_ :: Int foreign import javascript interruptible "h$base_access" c_access :: CString -> CInt -> IO CInt foreign import javascript interruptible "h$base_chmod" ===================================== rts/js/config.js ===================================== @@ -0,0 +1,21 @@ +function h$rts_isThreaded() { + return 0; +} + +function h$rts_isTracing() { + return 0; +} + +function h$rts_isDynamic() { + return 0; +} + +function h$rts_isDebugged() { + return 0; +} + +function h$rts_isProfiled() { + return 0; +} + + \ No newline at end of file ===================================== rts/js/thread.js ===================================== @@ -1460,5 +1460,3 @@ function h$makeMVarListener(mv, stopProp, stopImmProp, preventDefault) { function h$rs() { return h$stack[h$sp]; } - -const rts_isThreaded = 0; ===================================== rts/rts.cabal ===================================== @@ -99,6 +99,7 @@ library c-sources: version.c js-sources: + js/config.js js/structs.js js/arith.js js/compact.js View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faff671a7786202bff39fa0cdf41e4518fb11c4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faff671a7786202bff39fa0cdf41e4518fb11c4b You're receiving 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 Nov 18 11:54:43 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 18 Nov 2023 06:54:43 -0500 Subject: [Git][ghc/ghc][master] AArch64: Remove unused instructions Message-ID: <6558a60355a7a_14c49b124ab2a0156139@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 3 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/856e0a4ea83909ecbd1dae6e74213c06ea156342 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/856e0a4ea83909ecbd1dae6e74213c06ea156342 You're receiving 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 Nov 18 11:55:34 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 18 Nov 2023 06:55:34 -0500 Subject: [Git][ghc/ghc][master] EPA: Replace Monoid with NoAnn Message-ID: <6558a636c6a9f_14c49b127412bc1600da@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 2 changed files: - compiler/GHC/Parser/Annotation.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615441ef8bbdbb09ba1b354e8dc234b4aefb863a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615441ef8bbdbb09ba1b354e8dc234b4aefb863a You're receiving 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 Nov 18 12:50:19 2023 From: gitlab at gitlab.haskell.org (BinderDavid (@BinderDavid)) Date: Sat, 18 Nov 2023 07:50:19 -0500 Subject: [Git][ghc/ghc][wip/unify-hpc-testsuites] Unify the hpc testsuites Message-ID: <6558b30bd9011_14c49b145a3638162293@gitlab.mail> BinderDavid pushed to branch wip/unify-hpc-testsuites at Glasgow Haskell Compiler / GHC Commits: ccdae07f by David Binder at 2023-11-18T13:48:38+01:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - 30 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - libraries/hpc - + testsuite/tests/hpc/.gitignore - + testsuite/tests/hpc/fork/Makefile - + testsuite/tests/hpc/fork/hpc_fork.hs - + testsuite/tests/hpc/fork/hpc_fork.stdout - + testsuite/tests/hpc/fork/test.T - + testsuite/tests/hpc/function/Makefile - + testsuite/tests/hpc/function/test.T - + testsuite/tests/hpc/function/tough.hs - + testsuite/tests/hpc/function/tough.stdout - + testsuite/tests/hpc/function2/Makefile - + testsuite/tests/hpc/function2/subdir/tough2.lhs - + testsuite/tests/hpc/function2/test.T - + testsuite/tests/hpc/function2/tough2.stdout - + testsuite/tests/hpc/ghc_ghci/A.hs - + testsuite/tests/hpc/ghc_ghci/B.hs - + testsuite/tests/hpc/ghc_ghci/Makefile - + testsuite/tests/hpc/ghc_ghci/hpc_ghc_ghci.stdout - + testsuite/tests/hpc/ghc_ghci/test.T - + testsuite/tests/hpc/hpc.ovr - + testsuite/tests/hpc/hpcrun.pl - + testsuite/tests/hpc/raytrace/CSG.hs - + testsuite/tests/hpc/raytrace/Construct.hs - + testsuite/tests/hpc/raytrace/Data.hs - + testsuite/tests/hpc/raytrace/Eval.hs - + testsuite/tests/hpc/raytrace/Geometry.hs - + testsuite/tests/hpc/raytrace/Illumination.hs - + testsuite/tests/hpc/raytrace/Intersections.hs - + testsuite/tests/hpc/raytrace/Interval.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccdae07f1030a1954039c10b8e4da15b52cde1ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccdae07f1030a1954039c10b8e4da15b52cde1ee You're receiving 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 Nov 18 18:32:50 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 18 Nov 2023 13:32:50 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] base: Do not expose whereFrom# from GHC.Exts Message-ID: <65590352e24a7_14c49b1c08608017802d@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 44b4cdd1 by Ben Gamari at 2023-11-18T13:32:44-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 7 changed files: - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -28,6 +28,7 @@ matches a `data` or `data instance` declaration) with all of its constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ## 4.19.0.0 *October 2023* ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,7 +117,7 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) +import GHC.Prim hiding (dataToTagLarge#, whereFrom#) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,10 +133,11 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) +import GHC.Prim hiding ( coerce, dataToTagLarge#, whereFrom# ) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Types hiding ( IO -- Exported from "GHC.IO" ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4687,7 +4687,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44b4cdd1c679faf8ef28f3a21cb73ef7944d1cfc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44b4cdd1c679faf8ef28f3a21cb73ef7944d1cfc You're receiving 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 Nov 18 18:33:57 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 18 Nov 2023 13:33:57 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] base: Do not expose whereFrom# from GHC.Exts Message-ID: <6559039545aff_14c49b1c54f0801785e7@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: b3b44733 by Ben Gamari at 2023-11-18T13:33:48-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 7 changed files: - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -28,6 +28,7 @@ matches a `data` or `data instance` declaration) with all of its constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ## 4.19.0.0 *October 2023* ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,7 +117,7 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) +import GHC.Prim hiding (dataToTagLarge#, whereFrom#) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,10 +133,11 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) +import GHC.Prim hiding ( coerce, dataToTagLarge#, whereFrom# ) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Types hiding ( IO -- Exported from "GHC.IO" ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6738,7 +6737,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6707,7 +6706,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4687,7 +4687,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6887,7 +6886,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6738,7 +6737,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3b447337f318471b29b1c4703ed4b3aa5386f5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3b447337f318471b29b1c4703ed4b3aa5386f5c You're receiving 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 Nov 18 22:45:24 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 18 Nov 2023 17:45:24 -0500 Subject: [Git][ghc/ghc][wip/ipe-sharing] base: Do not expose whereFrom# from GHC.Exts Message-ID: <65593e849be6d_14c49b221b0a2c183675@gitlab.mail> Ben Gamari pushed to branch wip/ipe-sharing at Glasgow Haskell Compiler / GHC Commits: 41030825 by Ben Gamari at 2023-11-18T17:45:15-05:00 base: Do not expose whereFrom# from GHC.Exts - - - - - 8 changed files: - libraries/base/changelog.md - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - libraries/base/src/GHC/InfoProv/Types.hsc - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -28,6 +28,7 @@ matches a `data` or `data instance` declaration) with all of its constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + * `GHC.Exts` no longer exports the GHC-internal `whereFrom#` primop ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) * `GHC.InfoProv.InfoProv` now provides a `ipUnitId :: String` field encoding the unit ID of the unit defining the info table ([CLC proposal #214](https://github.com/haskell/core-libraries-committee/issues/214)) ## 4.19.0.0 *October 2023* ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,7 +117,7 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) +import GHC.Prim hiding (dataToTagLarge#, whereFrom#) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,10 +133,11 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) +import GHC.Prim hiding ( coerce, dataToTagLarge#, whereFrom# ) -- Hide dataToTagLarge# because it is expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) + -- whereFrom# is similarly internal. import GHC.Types hiding ( IO -- Exported from "GHC.IO" ===================================== libraries/base/src/GHC/InfoProv/Types.hsc ===================================== @@ -17,6 +17,7 @@ module GHC.InfoProv.Types ) where import GHC.Base +import GHC.Prim (whereFrom##) import GHC.Show (Show) import GHC.Ptr (Ptr(..), plusPtr) import GHC.Foreign (CString, peekCString) ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6738,7 +6737,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6707,7 +6706,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -4687,7 +4687,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6887,7 +6886,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -4684,7 +4684,6 @@ module GHC.Base where waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d when :: forall (f :: * -> *). Applicative f => Bool -> f () -> f () - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# @@ -6738,7 +6737,6 @@ module GHC.Exts where void# :: (# #) waitRead# :: forall d. Int# -> State# d -> State# d waitWrite# :: forall d. Int# -> State# d -> State# d - whereFrom# :: forall a d. a -> Addr# -> State# d -> (# State# d, Int# #) word16ToInt16# :: Word16# -> Int16# word16ToWord# :: Word16# -> Word# word2Double# :: Word# -> Double# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/410308251dd3fb04724a597e8e77f3c840804c23 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/410308251dd3fb04724a597e8e77f3c840804c23 You're receiving 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 Nov 18 23:51:05 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 18 Nov 2023 18:51:05 -0500 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 81 commits: Move function checks to RTS configure Message-ID: <65594de9df00c_14c49b239a6af01875f7@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - 30ae3224 by Simon Peyton Jones at 2023-11-18T21:42:04+00:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 10e5e6ce by Simon Peyton Jones at 2023-11-18T23:02:53+00:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The net result is good: a 2% improvement in compile time. The table below shows changes over 1%. The main changes are: * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Simplify.Utils.postInlineUnconditionally: * Inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Never postInlineUnconditionally join points; see join points below. * Don't postInlineUnconditionally strict bindings; doing so does not save allocation Also refactor the logic, which had grown rather convoluted. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * In SetLevels (full laziness) float a non-recursive join point only if it is going to get to top level. See GHC.Core.Opt.SetLevels.wantFloatNonRec * In GHC.Core.Opt.Arity.myExprIsCheap include `isCallStackTy`. See Note [Eta expanding through CallStacks] * Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly] Lots of stuff about join points. * Be very careful about inlining a join point $j = K x y, where K is a data constructor. See the long Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. There are a number of pieces to this; see wrinkles (DJ1)-(DJ5). * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * A bit of tuning in thumbsUpPlanA in GHC.Core.Opt.Simplify.Iteration. Small other things: * I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I added an INLINE pragma to it. * Added an invariant to GHC.Types.Tickish.GenTickish. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -4.3% GOOD LargeRecord(normal) -23.3% GOOD PmSeriesS(normal) -2.4% T11195(normal) -1.7% T12227(normal) -20.0% GOOD T12545(normal) -5.4% T13253-spj(normal) -50.7% GOOD T13386(normal) -5.1% GOOD T14766(normal) -2.4% GOOD T15164(normal) -1.7% T15304(normal) +1.0% T15630(normal) -7.7% T15630a(normal) NEW T15703(normal) -7.5% GOOD T16577(normal) -5.1% GOOD T17516(normal) -3.6% T18223(normal) -16.8% GOOD T18282(normal) -1.5% T18304(normal) +1.9% T21839c(normal) -3.5% GOOD T3064(normal) -1.5% T5030(normal) -16.2% GOOD T5321Fun(normal) -1.6% T6048(optasm) -2.1% GOOD T8095(normal) -6.1% GOOD T9630(normal) -5.1% GOOD WWRec(normal) -1.6% geo. mean -2.1% minimum -50.7% maximum +1.9% Metric Decrease: CoOpt_Singletons LargeRecord T12227 T13253-spj T13386 T14766 T15703 T16577 T18223 T21839c T5030 T6048 T8095 T9630 - - - - - 26 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c559190dcf35edd3379e8b00b0e8bb913db2f339...10e5e6ced5f3186f382c493d685aff51e253e0e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c559190dcf35edd3379e8b00b0e8bb913db2f339...10e5e6ced5f3186f382c493d685aff51e253e0e9 You're receiving 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 Nov 19 14:14:59 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sun, 19 Nov 2023 09:14:59 -0500 Subject: [Git][ghc/ghc][wip/testsuite-generic-stats] 4 commits: JS: clean up some foreign imports Message-ID: <655a18639509f_14c49b3761682c2058ee@gitlab.mail> Matthew Pickering pushed to branch wip/testsuite-generic-stats at Glasgow Haskell Compiler / GHC Commits: faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 294f189f by Matthew Pickering at 2023-11-19T14:14:40+00:00 testsuite: Add mechanism to collect generic metrics * Generalise the metric logic by adding an additional field which allows you to specify how to query for the actual value. Previously the method of querying the baseline value was abstracted (but always set to the same thing). * This requires rejigging how the stat collection works slightly but now it's more uniform and hopefully simpler. * Introduce some new "generic" helper functions for writing generic stats tests. - collect_size ( deviation, path ) Record the size of the file as a metric - stat_from_file ( metric, deviation, path ) Read a value from the given path, and store that as a metric - collect_generic_stat ( metric, deviation, get_stat ) Provide your own `get_stat` function, `lambda way: <Int>`, which can be used to establish the value of the metric. - collect_generic_stats ( get_stats ): Like collect_generic_stat but provide the whole dictionary of metric definitions. { metric: { deviation: <Int> action: lambda way: <Int> } } * Introduce two new "size" metrics for keeping track of build products. - `size_hello` - The size of `hello.o` from compiling hello.hs - `libdir` - The total size of the `libdir` folder. * Track the number of modules in the AST tests - CountDepsAst - CountDepsParser This lays the infrastructure for #24191 #22256 #17129 - - - - - 21 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Parser/Annotation.hs - libraries/base/src/GHC/JS/Foreign/Callback.hs - libraries/base/src/GHC/JS/Prim.hs - libraries/base/src/GHC/JS/Prim/Internal.hs - libraries/base/src/System/Posix/Internals.hs - + rts/js/config.js - rts/js/thread.js - rts/rts.cabal - testsuite/driver/perf_notes.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/count-deps/Makefile - testsuite/tests/count-deps/all.T - testsuite/tests/perf/haddock/all.T - + testsuite/tests/perf/size/Makefile - + testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/size_hello.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -1393,7 +1393,7 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where +instance Semigroup EpaLocation where EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) EpaSpan s1 m1 <> _ = EpaSpan s1 m1 _ <> EpaSpan s2 m2 = EpaSpan s2 m2 ===================================== libraries/base/src/GHC/JS/Foreign/Callback.hs ===================================== @@ -145,5 +145,5 @@ foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$runSyncReturn, [false], $2); })" js_syncCallbackApplyReturn :: Int -> Exts.Any -> IO (Callback b) -foreign import javascript unsafe "(($1) => { return h$release($1); })" +foreign import javascript unsafe "h$release" js_release :: Callback a -> IO () ===================================== libraries/base/src/GHC/JS/Prim.hs ===================================== @@ -259,16 +259,16 @@ seqList xs = go xs `seq` xs where go (y:ys) = y `seq` go ys go [] = () -foreign import javascript unsafe "(($1) => { return h$toHsString($1); })" +foreign import javascript unsafe "h$toHsString" js_fromJSString :: JSVal -> Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsString($1); })" +foreign import javascript unsafe "h$fromHsString" js_toJSString :: Exts.Any -> JSVal -foreign import javascript unsafe "(($1) => { return h$toHsListJSVal($1); })" +foreign import javascript unsafe "h$toHsListJSVal" js_fromJSArray :: JSVal -> IO Exts.Any -foreign import javascript unsafe "(($1) => { return h$fromHsListJSVal($1); })" +foreign import javascript unsafe "h$fromHsListJSVal" js_toJSArray :: Exts.Any -> IO JSVal foreign import javascript unsafe "(($1) => { return ($1 === null); })" ===================================== libraries/base/src/GHC/JS/Prim/Internal.hs ===================================== @@ -43,14 +43,14 @@ foreign import javascript unsafe js_setCurrentThreadResultWouldBlock :: IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultJSException($1); })" + "h$setCurrentThreadResultJSException" js_setCurrentThreadResultJSException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultHaskellException($1); })" + "h$setCurrentThreadResultHaskellException" js_setCurrentThreadResultHaskellException :: JSVal -> IO () foreign import javascript unsafe - "(($1) => { return h$setCurrentThreadResultValue($1); })" + "h$setCurrentThreadResultValue" js_setCurrentThreadResultValue :: JSVal -> IO () ===================================== libraries/base/src/System/Posix/Internals.hs ===================================== @@ -504,7 +504,7 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat" #if defined(javascript_HOST_ARCH) -foreign import javascript unsafe "(() => { return rts_isThreaded; })" rtsIsThreaded_ :: Int +foreign import javascript unsafe "h$rts_isThreaded" rtsIsThreaded_ :: Int foreign import javascript interruptible "h$base_access" c_access :: CString -> CInt -> IO CInt foreign import javascript interruptible "h$base_chmod" ===================================== rts/js/config.js ===================================== @@ -0,0 +1,21 @@ +function h$rts_isThreaded() { + return 0; +} + +function h$rts_isTracing() { + return 0; +} + +function h$rts_isDynamic() { + return 0; +} + +function h$rts_isDebugged() { + return 0; +} + +function h$rts_isProfiled() { + return 0; +} + + \ No newline at end of file ===================================== rts/js/thread.js ===================================== @@ -1460,5 +1460,3 @@ function h$makeMVarListener(mv, stopProp, stopImmProp, preventDefault) { function h$rs() { return h$stack[h$sp]; } - -const rts_isThreaded = 0; ===================================== rts/rts.cabal ===================================== @@ -99,6 +99,7 @@ library c-sources: version.c js-sources: + js/config.js js/structs.js js/arith.js js/compact.js ===================================== testsuite/driver/perf_notes.py ===================================== @@ -123,11 +123,6 @@ AllowedPerfChange = NamedTuple('AllowedPerfChange', ('opts', Dict[str, str]) ]) -MetricBaselineOracle = Callable[[WayName, GitHash], Baseline] -MetricDeviationOracle = Callable[[WayName, GitHash], Optional[float]] -MetricOracles = NamedTuple("MetricOracles", [("baseline", MetricBaselineOracle), - ("deviation", MetricDeviationOracle)]) - def parse_perf_stat(stat_str: str) -> PerfStat: field_vals = stat_str.strip('\t').split('\t') stat = PerfStat(*field_vals) # type: ignore ===================================== testsuite/driver/testglobals.py ===================================== @@ -4,7 +4,7 @@ from my_typing import * from pathlib import Path -from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles, GitRef +from perf_notes import MetricChange, PerfStat, Baseline, GitRef from datetime import datetime # ----------------------------------------------------------------------------- @@ -378,24 +378,20 @@ class TestOptions: # extra files to copy to the testdir self.extra_files = [] # type: List[str] - # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g. - # { 'bytes allocated': ( - # lambda way commit: - # ... - # if way1: return None ... - # elif way2:return 9300000000 ... - # ... - # , 10) } - # This means no baseline is available for way1. For way 2, allow a 10% - # deviation from 9300000000. - self.stats_range_fields = {} # type: Dict[MetricName, MetricOracles] - # Is the test testing performance? self.is_stats_test = False # Does this test the compiler's performance as opposed to the generated code. self.is_compiler_stats_test = False + # Map from metric to information about that metric + # { metric: { "deviation": + # The action to run to get the current value of the test + # , "action": lambda way: + # The action to run to get the baseline value of the test + # , "oracle": lambda way commit: baseline value } } + self.generic_stats_test: Dict = {} # Dict + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = False ===================================== testsuite/driver/testlib.py ===================================== @@ -28,7 +28,7 @@ from term_color import Color, colored import testutil from cpu_features import have_cpu_feature import perf_notes as Perf -from perf_notes import MetricChange, PerfStat, MetricOracles +from perf_notes import MetricChange, PerfStat extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -99,6 +99,10 @@ def isCompilerStatsTest() -> bool: opts = getTestOpts() return bool(opts.is_compiler_stats_test) +def isGenericStatsTest() -> bool: + opts = getTestOpts() + return bool(opts.generic_stats_test) + def isStatsTest() -> bool: opts = getTestOpts() return opts.is_stats_test @@ -599,6 +603,44 @@ def extra_files(files): def _extra_files(name, opts, files): opts.extra_files.extend(files) +# Record the size of a specific file +def collect_size ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) + +# Read a number from a specific file +def stat_from_file ( metric, deviation, path ): + def read_file (way): + with open(in_testdir(path)) as f: + return int(f.read()) + return collect_generic_stat ( metric, deviation, read_file ) + + +# Define a set of generic stat tests +def collect_generic_stats ( get_stats ): + def f(name, opts, f=get_stats): + return _collect_generic_stat(name, opts, get_stats) + return f + +# Define the a generic stat test, which computes the statistic by calling the function +# given as the third argument. +def collect_generic_stat ( metric, deviation, get_stat ): + return collect_generic_stats ( { metric: { 'deviation': deviation, 'action': get_stat } } ) + +def _collect_generic_stat(name : TestName, opts, get_stat): + + + # Add new stats to the stat list + opts.generic_stats_test.update(get_stat) + + # Add the "oracle" which determines the stat baseline + for (metric, info) in get_stat.items(): + def baselineByWay(way, target_commit, metric=metric): + return Perf.baseline_metric( \ + target_commit, name, config.test_env, metric, way, \ + config.baseline_commit ) + opts.generic_stats_test[metric]["oracle"] = baselineByWay + + # ----- # Defaults to "test everything, and only break on extreme cases" @@ -619,11 +661,14 @@ def _extra_files(name, opts, files): def collect_compiler_stats(metric='all',deviation=20): def f(name, opts, m=metric, d=deviation): no_lint(name, opts) - return _collect_stats(name, opts, m, d, True) + return _collect_stats(name, opts, m, d, None, True) return f -def collect_stats(metric='all', deviation=20): - return lambda name, opts, m=metric, d=deviation: _collect_stats(name, opts, m, d) +def collect_stats(metric='all', deviation=20, static_stats_file=None): + return lambda name, opts, m=metric, d=deviation, s=static_stats_file: _collect_stats(name, opts, m, d, s) + +def statsFile(comp_test: bool, name: str) -> str: + return name + ('.comp' if comp_test else '') + '.stats' # This is an internal function that is used only in the implementation. # 'is_compiler_stats_test' is somewhat of an unfortunate name. @@ -631,7 +676,7 @@ def collect_stats(metric='all', deviation=20): # measures the performance numbers of the compiler. # As this is a fairly rare case in the testsuite, it defaults to false to # indicate that it is a 'normal' performance test. -def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_test=False): +def _collect_stats(name: TestName, opts, metrics, deviation, static_stats_file, is_compiler_stats_test=False): if not re.match('^[0-9]*[a-zA-Z][a-zA-Z0-9._-]*$', name): failBecause('This test has an invalid name.') @@ -664,15 +709,41 @@ def _collect_stats(name: TestName, opts, metrics, deviation, is_compiler_stats_t # The nonmoving collector does not support -G1 _omit_ways(name, opts, [WayName(name) for name in ['nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']]) + # How to read the result of the performance test + def read_stats_file(way, metric_name): + # Confusingly compile time ghci tests are actually runtime tests, so we have + # to go and look for the name.stats file rather than name.comp.stats file. + compiler_stats_test = is_compiler_stats_test and not (way == "ghci" or way == "ghci-opt") + + if static_stats_file: + stats_file = in_statsdir(static_stats_file) + else: + stats_file = Path(in_testdir(statsFile(compiler_stats_test, name))) + + + try: + stats_file_contents = stats_file.read_text() + except IOError as e: + raise Exception(failBecause(str(e))) + field_match = re.search('\\("' + metric_name + '", "([0-9]+)"\\)', stats_file_contents) + if field_match is None: + print('Failed to find metric: ', metric_name) + raise Exception(failBecause("No such metric")) + else: + val = field_match.group(1) + assert val is not None + return int(val) + + + collect_stat = {} for metric_name in metrics: + def action_generator(mn): + return lambda way: read_stats_file(way, mn) metric = '{}/{}'.format(tag, metric_name) - def baselineByWay(way, target_commit, metric=metric): - return Perf.baseline_metric( \ - target_commit, name, config.test_env, metric, way, \ - config.baseline_commit ) + collect_stat[metric] = { "deviation": deviation + , "action": action_generator(metric_name) } - opts.stats_range_fields[metric] = MetricOracles(baseline=baselineByWay, - deviation=deviation) + _collect_generic_stat(name, opts, collect_stat) # ----- @@ -1581,6 +1652,11 @@ async def do_compile(name: TestName, diff_file_name.unlink() return failBecause('stderr mismatch', stderr=stderr) + opts = getTestOpts() + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult # no problems found, this test passed return passed() @@ -1717,13 +1793,9 @@ async def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ) async def warn_and_run( name, way, extra_hc_opts ): return await compile_and_run__( name, way, None, [], extra_hc_opts, compile_stderr = True) -def stats( name, way, stats_file ): - opts = getTestOpts() - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - -async def static_stats( name, way, stats_file ): +async def static_stats( name, way ): opts = getTestOpts() - return check_stats(name, way, in_statsdir(stats_file), opts.stats_range_fields) + return check_generic_stats(name, way, opts.generic_stats_test) def metric_dict(name, way, metric, value) -> PerfStat: return Perf.PerfStat( @@ -1733,75 +1805,58 @@ def metric_dict(name, way, metric, value) -> PerfStat: metric = metric, value = value) -# ----------------------------------------------------------------------------- -# Check test stats. This prints the results for the user. -# name: name of the test. -# way: the way. -# stats_file: the path of the stats_file containing the stats for the test. -# range_fields: see TestOptions.stats_range_fields -# Returns a pass/fail object. Passes if the stats are within the expected value ranges. -# This prints the results for the user. -def check_stats(name: TestName, - way: WayName, - stats_file: Path, - range_fields: Dict[MetricName, MetricOracles] - ) -> PassFail: + + +def check_generic_stats(name, way, get_stats): + for (metric, gen_stat) in get_stats.items(): + res = report_stats(name, way, metric, gen_stat) + if badResult(res): + return res + return passed() + +def report_stats(name, way, metric, gen_stat): + try: + actual_val = gen_stat['action'](way) + # Metrics can exit early by throwing an Exception with the desired result. + # This is used for both failure, and skipping computing the metric. + except Exception as e: + result = e.args[0] + return result + head_commit = Perf.commit_hash(GitRef('HEAD')) if Perf.inside_git_repo() else None if head_commit is None: return passed() result = passed() - if range_fields: - try: - stats_file_contents = stats_file.read_text() - except IOError as e: - return failBecause(str(e)) - - for (metric, baseline_and_dev) in range_fields.items(): - # Remove any metric prefix e.g. "runtime/" and "compile_time/" - stat_file_metric = metric.split("/")[-1] - perf_change = None - - field_match = re.search('\\("' + stat_file_metric + '", "([0-9]+)"\\)', stats_file_contents) - if field_match is None: - print('Failed to find metric: ', stat_file_metric) - result = failBecause('no such stats metric') - else: - val = field_match.group(1) - assert val is not None - actual_val = int(val) - - # Store the metric so it can later be stored in a git note. - perf_stat = metric_dict(name, way, metric, actual_val) - - # If this is the first time running the benchmark, then pass. - baseline = baseline_and_dev.baseline(way, head_commit) \ - if Perf.inside_git_repo() else None - if baseline is None: - metric_result = passed() - perf_change = MetricChange.NewMetric - else: - tolerance_dev = baseline_and_dev.deviation - (perf_change, metric_result) = Perf.check_stats_change( - perf_stat, - baseline, - tolerance_dev, - config.allowed_perf_changes, - config.verbose >= 4) - - t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) - - # If any metric fails then the test fails. - # Note, the remaining metrics are still run so that - # a complete list of changes can be presented to the user. - if not metric_result.passed: - if config.ignore_perf_increases and perf_change == MetricChange.Increase: - metric_result = passed() - elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: - metric_result = passed() - - result = metric_result - + # Store the metric so it can later be stored in a git note. + perf_stat = metric_dict(name, way, metric, actual_val) + + # If this is the first time running the benchmark, then pass. + baseline = gen_stat['oracle'](way, head_commit) \ + if Perf.inside_git_repo() else None + if baseline is None: + metric_result = passed() + perf_change = MetricChange.NewMetric + else: + (perf_change, metric_result) = Perf.check_stats_change( + perf_stat, + baseline, + gen_stat["deviation"], + config.allowed_perf_changes, + config.verbose >= 4) + + t.metrics.append(PerfMetric(change=perf_change, stat=perf_stat, baseline=baseline)) + + # If any metric fails then the test fails. + # Note, the remaining metrics are still run so that + # a complete list of changes can be presented to the user. + if not metric_result.passed: + if config.ignore_perf_increases and perf_change == MetricChange.Increase: + metric_result = passed() + elif config.ignore_perf_decreases and perf_change == MetricChange.Decrease: + metric_result = passed() + + result = metric_result return result # ----------------------------------------------------------------------------- @@ -1863,8 +1918,8 @@ async def simple_build(name: Union[TestName, str], else: to_do = '-c' # just compile - stats_file = name + '.comp.stats' if isCompilerStatsTest(): + stats_file = statsFile(True, name) # Set a bigger chunk size to reduce variation due to additional under/overflowing # The tests are attempting to test how much work the compiler is doing by proxy of # bytes allocated. The additional allocations caused by stack overflow can cause @@ -1913,10 +1968,6 @@ async def simple_build(name: Union[TestName, str], stderr_contents = actual_stderr_path.read_text(encoding='UTF-8', errors='replace') return failBecause('exit code non-0', stderr=stderr_contents) - if isCompilerStatsTest(): - statsResult = check_stats(TestName(name), way, in_testdir(stats_file), opts.stats_range_fields) - if badResult(statsResult): - return statsResult return passed() @@ -1953,7 +2004,7 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st # assume we are running a program via ghci. Collect stats stats_file = None # type: Optional[str] if isStatsTest() and (not isCompilerStatsTest() or way == 'ghci' or way == 'ghci-opt'): - stats_file = name + '.stats' + stats_file = statsFile(False, name) stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS' else: stats_args = '' @@ -1999,11 +2050,13 @@ async def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: st if check_prof and not await check_prof_ok(name, way): return failBecause('bad profile') - # Check runtime stats if desired. - if stats_file is not None: - return check_stats(name, way, in_testdir(stats_file), opts.stats_range_fields) - else: - return passed() + # Check the results of stats tests + if isGenericStatsTest(): + statsResult = check_generic_stats(TestName(name), way, opts.generic_stats_test) + if badResult(statsResult): + return statsResult + + return passed() def rts_flags(way: WayName) -> str: args = config.way_rts_flags.get(way, []) ===================================== testsuite/tests/count-deps/Makefile ===================================== @@ -16,8 +16,10 @@ LIBDIR := "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" .PHONY: count-deps-parser count-deps-parser: - $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" + $(COUNT_DEPS) $(LIBDIR) "GHC.Parser" | tee out + cat out | tail -n +2 | wc -l > SIZE .PHONY: count-deps-ast count-deps-ast: - $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" + $(COUNT_DEPS) $(LIBDIR) "Language.Haskell.Syntax" | tee out + cat out | tail -n +2 | wc -l > SIZE ===================================== testsuite/tests/count-deps/all.T ===================================== @@ -1,2 +1,2 @@ -test('CountDepsAst', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) -test('CountDepsParser', [req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) +test('CountDepsAst', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-ast']) +test('CountDepsParser', [stat_from_file('deps', 100, 'SIZE'), req_hadrian_deps(["test:count-deps"])], makefile_test, ['count-deps-parser']) ===================================== testsuite/tests/perf/haddock/all.T ===================================== @@ -19,21 +19,21 @@ test('haddock.base', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',5) + ,collect_stats('bytes allocated',5, static_stats_file='base.t') ], static_stats, - ['base.t']) + []) test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',5) + ,collect_stats('bytes allocated',5, static_stats_file='Cabal.t') ], static_stats, - ['Cabal.t']) + []) test('haddock.compiler', [unless(in_tree_compiler(), skip), req_haddock - ,collect_stats('bytes allocated',10) + ,collect_stats('bytes allocated',10, static_stats_file='ghc.t') ], static_stats, - ['ghc.t']) + []) ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -0,0 +1,7 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +libdir_size: + du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE + ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -0,0 +1,3 @@ +test('size_hello', [collect_size(3, 'size_hello.o')], compile, ['']) + +test('libdir',[stat_from_file('size', 3, 'SIZE')], makefile_test, ['libdir_size'] ) ===================================== testsuite/tests/perf/size/size_hello.hs ===================================== @@ -0,0 +1,3 @@ +module Main where + +main = print "Hello World!" ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2501357cd055978a6ac944034b04824f9131c59a...294f189f72dde6731e825911c9ca190bba250e88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2501357cd055978a6ac944034b04824f9131c59a...294f189f72dde6731e825911c9ca190bba250e88 You're receiving 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 Nov 19 14:30:18 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 19 Nov 2023 09:30:18 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-srcspan-in-epaspan Message-ID: <655a1bf9e2e9a_14c49b37e9ec3820644e@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-srcspan-in-epaspan at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-srcspan-in-epaspan You're receiving 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 Nov 19 17:19:34 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 19 Nov 2023 12:19:34 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/DataToTagSmallOp Message-ID: <655a43a6f2772_14c49b3bc22fc8210797@gitlab.mail> Matthew Craven pushed new branch wip/DataToTagSmallOp at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/DataToTagSmallOp You're receiving 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 Nov 19 17:46:09 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 19 Nov 2023 12:46:09 -0500 Subject: [Git][ghc/ghc][wip/DataToTagSmallOp] 2 commits: Introduce `dataToTagSmall#` primop (closes #21710) Message-ID: <655a49e163df8_14c49b3c87bfcc214974@gitlab.mail> Matthew Craven pushed to branch wip/DataToTagSmallOp at Glasgow Haskell Compiler / GHC Commits: 31652638 by Matthew Craven at 2023-11-19T12:44:05-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. - - - - - 1728dbb4 by Matthew Craven at 2023-11-19T12:45:15-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 17 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Instance/Class.hs - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - testsuite/tests/codeGen/should_compile/T21710a.stderr - testsuite/tests/linters/notes.stdout - testsuite/tests/simplCore/should_compile/T22375.hs - testsuite/tests/simplCore/should_compile/T22375.stderr - testsuite/tests/simplCore/should_compile/T22375DataFamily.hs - testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr Changes: ===================================== compiler/GHC/Builtin/PrimOps.hs ===================================== @@ -921,5 +921,6 @@ instance Outputable PrimCall where primOpIsReallyInline :: PrimOp -> Bool primOpIsReallyInline = \case SeqOp -> False - DataToTagOp -> False + DataToTagSmallOp -> False + DataToTagLargeOp -> False p -> not (primOpOutOfLine p) ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3689,7 +3689,27 @@ section "Tag to enum stuff" and small integers.} ------------------------------------------------------------------------ -primop DataToTagOp "dataToTagLarge#" GenPrimOp +primop DataToTagSmallOp "dataToTagSmall#" GenPrimOp + a_levpoly -> Int# + { Used internally to implement @dataToTag#@: Use that function instead! + This one offers /no advantage/ and comes with no stability + guarantees: it may change its type, its name, or its behavior + with /no warning/ between compiler releases. + + It is expected that this function will be un-exposed in a future + release of ghc. + + For more details, look at @Note [DataToTag overview]@ + in GHC.Tc.Instance.Class in the source code for + /the specific compiler version you are using./ + } + with + deprecated_msg = { Use dataToTag# from \"GHC.Magic\" instead. } + strictness = { \ _arity -> mkClosedDmdSig [evalDmd] topDiv } + effect = ThrowsException + cheap = True + +primop DataToTagLargeOp "dataToTagLarge#" GenPrimOp a_levpoly -> Int# { Used internally to implement @dataToTag#@: Use that function instead! This one offers /no advantage/ and comes with no stability ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1142,7 +1142,8 @@ checkDataToTagPrimOpTyCon -> [CoreArg] -- ^ The arguments to the application -> LintM () checkDataToTagPrimOpTyCon (Var fun_id) args - | Just DataToTagOp <- isPrimOpId_maybe fun_id + | Just op <- isPrimOpId_maybe fun_id + , op == DataToTagSmallOp || op == DataToTagLargeOp = case args of Type _levity : Type dty : _rest | Just (tc, _) <- splitTyConApp_maybe dty ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -102,7 +102,8 @@ That is why these rules are built in here. primOpRules :: Name -> PrimOp -> Maybe CoreRule primOpRules nm = \case TagToEnumOp -> mkPrimOpRule nm 2 [ tagToEnumRule ] - DataToTagOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagSmallOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagLargeOp -> mkPrimOpRule nm 3 [ dataToTagRule ] -- Int8 operations Int8AddOp -> mkPrimOpRule nm 2 [ binaryLit (int8Op2 (+)) @@ -3374,7 +3375,8 @@ caseRules platform (App (App (Var f) type_arg) v) -- See Note [caseRules for dataToTag] caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x - | Just DataToTagOp <- isPrimOpId_maybe f + | Just op <- isPrimOpId_maybe f + , op == DataToTagSmallOp || op == DataToTagLargeOp = case splitTyConApp_maybe ty of Just (tc, _) | isValidDTT2TyCon tc -> Just (v, tx_con_dtt tc @@ -3382,9 +3384,9 @@ caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x _ -> pprTraceUserWarning warnMsg Nothing where warnMsg = vcat $ map text - [ "Found dataToTag primop applied to a non-ADT type. This" - , "could be a future bug in GHC, or it may be caused by an" - , "unsupported use of the ghc-internal primop dataToTagLarge#." + [ "Found dataToTag primop applied to a non-ADT type. This could" + , "be a future bug in GHC, or it may be caused by an unsupported" + , "use of the ghc-internal primops dataToTagSmall# and dataToTagLarge#." , "In either case, the GHC developers would like to know about it!" , "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug" ] ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -495,10 +495,9 @@ occurrence of `x` and `y` to record whether it is evaluated and properly tagged. For the vast majority of primops that's a waste of time: the argument is an `Int#` or something. -But code generation for `seq#` and `dataToTagLarge#` /does/ consult that -tag, to statically avoid generating an eval: -* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig` -* `dataToTagLarge#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`. +But code generation for `seq#` and the `dataToTag#` ops /does/ consult that +tag, to statically avoid generating an eval. All three do so via `cgIdApp`, +which in turn uses `getCallMethod` which looks at the `tagSig`. So for these we should call `rewriteArgs`. @@ -507,7 +506,7 @@ So for these we should call `rewriteArgs`. rewriteOpApp :: InferStgExpr -> RM TgStgExpr rewriteOpApp (StgOpApp op args res_ty) = case op of op@(StgPrimOp primOp) - | primOp == SeqOp || primOp == DataToTagOp + | primOp == SeqOp || primOp == DataToTagSmallOp || primOp == DataToTagLargeOp -- see Note [Rewriting primop arguments] -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty _ -> pure $! StgOpApp op args res_ty ===================================== compiler/GHC/StgToCmm/Expr.hs ===================================== @@ -37,7 +37,7 @@ import GHC.Cmm.Graph import GHC.Cmm.BlockId import GHC.Cmm hiding ( succ ) import GHC.Cmm.Info -import GHC.Cmm.Utils ( zeroExpr, cmmTagMask, mkWordCLit, mAX_PTR_TAG ) +import GHC.Cmm.Utils ( cmmTagMask, mkWordCLit, mAX_PTR_TAG ) import GHC.Core import GHC.Core.DataCon import GHC.Types.ForeignCall @@ -73,55 +73,49 @@ cgExpr (StgApp fun args) = cgIdApp fun args cgExpr (StgOpApp (StgPrimOp SeqOp) [StgVarArg a, _] _res_ty) = cgIdApp a [] +-- dataToTagSmall# :: a_levpoly -> Int# +-- See Note [DataToTag overview] in GHC.Tc.Instance.Class +cgExpr (StgOpApp (StgPrimOp DataToTagSmallOp) [StgVarArg a] _res_ty) = do + platform <- getPlatform + emitComment (mkFastString "dataToTagSmall#") + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + tag1 = cmmConstrTag1 platform a_eval_expr + + -- subtract 1 because we need to return a zero-indexed tag + emitReturn [cmmSubWord platform tag1 (CmmLit $ mkWordCLit platform 1)] + -- dataToTagLarge# :: a_levpoly -> Int# -- See Note [DataToTag overview] in GHC.Tc.Instance.Class --- TODO: There are some more optimization ideas for this code path --- in #21710 -cgExpr (StgOpApp (StgPrimOp DataToTagOp) [StgVarArg a] _res_ty) = do +cgExpr (StgOpApp (StgPrimOp DataToTagLargeOp) [StgVarArg a] _res_ty) = do platform <- getPlatform emitComment (mkFastString "dataToTagLarge#") - info <- getCgIdInfo a - let amode = idInfoToAmode info - tag_reg <- assignTemp $ cmmConstrTag1 platform amode + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + + tag1_reg <- assignTemp $ cmmConstrTag1 platform a_eval_expr result_reg <- newTemp (bWord platform) - let tag = CmmReg $ CmmLocal tag_reg - is_tagged = cmmNeWord platform tag (zeroExpr platform) - is_too_big_tag = cmmEqWord platform tag (cmmTagMask platform) - -- Here we will first check the tag bits of the pointer we were given; - -- if this doesn't work then enter the closure and use the info table - -- to determine the constructor. Note that all tag bits set means that - -- the constructor index is too large to fit in the pointer and therefore - -- we must look in the info table. See Note [Tagging big families]. - - (fast_path :: CmmAGraph) <- getCode $ do - -- Return the constructor index from the pointer tag - return_ptr_tag <- getCode $ do - emitAssign (CmmLocal result_reg) - $ cmmSubWord platform tag (CmmLit $ mkWordCLit platform 1) - -- Return the constructor index recorded in the info table - return_info_tag <- getCode $ do - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform amode) - - emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) - -- If we know the argument is already tagged there is no need to generate code to evaluate it - -- so we skip straight to the fast path. If we don't know if there is a tag we take the slow - -- path which evaluates the argument before fetching the tag. - case (idTagSig_maybe a) of - Just sig - | isTaggedSig sig - -> emit fast_path - _ -> do - slow_path <- getCode $ do - tmp <- newTemp (bWord platform) - _ <- withSequel (AssignTo [tmp] False) (cgIdApp a []) - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform (CmmReg (CmmLocal tmp))) - emit =<< mkCmmIfThenElse' is_tagged fast_path slow_path (Just True) + let tag1_expr = CmmReg $ CmmLocal tag1_reg + is_too_big_tag = cmmEqWord platform tag1_expr (cmmTagMask platform) + + -- Return the constructor index from the pointer tag + -- (Used if pointer tag is small enough to be unambiguous) + return_ptr_tag <- getCode $ do + emitAssign (CmmLocal result_reg) + $ cmmSubWord platform tag1_expr (CmmLit $ mkWordCLit platform 1) + + -- Return the constructor index recorded in the info table + return_info_tag <- getCode $ do + profile <- getProfile + align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig + emitAssign (CmmLocal result_reg) + $ getConstrTag profile align_check (cmmUntag platform a_eval_expr) + + emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) emitReturn [CmmReg $ CmmLocal result_reg] @@ -638,9 +632,10 @@ isSimpleScrut _ _ = return False isSimpleOp :: StgOp -> [StgArg] -> FCode Bool -- True iff the op cannot block or allocate isSimpleOp (StgFCallOp (CCall (CCallSpec _ _ safe)) _) _ = return $! not (playSafe safe) --- dataToTagLarge# evaluates its argument; +-- dataToTagSmall#/dataToTagLarge# evaluate an argument; -- see Note [DataToTag overview] in GHC.Tc.Instance.Class -isSimpleOp (StgPrimOp DataToTagOp) _ = return False +isSimpleOp (StgPrimOp DataToTagSmallOp) _ = return False +isSimpleOp (StgPrimOp DataToTagLargeOp) _ = return False isSimpleOp (StgPrimOp op) stg_args = do arg_exprs <- getNonVoidArgAmodes stg_args cfg <- getStgToCmmConfig @@ -851,6 +846,7 @@ cgAlts _ _ _ _ = panic "cgAlts" -- Note [alg-alt heap check] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- In an algebraic case with more than one alternative, we will have -- code like ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1640,7 +1640,8 @@ emitPrimOp cfg primop = SeqOp -> alwaysExternal GetSparkOp -> alwaysExternal NumSparks -> alwaysExternal - DataToTagOp -> alwaysExternal + DataToTagSmallOp -> alwaysExternal + DataToTagLargeOp -> alwaysExternal MkApUpd0_Op -> alwaysExternal NewBCOOp -> alwaysExternal UnpackClosureOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -967,7 +967,11 @@ genPrim prof bound ty op = case op of ------------------------------ Tag to enum stuff -------------------------------- - DataToTagOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + DataToTagSmallOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + [ stack .! PreInc sp |= var "h$dataToTag_e" + , returnS (app "h$e" [d]) + ] + DataToTagLargeOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat [ stack .! PreInc sp |= var "h$dataToTag_e" , returnS (app "h$e" [d]) ] ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -50,6 +50,8 @@ import GHC.Core.Class import GHC.Core ( Expr(..) ) +import GHC.StgToCmm.Closure ( isSmallFamily ) + import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc( splitAtList, fstOf3 ) @@ -671,15 +673,17 @@ But, to avoid all this boilerplate code, and improve optimisation opportunities, GHC generates instances like this: instance DataToTag [a] where - dataToTag# = dataToTagLarge# + dataToTag# = dataToTagSmall# -using a (temporarily strangely-named) primop `dataToTagLarge#`. The -primop has the following over-polymorphic type +using one of two dedicated primops: `dataToTagSmall#` and `dataToTagLarge#`. +(These two primops differ only in code generation; see wrinkle DTW4 below.) +Both primops have the following over-polymorphic type: dataToTagLarge# :: forall {l::levity} (a::TYPE (BoxedRep l)). a -> Int# -Every call to (dataToTagLarge# @{lev} @ty) that we generate should -satisfy these conditions: +Every call to either primop that we generate should look like +(dataToTagSmall# @{lev} @ty) with two type arguments that satisfy +these conditions: (DTT1) `lev` is concrete (either lifted or unlifted), not polymorphic. This is an invariant--we must satisfy this or Core Lint will complain. @@ -698,21 +702,21 @@ satisfy these conditions: GHC.Rename.Module. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold for why this matters. - While the dataToTagLarge# primop remains exposed from GHC.Prim + While the dataToTag# primops remain exposed from GHC.Prim (and abused in GHC.PrimopWrappers), this cannot be a true invariant. - But with a little effort we can ensure that every `dataToTagLarge#` + But with a little effort we can ensure that every primop call we generate in a DataToTag instance satisfies this condition. -The `dataToTagLarge#` primop has special handling in several parts of +These two primops have special handling in several parts of the compiler: -- It has a couple of built-in rewrite rules, implemented in +- They have a couple of built-in rewrite rules, implemented in GHC.Core.Opt.ConstantFold.dataToTagRule -- The simplifier rewrites most case expressions scrutinizing its result. +- The simplifier rewrites most case expressions scrutinizing their result. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold. -- It evaluates its argument; this is implemented via a special case in +- Each evaluates its argument; this is implemented via special cases in GHC.StgToCmm.Expr.cgExpr. - Additionally, a special case in GHC.Stg.InferTags.Rewrite.rewriteExpr ensures @@ -727,12 +731,12 @@ Wrinkles: [W] DataToTag (D (Either t1 t2)) GHC uses the built-in instance instance DataToTag (D (Either p q)) where - dataToTag# x = dataToTagLarge# @Lifted @(R:DEither p q) + dataToTag# x = dataToTagSmall# @Lifted @(R:DEither p q) (x |> sym (ax:DEither p q)) where `ax:DEither` is the axiom arising from the `data instance`: ax:DEither p q :: D (Either p q) ~ R:DEither p q - Notice that we cast `x` before giving it to `dataToTagLarge#`, so + Notice that we cast `x` before giving it to `dataToTagSmall#`, so that (DTT2) is satisfied. (DTW2) Suppose we have module A (T(..)) where { data T = TCon } @@ -747,7 +751,7 @@ Wrinkles: (DTW3) Similar to DTW2, consider this example: {-# LANGUAGE MagicHash #-} - module A (X(X2, X3), f) where + module A (X(X2, X3), g) where -- see also testsuite/tests/warnings/should_compile/DataToTagWarnings.hs import GHC.Exts (dataToTag#, Int#) data X = X1 | X2 | X3 | X4 @@ -774,10 +778,18 @@ Wrinkles: keepAlive on the constructor names. (Contrast with Note [Unused name reporting and HasField].) -(DTW4) It is expected that in the future some instances may select more - efficient specialised implementations; for example we may use a - separate `dataToTagSmall#` primop for a type with only a few - constructors; see #17079 and #21710. +(DTW4) The way tag information is stored at runtime is described in + Note [Tagging big families] in GHC.StgToCmm.Expr. In particular, + for "big data types" we must consult the heap object's info table at + least in the MAX_PTR_TAG case, while for "small data types" we can + always just examine the tag bits on the pointer itself. + + Although it is always correct to consult the info table, we can + produce slightly smaller and faster code by not doing so for "small + data types." Since types and coercions are largely erased in STG, + the simplest reliable way to achieve this is to produce different + primops in DataToTag instances depending on the number of data + constructors the relevant TyCon has. (DTW5) We make no promises about the primops used to implement DataToTag instances. Changes to GHC's representation of algebraic @@ -816,6 +828,7 @@ matchDataToTag :: Class -> [Type] -> TcM ClsInstResult matchDataToTag dataToTagClass [levity, dty] = do famEnvs <- tcGetFamInstEnvs (gbl_env, _lcl_env) <- getEnvs + platform <- getPlatform if | isConcreteType levity -- condition C3 , Just (rawTyCon, rawTyConArgs) <- tcSplitTyConApp_maybe dty , let (repTyCon, repArgs, repCo) @@ -828,13 +841,14 @@ matchDataToTag dataToTagClass [levity, dty] = do , let rdr_env = tcg_rdr_env gbl_env inScope con = isJust $ lookupGRE_Name rdr_env $ dataConName con , all inScope constrs -- condition C2 + , let repTy = mkTyConApp repTyCon repArgs - whichOp - -- TODO: More optimized implementations for: - -- * small constructor families - -- * Bool/Int/Float/etc. on JS backend + numConstrs = tyConFamilySize repTyCon + !whichOp -- see wrinkle DTW4 + | isSmallFamily platform numConstrs + = primOpId DataToTagSmallOp | otherwise - = primOpId DataToTagOp + = primOpId DataToTagLargeOp -- See wrinkle DTW1; we must apply the underlying -- operation at the representation type and cast it ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,8 +117,8 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,8 +133,8 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== testsuite/tests/codeGen/should_compile/T21710a.stderr ===================================== @@ -1,117 +1,44 @@ -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'E2_bytes" { - M.$tc'E2_bytes: - I8[] "'E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'D2_bytes" { - M.$tc'D2_bytes: - I8[] "'D" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'C2_bytes" { - M.$tc'C2_bytes: - I8[] "'C" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'B2_bytes" { - M.$tc'B2_bytes: - I8[] "'B" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'A3_bytes" { - M.$tc'A3_bytes: - I8[] "'A" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tcE2_bytes" { - M.$tcE2_bytes: - I8[] "E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule2_bytes" { - M.$trModule2_bytes: - I8[] "M" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule4_bytes" { - M.$trModule4_bytes: - I8[] "main" - }] - - - ==================== Output Cmm ==================== [M.foo_entry() { // [R2] - { info_tbls: [(cBa, - label: block_cBa_info + { info_tbls: [(cCU, + label: block_cCU_info rep: StackRep [] srt: Nothing), - (cBi, + (cD2, label: M.foo_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cBi: // global - if ((Sp + -8) < SpLim) (likely: False) goto cBj; else goto cBk; // CmmCondBranch - cBj: // global + cD2: // global + if ((Sp + -8) < SpLim) (likely: False) goto cD3; else goto cD4; // CmmCondBranch + cD3: // global R1 = M.foo_closure; // CmmAssign call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall - cBk: // global - I64[Sp - 8] = cBa; // CmmStore + cD4: // global + I64[Sp - 8] = cCU; // CmmStore R1 = R2; // CmmAssign Sp = Sp - 8; // CmmAssign - if (R1 & 7 != 0) goto cBa; else goto cBb; // CmmCondBranch - cBb: // global - call (I64[R1])(R1) returns to cBa, args: 8, res: 8, upd: 8; // CmmCall - cBa: // global - _cBh::P64 = R1 & 7; // CmmAssign - if (_cBh::P64 != 1) goto uBz; else goto cBf; // CmmCondBranch - uBz: // global - if (_cBh::P64 != 2) goto cBe; else goto cBg; // CmmCondBranch - cBe: // global - // dataToTag# - _cBn::P64 = R1 & 7; // CmmAssign - if (_cBn::P64 == 7) (likely: False) goto cBs; else goto cBr; // CmmCondBranch - cBs: // global - _cBo::I64 = %MO_UU_Conv_W32_W64(I32[I64[R1 & (-8)] - 4]); // CmmAssign - goto cBq; // CmmBranch - cBr: // global - _cBo::I64 = _cBn::P64 - 1; // CmmAssign - goto cBq; // CmmBranch - cBq: // global - R1 = _cBo::I64; // CmmAssign + if (R1 & 7 != 0) goto cCU; else goto cCV; // CmmCondBranch + cCV: // global + call (I64[R1])(R1) returns to cCU, args: 8, res: 8, upd: 8; // CmmCall + cCU: // global + _cD1::P64 = R1 & 7; // CmmAssign + if (_cD1::P64 != 1) goto uDf; else goto cCZ; // CmmCondBranch + uDf: // global + if (_cD1::P64 != 2) goto cCY; else goto cD0; // CmmCondBranch + cCY: // global + // dataToTagSmall# + R1 = R1 & 7 - 1; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBg: // global + cD0: // global R1 = 42; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBf: // global + cCZ: // global R1 = 2; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall @@ -124,190 +51,6 @@ -==================== Output Cmm ==================== -[section ""data" . M.$trModule3_closure" { - M.$trModule3_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule4_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule1_closure" { - M.$trModule1_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule_closure" { - M.$trModule_closure: - const GHC.Types.Module_con_info; - const M.$trModule3_closure+1; - const M.$trModule1_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE1_closure" { - M.$tcE1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tcE2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE_closure" { - M.$tcE_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tcE1_closure+1; - const GHC.Types.krep$*_closure+5; - const 10475418246443540865; - const 12461417314693222409; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A1_closure" { - M.$tc'A1_closure: - const GHC.Types.KindRepTyConApp_con_info; - const M.$tcE_closure+1; - const GHC.Types.[]_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A2_closure" { - M.$tc'A2_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'A3_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A_closure" { - M.$tc'A_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'A2_closure+1; - const M.$tc'A1_closure+1; - const 10991425535368257265; - const 3459663971500179679; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B1_closure" { - M.$tc'B1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'B2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B_closure" { - M.$tc'B_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'B1_closure+1; - const M.$tc'A1_closure+1; - const 13038863156169552918; - const 13430333535161531545; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C1_closure" { - M.$tc'C1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'C2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C_closure" { - M.$tc'C_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'C1_closure+1; - const M.$tc'A1_closure+1; - const 8482817676735632621; - const 8146597712321241387; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D1_closure" { - M.$tc'D1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'D2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D_closure" { - M.$tc'D_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'D1_closure+1; - const M.$tc'A1_closure+1; - const 7525207739284160575; - const 13746130127476219356; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E1_closure" { - M.$tc'E1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'E2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E_closure" { - M.$tc'E_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'E1_closure+1; - const M.$tc'A1_closure+1; - const 6748545530683684316; - const 10193016702094081137; - const 0; - const 3; - }] - - - ==================== Output Cmm ==================== [section ""data" . M.A_closure" { M.A_closure: @@ -362,14 +105,14 @@ ==================== Output Cmm ==================== [M.A_con_entry() { // [] - { info_tbls: [(cC5, + { info_tbls: [(cDt, label: M.A_con_info rep: HeapRep 1 nonptrs { Con {tag: 0 descr:"main:M.A"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cC5: // global + cDt: // global R1 = R1 + 1; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -379,14 +122,14 @@ ==================== Output Cmm ==================== [M.B_con_entry() { // [] - { info_tbls: [(cCa, + { info_tbls: [(cDy, label: M.B_con_info rep: HeapRep 1 nonptrs { Con {tag: 1 descr:"main:M.B"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCa: // global + cDy: // global R1 = R1 + 2; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -396,14 +139,14 @@ ==================== Output Cmm ==================== [M.C_con_entry() { // [] - { info_tbls: [(cCf, + { info_tbls: [(cDD, label: M.C_con_info rep: HeapRep 1 nonptrs { Con {tag: 2 descr:"main:M.C"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCf: // global + cDD: // global R1 = R1 + 3; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -413,14 +156,14 @@ ==================== Output Cmm ==================== [M.D_con_entry() { // [] - { info_tbls: [(cCk, + { info_tbls: [(cDI, label: M.D_con_info rep: HeapRep 1 nonptrs { Con {tag: 3 descr:"main:M.D"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCk: // global + cDI: // global R1 = R1 + 4; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -430,14 +173,14 @@ ==================== Output Cmm ==================== [M.E_con_entry() { // [] - { info_tbls: [(cCp, + { info_tbls: [(cDN, label: M.E_con_info rep: HeapRep 1 nonptrs { Con {tag: 4 descr:"main:M.E"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCp: // global + cDN: // global R1 = R1 + 5; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,41 +1,40 @@ -ref compiler/GHC/Core/Coercion/Axiom.hs:463:2: Note [RoughMap and rm_empty] -ref compiler/GHC/Core/Opt/OccurAnal.hs:983:7: Note [Loop breaking] -ref compiler/GHC/Core/Opt/SetLevels.hs:1574:30: Note [Top level scope] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2826:13: Note [Case binder next] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4018:8: Note [Lambda-bound unfoldings] -ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1343:37: Note [Gentle mode] -ref compiler/GHC/Core/Opt/Specialise.hs:1765:29: Note [Arity decrease] -ref compiler/GHC/Core/TyCo/Rep.hs:1565:31: Note [What prevents a constraint from floating] -ref compiler/GHC/Driver/DynFlags.hs:1245:49: Note [Eta-reduction in -O0] -ref compiler/GHC/Driver/Main.hs:1762:34: Note [simpleTidyPgm - mkBootModDetailsTc] -ref compiler/GHC/Hs/Expr.hs:194:63: Note [Pending Splices] -ref compiler/GHC/Hs/Expr.hs:1738:87: Note [Lifecycle of a splice] -ref compiler/GHC/Hs/Expr.hs:1774:7: Note [Pending Splices] -ref compiler/GHC/Hs/Extension.hs:146:5: Note [Strict argument type constraints] -ref compiler/GHC/Hs/Pat.hs:143:74: Note [Lifecycle of a splice] -ref compiler/GHC/HsToCore/Pmc/Solver.hs:858:20: Note [COMPLETE sets on data families] -ref compiler/GHC/HsToCore/Quote.hs:1476:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Stg/Unarise.hs:442:32: Note [Renaming during unarisation] -ref compiler/GHC/StgToCmm/Expr.hs:585:4: Note [case on bool] -ref compiler/GHC/StgToCmm/Expr.hs:853:3: Note [alg-alt heap check] +ref compiler/GHC/Core/Coercion/Axiom.hs:472:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/OccurAnal.hs:1157:7: Note [Loop breaking] +ref compiler/GHC/Core/Opt/SetLevels.hs:1586:30: Note [Top level scope] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2832:13: Note [Case binder next] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4023:8: Note [Lambda-bound unfoldings] +ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1342:37: Note [Gentle mode] +ref compiler/GHC/Core/Opt/Specialise.hs:1763:29: Note [Arity decrease] +ref compiler/GHC/Core/TyCo/Rep.hs:1652:31: Note [What prevents a constraint from floating] +ref compiler/GHC/Driver/DynFlags.hs:1251:52: Note [Eta-reduction in -O0] +ref compiler/GHC/Driver/Main.hs:1749:34: Note [simpleTidyPgm - mkBootModDetailsTc] +ref compiler/GHC/Hs/Expr.hs:191:63: Note [Pending Splices] +ref compiler/GHC/Hs/Expr.hs:1727:87: Note [Lifecycle of a splice] +ref compiler/GHC/Hs/Expr.hs:1763:7: Note [Pending Splices] +ref compiler/GHC/Hs/Extension.hs:147:5: Note [Strict argument type constraints] +ref compiler/GHC/Hs/Pat.hs:141:74: Note [Lifecycle of a splice] +ref compiler/GHC/HsToCore/Pmc/Solver.hs:856:20: Note [COMPLETE sets on data families] +ref compiler/GHC/HsToCore/Quote.hs:1487:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Stg/Unarise.hs:438:32: Note [Renaming during unarisation] +ref compiler/GHC/StgToCmm/Expr.hs:578:4: Note [case on bool] ref compiler/GHC/Tc/Gen/HsType.hs:556:56: Note [Skolem escape prevention] -ref compiler/GHC/Tc/Gen/HsType.hs:2621:7: Note [Matching a kind signature with a declaration] -ref compiler/GHC/Tc/Gen/Pat.hs:176:20: Note [Typing patterns in pattern bindings] -ref compiler/GHC/Tc/Gen/Pat.hs:1127:7: Note [Matching polytyped patterns] -ref compiler/GHC/Tc/Gen/Sig.hs:81:10: Note [Overview of type signatures] -ref compiler/GHC/Tc/Gen/Splice.hs:356:16: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:531:35: Note [PendingRnSplice] -ref compiler/GHC/Tc/Gen/Splice.hs:655:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:888:11: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Instance/Family.hs:474:35: Note [Constrained family instances] -ref compiler/GHC/Tc/Solver/Rewrite.hs:1009:7: Note [Stability of rewriting] -ref compiler/GHC/Tc/TyCl.hs:1130:6: Note [Unification variables need fresh Names] -ref compiler/GHC/Tc/Types/Constraint.hs:226:34: Note [NonCanonical Semantics] -ref compiler/GHC/Types/Demand.hs:302:25: Note [Preserving Boxity of results is rarely a win] -ref compiler/GHC/Unit/Module/Deps.hs:81:13: Note [Structure of dep_boot_mods] +ref compiler/GHC/Tc/Gen/HsType.hs:2676:7: Note [Matching a kind signature with a declaration] +ref compiler/GHC/Tc/Gen/Pat.hs:174:20: Note [Typing patterns in pattern bindings] +ref compiler/GHC/Tc/Gen/Pat.hs:1163:7: Note [Matching polytyped patterns] +ref compiler/GHC/Tc/Gen/Sig.hs:80:10: Note [Overview of type signatures] +ref compiler/GHC/Tc/Gen/Splice.hs:358:16: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:533:35: Note [PendingRnSplice] +ref compiler/GHC/Tc/Gen/Splice.hs:657:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:891:11: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Instance/Family.hs:406:35: Note [Constrained family instances] +ref compiler/GHC/Tc/Solver/Rewrite.hs:1010:7: Note [Stability of rewriting] +ref compiler/GHC/Tc/TyCl.hs:1316:6: Note [Unification variables need fresh Names] +ref compiler/GHC/Tc/Types/Constraint.hs:206:38: Note [NonCanonical Semantics] +ref compiler/GHC/Types/Demand.hs:301:25: Note [Preserving Boxity of results is rarely a win] +ref compiler/GHC/Unit/Module/Deps.hs:83:13: Note [Structure of dep_boot_mods] ref compiler/GHC/Utils/Monad.hs:410:34: Note [multiShotIO] ref compiler/Language/Haskell/Syntax/Binds.hs:200:31: Note [fun_id in Match] -ref configure.ac:210:10: Note [Linking ghc-bin against threaded stage0 RTS] +ref configure.ac:203: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:145:30: Note [Linking ghc-bin against threaded stage0 RTS] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ===================================== testsuite/tests/simplCore/should_compile/T22375.hs ===================================== @@ -1,12 +1,19 @@ module T22375 where -data X = A | B | C | D | E +data X + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 76, types: 41, coercions: 0, joins: 0/0} + = {terms: 96, types: 41, coercions: 0, joins: 0/0} -- RHS size: {terms: 14, types: 9, coercions: 0, joins: 0/0} T22375.$fEqX_$c== :: X -> X -> Bool @@ -50,22 +50,27 @@ T22375.$fEqX [InlPrag=CONLIKE] :: Eq X T22375.$fEqX = GHC.Classes.C:Eq @X T22375.$fEqX_$c== T22375.$fEqX_$c/= --- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0} +-- RHS size: {terms: 44, types: 3, coercions: 0, joins: 0/0} T22375.$wf [InlPrag=[2]] :: X -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375.$wf = \ (x :: X) (ww :: GHC.Prim.Int#) -> case x of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 5, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.hs ===================================== @@ -6,13 +6,20 @@ import Data.Kind type X :: Type -> Type data family X a -data instance X () = A | B | C | D | E +data instance X () + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X () -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 86, types: 65, coercions: 15, joins: 0/0} + = {terms: 116, types: 75, coercions: 25, joins: 0/0} -- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} T22375DataFamily.$WA [InlPrag=INLINE[final] CONLIKE] :: X () @@ -58,6 +58,61 @@ T22375DataFamily.$WE `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) :: T22375DataFamily.R:XUnit ~R# X ()) +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WF [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WF + = T22375DataFamily.F + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WG [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WG + = T22375DataFamily.G + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WH [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WH + = T22375DataFamily.H + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WI [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WI + = T22375DataFamily.I + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WJ [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WJ + = T22375DataFamily.J + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + -- RHS size: {terms: 14, types: 11, coercions: 2, joins: 0/0} T22375DataFamily.$fEqX_$c== :: X () -> X () -> Bool [GblId, @@ -133,7 +188,7 @@ T22375DataFamily.$fEqX = GHC.Classes.C:Eq @(X ()) T22375DataFamily.$fEqX_$c== T22375DataFamily.$fEqX_$c/= --- RHS size: {terms: 24, types: 4, coercions: 1, joins: 0/0} +-- RHS size: {terms: 44, types: 4, coercions: 1, joins: 0/0} T22375DataFamily.$wf [InlPrag=[2]] :: X () -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], @@ -141,18 +196,23 @@ T22375DataFamily.$wf [InlPrag=[2]] Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375DataFamily.$wf = \ (x :: X ()) (ww :: GHC.Prim.Int#) -> case x `cast` (T22375DataFamily.D:R:XUnit0[0] :: X () ~R# T22375DataFamily.R:XUnit) of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 6, coercions: 0, joins: 0/0} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55a98cd35ef68753866d9832e62775ccc9e1c441...1728dbb40eb68e71a4fb26e08136d164fdaa1ea1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55a98cd35ef68753866d9832e62775ccc9e1c441...1728dbb40eb68e71a4fb26e08136d164fdaa1ea1 You're receiving 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 Nov 19 23:32:56 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 19 Nov 2023 18:32:56 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Adjust thresholds Message-ID: <655a9b2894c63_14c49b4443d9e42264f0@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: ddd17134 by Simon Peyton Jones at 2023-11-19T23:32:16+00:00 Adjust thresholds - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -660,10 +660,10 @@ exprDigest env e = go env e [] -- attract that ScrutOf discount! We want liftM2 to be inlined -- in its use in the liftA2 method of instance Applicative (ST s) -- - -- Actually in specrtal/puzzle I found that we got a big (40%!) + -- Actually in spectral/puzzle I found that we got a big (40%!) -- benefit from let newDest = ... in case (notSeen newDest) of ... -- We want to inline notSeen. The argument has structure (its RHS) - -- and in fat if we inline notSeen, newDest turns into a thunk + -- and in fact if we inline notSeen, newDest turns into a thunk -- (SPJ GHC log 13 Nov). | Just rhs <- expandUnfolding_maybe unfolding ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -206,7 +206,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- inline into Csg.calc (The unfolding for sqr never makes it -- into the interface file.) - , unfoldingUseThreshold = 80 + , unfoldingUseThreshold = 70 -- Adjusted 90 -> 80 when adding discounts for free variables which -- generally make things more likely to inline. Reducing the threshold -- eliminates some undesirable compile-time regressions (e.g. T10412a) @@ -214,7 +214,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- Previously: adjusted upwards in #18282, when I reduced -- the result discount for constructors. - , unfoldingFunAppDiscount = 60 + , unfoldingFunAppDiscount = 30 -- Be fairly keen to inline a function if that means -- we'll be able to pick the right method from a dictionary @@ -882,12 +882,11 @@ conSize :: DataCon -> Int -> ExprTree conSize dc n_val_args | isUnboxedTupleDataCon dc = etZero -- See Note [Unboxed tuple size and result discount] + | n_val_args == 0 -- Like variables + = etZero | otherwise -- See Note [Constructor size and result discount] - = ExprTree { et_size = size, et_wc_tot = size + = ExprTree { et_size = 10, et_wc_tot = 10 , et_cases = emptyBag, et_ret = 10 } - where - size | n_val_args == 0 = 0 -- Like variables - | otherwise = 10 primOpSize :: PrimOp -> Int -> Size primOpSize op n_val_args View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ddd17134826249bbe87c370dbcabb12fc7a6c5d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ddd17134826249bbe87c370dbcabb12fc7a6c5d9 You're receiving 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 Nov 20 10:02:40 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 20 Nov 2023 05:02:40 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T6070 Message-ID: <655b2ec022e61_14c49b529065d0256544@gitlab.mail> Sebastian Graf pushed new branch wip/T6070 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T6070 You're receiving 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 Nov 20 12:12:12 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 07:12:12 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: AArch64: Remove unused instructions Message-ID: <655b4d1cd7976_14c49b5594fca026658@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 8bde6c36 by Alan Zimmerman at 2023-11-19T14:29:48+00:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - e866b16b by Sebastian Graf at 2023-11-20T07:11:42-05:00 Add regression test for #6070 Fixes #6070. - - - - - 19 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Test20297.stdout - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Orphans.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs - utils/haddock Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -434,7 +434,7 @@ getMovWideImm n w -- | Arithmetic(immediate) -- Allows for 12bit immediates which can be shifted by 0 or 12 bits. --- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- Used with ADD, ADDS, SUB, SUBS, CMP -- See Note [Aarch64 immediates] getArithImm :: Integer -> Width -> Maybe Operand getArithImm n w @@ -459,7 +459,7 @@ getArithImm n w -- | Logical (immediate) -- Allows encoding of some repeated bitpatterns --- Used with AND, ANDS, EOR, ORR, TST +-- Used with AND, EOR, ORR -- and their aliases which includes at least MOV (bitmask immediate) -- See Note [Aarch64 immediates] getBitmaskImm :: Integer -> Width -> Maybe Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -79,7 +79,6 @@ regUsageOfInstr platform instr = case instr of -- 1. Arithmetic Instructions ------------------------------------------------ ADD dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - CMN l r -> usage (regOp l ++ regOp r, []) CMP l r -> usage (regOp l ++ regOp r, []) MSUB dst src1 src2 src3 -> usage (regOp src1 ++ regOp src2 ++ regOp src3, regOp dst) MUL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -102,9 +101,6 @@ regUsageOfInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ASR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BIC dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - BICS dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - EON dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) EOR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSL dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -113,8 +109,6 @@ regUsageOfInstr platform instr = case instr of MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) - TST src1 src2 -> usage (regOp src1 ++ regOp src2, []) -- 4. Branch Instructions ---------------------------------------------------- J t -> usage (regTarget t, []) B t -> usage (regTarget t, []) @@ -131,12 +125,8 @@ regUsageOfInstr platform instr = case instr of STLR _ src dst -> usage (regOp src ++ regOp dst, []) LDR _ dst src -> usage (regOp src, regOp dst) LDAR _ dst src -> usage (regOp src, regOp dst) - -- TODO is this right? see STR, which I'm only partial about being right? - STP _ src1 src2 dst -> usage (regOp src1 ++ regOp src2 ++ regOp dst, []) - LDP _ dst1 dst2 src -> usage (regOp src, regOp dst1 ++ regOp dst2) -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> usage ([], []) DMBISH -> usage ([], []) -- 9. Floating Point Instructions -------------------------------------------- @@ -219,7 +209,6 @@ patchRegsOfInstr instr env = case instr of DELTA{} -> instr -- 1. Arithmetic Instructions ---------------------------------------------- ADD o1 o2 o3 -> ADD (patchOp o1) (patchOp o2) (patchOp o3) - CMN o1 o2 -> CMN (patchOp o1) (patchOp o2) CMP o1 o2 -> CMP (patchOp o1) (patchOp o2) MSUB o1 o2 o3 o4 -> MSUB (patchOp o1) (patchOp o2) (patchOp o3) (patchOp o4) MUL o1 o2 o3 -> MUL (patchOp o1) (patchOp o2) (patchOp o3) @@ -242,11 +231,7 @@ patchRegsOfInstr instr env = case instr of -- 3. Logical and Move Instructions ---------------------------------------- AND o1 o2 o3 -> AND (patchOp o1) (patchOp o2) (patchOp o3) - ANDS o1 o2 o3 -> ANDS (patchOp o1) (patchOp o2) (patchOp o3) ASR o1 o2 o3 -> ASR (patchOp o1) (patchOp o2) (patchOp o3) - BIC o1 o2 o3 -> BIC (patchOp o1) (patchOp o2) (patchOp o3) - BICS o1 o2 o3 -> BICS (patchOp o1) (patchOp o2) (patchOp o3) - EON o1 o2 o3 -> EON (patchOp o1) (patchOp o2) (patchOp o3) EOR o1 o2 o3 -> EOR (patchOp o1) (patchOp o2) (patchOp o3) LSL o1 o2 o3 -> LSL (patchOp o1) (patchOp o2) (patchOp o3) LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) @@ -255,8 +240,6 @@ patchRegsOfInstr instr env = case instr of MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) - ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) - TST o1 o2 -> TST (patchOp o1) (patchOp o2) -- 4. Branch Instructions -------------------------------------------------- J t -> J (patchTarget t) @@ -274,11 +257,8 @@ patchRegsOfInstr instr env = case instr of STLR f o1 o2 -> STLR f (patchOp o1) (patchOp o2) LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2) LDAR f o1 o2 -> LDAR f (patchOp o1) (patchOp o2) - STP f o1 o2 o3 -> STP f (patchOp o1) (patchOp o2) (patchOp o3) - LDP f o1 o2 o3 -> LDP f (patchOp o1) (patchOp o2) (patchOp o3) -- 8. Synchronization Instructions ----------------------------------------- - DMBSY -> DMBSY DMBISH -> DMBISH -- 9. Floating Point Instructions ------------------------------------------ @@ -560,7 +540,6 @@ data Instr -- | ADDS Operand Operand Operand -- rd = rn + rm -- | ADR ... -- | ADRP ... - | CMN Operand Operand -- rd + op2 | CMP Operand Operand -- rd - op2 -- | MADD ... -- | MNEG ... @@ -601,11 +580,7 @@ data Instr -- 3. Logical and Move Instructions ---------------------------------------- | AND Operand Operand Operand -- rd = rn & op2 - | ANDS Operand Operand Operand -- rd = rn & op2 | ASR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | BIC Operand Operand Operand -- rd = rn & ~op2 - | BICS Operand Operand Operand -- rd = rn & ~op2 - | EON Operand Operand Operand -- rd = rn ⊕ ~op2 | EOR Operand Operand Operand -- rd = rn ⊕ op2 | LSL Operand Operand Operand -- rd = rn ≪ rm or rd = rn ≪ #i, i is 6 bits | LSR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits @@ -614,18 +589,13 @@ data Instr -- | MOVN Operand Operand | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn - | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 - | ROR Operand Operand Operand -- rd = rn ≫ rm or rd = rn ≫ #i, i is 6 bits - | TST Operand Operand -- rn & op2 -- Load and stores. -- TODO STR/LDR might want to change to STP/LDP with XZR for the second register. | STR Format Operand Operand -- str Xn, address-mode // Xn -> *addr | STLR Format Operand Operand -- stlr Xn, address-mode // Xn -> *addr | LDR Format Operand Operand -- ldr Xn, address-mode // Xn <- *addr | LDAR Format Operand Operand -- ldar Xn, address-mode // Xn <- *addr - | STP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn -> *addr, Xm -> *(addr + 8) - | LDP Format Operand Operand Operand -- stp Xn, Xm, address-mode // Xn <- *addr, Xm <- *(addr + 8) -- Conditional instructions | CSET Operand Cond -- if(cond) op <- 1 else op <- 0 @@ -639,7 +609,6 @@ data Instr | BCOND Cond Target -- branch with condition. b. -- 8. Synchronization Instructions ----------------------------------------- - | DMBSY | DMBISH -- 9. Floating Point Instructions -- Float ConVerT @@ -675,7 +644,6 @@ instrCon i = PUSH_STACK_FRAME{} -> "PUSH_STACK_FRAME" POP_STACK_FRAME{} -> "POP_STACK_FRAME" ADD{} -> "ADD" - CMN{} -> "CMN" CMP{} -> "CMP" MSUB{} -> "MSUB" MUL{} -> "MUL" @@ -690,11 +658,7 @@ instrCon i = SBFX{} -> "SBFX" UBFX{} -> "UBFX" AND{} -> "AND" - ANDS{} -> "ANDS" ASR{} -> "ASR" - BIC{} -> "BIC" - BICS{} -> "BICS" - EON{} -> "EON" EOR{} -> "EOR" LSL{} -> "LSL" LSR{} -> "LSR" @@ -702,16 +666,11 @@ instrCon i = MOVK{} -> "MOVK" MOVZ{} -> "MOVZ" MVN{} -> "MVN" - ORN{} -> "ORN" ORR{} -> "ORR" - ROR{} -> "ROR" - TST{} -> "TST" STR{} -> "STR" STLR{} -> "STLR" LDR{} -> "LDR" LDAR{} -> "LDAR" - STP{} -> "STP" - LDP{} -> "LDP" CSET{} -> "CSET" CBZ{} -> "CBZ" CBNZ{} -> "CBNZ" @@ -719,7 +678,6 @@ instrCon i = B{} -> "B" BL{} -> "BL" BCOND{} -> "BCOND" - DMBSY{} -> "DMBSY" DMBISH{} -> "DMBISH" FCVT{} -> "FCVT" SCVTF{} -> "SCVTF" ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -370,7 +370,6 @@ pprInstr platform instr = case instr of ADD o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 | otherwise -> op3 (text "\tadd") o1 o2 o3 - CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 | otherwise -> op2 (text "\tcmp") o1 o2 @@ -405,11 +404,7 @@ pprInstr platform instr = case instr of -- 3. Logical and Move Instructions ------------------------------------------ AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 - ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 - BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 - BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 - EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 @@ -419,10 +414,7 @@ pprInstr platform instr = case instr of MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 - ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 - ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 - TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -526,12 +518,9 @@ pprInstr platform instr = case instr of LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 LDAR _f o1 o2 -> op2 (text "\tldar") o1 o2 - STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 - LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 - -- 8. Synchronization Instructions ------------------------------------------- - DMBSY -> line $ text "\tdmb sy" DMBISH -> line $ text "\tdmb ish" + -- 9. Floating Point Instructions -------------------------------------------- FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan s) = parens $ text "EpaSpan" <+> srcSpan s epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Hs/ImpExp.hs ===================================== @@ -42,6 +42,7 @@ import GHC.Unit.Module.Warnings import Data.Data import Data.Maybe +import qualified Data.Semigroup as Semigroup {- @@ -119,6 +120,13 @@ data EpAnnImportDecl = EpAnnImportDecl , importDeclAnnAs :: Maybe EpaLocation } deriving (Data) +instance Semigroup EpAnnImportDecl where + EpAnnImportDecl a1 b1 c1 d1 e1 f1 <> EpAnnImportDecl a2 b2 c2 d2 e2 f2 + = EpAnnImportDecl (a1 Semigroup.<> a2) (b1 Semigroup.<> b2) (c1 Semigroup.<> c2) + (d1 Semigroup.<> d2) (e1 Semigroup.<> e2) (f1 Semigroup.<> f2) +instance Monoid EpAnnImportDecl where + mempty = EpAnnImportDecl noSpanAnchor Nothing Nothing Nothing Nothing Nothing + -- --------------------------------------------------------------------- simpleImportDecl :: ModuleName -> ImportDecl GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -4308,7 +4308,7 @@ glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc glR :: HasLoc a => a -> Anchor -glR la = EpaSpan (realSrcSpan $ getHasLoc la) Strict.Nothing +glR la = EpaSpan (getHasLoc la) glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4318,7 +4318,7 @@ glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y anc :: RealSrcSpan -> Anchor -anc r = EpaSpan r Strict.Nothing +anc r = EpaSpan (RealSrcSpan r Strict.Nothing) glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l @@ -4442,7 +4442,7 @@ parseSignature :: P (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (NoAnn ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) -commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan (rs loc) Strict.Nothing) noAnn cs) loc +commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan loc) noAnn cs) loc -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -406,7 +406,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) +data EpaLocation = EpaSpan !SrcSpan | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq,Show) @@ -418,7 +418,7 @@ data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation getTokenSrcSpan :: TokenLocation -> SrcSpan getTokenSrcSpan NoTokenLoc = noSrcSpan getTokenSrcSpan (TokenLoc EpaDelta{}) = noSrcSpan -getTokenSrcSpan (TokenLoc (EpaSpan rspan mbufpos)) = RealSrcSpan rspan mbufpos +getTokenSrcSpan (TokenLoc (EpaSpan span)) = span instance Outputable a => Outputable (GenLocated TokenLocation a) where ppr (L _ x) = ppr x @@ -455,15 +455,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r _) = r -epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" +epaLocationRealSrcSpan (EpaSpan (RealSrcSpan r _)) = r +epaLocationRealSrcSpan _ = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan l +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = anc instance Outputable EpaLocation where - ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -527,18 +527,17 @@ data EpAnn ann type Anchor = EpaLocation -- Transitional anchor :: Anchor -> RealSrcSpan -anchor (EpaSpan r _) = r +anchor (EpaSpan (RealSrcSpan r _)) = r anchor _ = panic "anchor" spanAsAnchor :: SrcSpan -> Anchor -spanAsAnchor (RealSrcSpan r mb) = EpaSpan r mb -spanAsAnchor s = EpaSpan (realSrcSpan s) Strict.Nothing +spanAsAnchor ss = EpaSpan ss realSpanAsAnchor :: RealSrcSpan -> Anchor -realSpanAsAnchor r = EpaSpan r Strict.Nothing +realSpanAsAnchor s = EpaSpan (RealSrcSpan s Strict.Nothing) spanFromAnchor :: Anchor -> SrcSpan -spanFromAnchor (EpaSpan r mb) = RealSrcSpan r mb +spanFromAnchor (EpaSpan ss) = ss spanFromAnchor (EpaDelta _ _) = UnhelpfulSpan (UnhelpfulOther (fsLit "spanFromAnchor")) noSpanAnchor :: Anchor @@ -1062,8 +1061,8 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary l = mkRealSrcLoc (fsLit "realSrcSpan") (-1) (-1) srcSpan2e :: SrcSpan -> EpaLocation -srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb -srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing +srcSpan2e ss@(RealSrcSpan _ _) = EpaSpan ss +srcSpan2e span = EpaSpan (RealSrcSpan (realSrcSpan span) Strict.Nothing) la2e :: SrcSpanAnn' a -> EpaLocation la2e = srcSpan2e . locA @@ -1081,7 +1080,7 @@ reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e reAnnL anns cs (L l a) = L (SrcSpanAnn (EpAnn (spanAsAnchor l) anns cs) l) a getLocAnn :: Located a -> SrcSpanAnnA -getLocAnn (L l _) = SrcSpanAnn EpAnnNotUsed l +getLocAnn (L l _) = SrcSpanAnn noAnn l instance NoAnn (EpAnn a) where -- Short form for 'EpAnnNotUsed' @@ -1111,7 +1110,8 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s mb)):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan _):rest) = go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -1120,8 +1120,8 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest - go (AddEpAnn _ (EpaDelta _ _):rest) = go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s _)):rest) = s : go rest + go (AddEpAnn _ _:rest) = go rest realSpanFromAnns :: [AddEpAnn] -> Strict.Maybe RealSrcSpan realSpanFromAnns as = go Strict.Nothing as @@ -1130,7 +1130,7 @@ realSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineRealSrcSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan s _b):rest) = go (combine acc s) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan s _b)):rest) = go (combine acc s) rest go acc (AddEpAnn _ _ :rest) = go acc rest bufSpanFromAnns :: [AddEpAnn] -> Strict.Maybe BufSpan @@ -1140,28 +1140,27 @@ bufSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineBufSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan _ (Strict.Just mb)):rest) = go (combine acc mb) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan _ (Strict.Just mb))):rest) = go (combine acc mb) rest go acc (AddEpAnn _ _:rest) = go acc rest --- widenAnchor :: Anchor -> [AddEpAnn] -> Anchor --- widenAnchor (Anchor s op) as = Anchor (widenRealSpan s as) op widenAnchor :: Anchor -> [AddEpAnn] -> Anchor -widenAnchor (EpaSpan s mb) as - = EpaSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as)) --- widenAnchor (EpaSpan r mb) _ = EpaSpan r mb +widenAnchor (EpaSpan (RealSrcSpan s mb)) as + = EpaSpan (RealSrcSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as))) +widenAnchor (EpaSpan us) _ = EpaSpan us widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of Strict.Nothing -> a - Strict.Just r -> EpaSpan r Strict.Nothing + Strict.Just r -> EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorR :: Anchor -> RealSrcSpan -> Anchor -widenAnchorR (EpaSpan s _) r = EpaSpan (combineRealSrcSpans s r) Strict.Nothing -widenAnchorR (EpaDelta _ _) r = EpaSpan r Strict.Nothing +widenAnchorR (EpaSpan (RealSrcSpan s _)) r = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) Strict.Nothing) +widenAnchorR (EpaSpan _) r = EpaSpan (RealSrcSpan r Strict.Nothing) +widenAnchorR (EpaDelta _ _) r = EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorS :: Anchor -> SrcSpan -> Anchor -widenAnchorS (EpaSpan s mbe) (RealSrcSpan r mbr) - = EpaSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr) -widenAnchorS (EpaSpan us mb) _ = EpaSpan us mb -widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan r mb +widenAnchorS (EpaSpan (RealSrcSpan s mbe)) (RealSrcSpan r mbr) + = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr)) +widenAnchorS (EpaSpan us) _ = EpaSpan us +widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan (RealSrcSpan r mb) widenAnchorS anc _ = anc widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an @@ -1251,7 +1250,7 @@ placeholderRealSpan :: RealSrcSpan placeholderRealSpan = realSrcLocSpan (mkRealSrcLoc (mkFastString "placeholder") (-1) (-1)) comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO -comment loc cs = EpAnn (EpaSpan loc Strict.Nothing) NoEpAnns cs +comment loc cs = EpAnn (EpaSpan (RealSrcSpan loc Strict.Nothing)) NoEpAnns cs -- --------------------------------------------------------------------- -- Utilities for managing comments in an `EpAnn a` structure. @@ -1393,10 +1392,10 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- annotations must follow it. So we combine them which yields the -- largest span -instance Semigroup Anchor where - EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) - EpaSpan s1 m1 <> _ = EpaSpan s1 m1 - _ <> EpaSpan s2 m2 = EpaSpan s2 m2 +instance Semigroup EpaLocation where + EpaSpan s1 <> EpaSpan s2 = EpaSpan (combineSrcSpans s1 s2) + EpaSpan s1 <> _ = EpaSpan s1 + _ <> EpaSpan s2 = EpaSpan s2 EpaDelta dp1 cs1 <> EpaDelta _dp2 cs2 = EpaDelta dp1 (cs1<>cs2) instance Semigroup EpAnnComments where ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3780,7 +3780,8 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan (RealSrcSpan lo Strict.Nothing)), + AddEpAnn AnnCloseP (EpaSpan (RealSrcSpan lc Strict.Nothing))) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -472,29 +472,30 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 - | valid_anchor (anchor a) +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs _))) (EpAnn a (AnnList anc o c r t) cs) cs2 + | valid_anchor a = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs mb)) EpAnnNotUsed cs - = EpAnn (EpaSpan rs mb) - (AnnList (Just $ EpaSpan rs mb) Nothing Nothing [an] []) cs +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs mb))) EpAnnNotUsed cs + = EpAnn (EpaSpan (RealSrcSpan rs mb)) + (AnnList (Just $ EpaSpan (RealSrcSpan rs mb)) Nothing Nothing [an] []) cs add_where (AddEpAnn _ _) _ _ = panic "add_where" -- EpaDelta should only be used for transformations -valid_anchor :: RealSrcSpan -> Bool -valid_anchor r = srcSpanStartLine r >= 0 +valid_anchor :: Anchor -> Bool +valid_anchor (EpaSpan (RealSrcSpan r _)) = srcSpanStartLine r >= 0 +valid_anchor _ = False -- If the decl list for where binds is empty, the anchor ends up -- invalid. In this case, use the parent one patch_anchor :: RealSrcSpan -> Anchor -> Anchor -patch_anchor r (EpaDelta _ _) = EpaSpan r Strict.Nothing -patch_anchor r1 (EpaSpan r0 mb) = EpaSpan r mb +patch_anchor r (EpaDelta _ _) = EpaSpan (RealSrcSpan r Strict.Nothing) +patch_anchor r1 (EpaSpan (RealSrcSpan r0 mb)) = EpaSpan (RealSrcSpan r mb) where r = if srcSpanStartLine r0 < 0 then r1 else r0 --- patch_anchor _ (EpaSpan ss mb) = EpaSpan ss mb +patch_anchor _ (EpaSpan ss) = EpaSpan ss fixValbindsAnn :: EpAnn AnnList -> EpAnn AnnList fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed @@ -504,9 +505,9 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor -stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan r rb)) _), _)) - = Just $ widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) -stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan l mb +stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan (RealSrcSpan r rb))) _), _)) + = Just $ widenAnchorS (EpaSpan (RealSrcSpan l mb)) (RealSrcSpan r rb) +stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan (RealSrcSpan l mb) stmtsAnchor _ = Nothing stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan @@ -994,7 +995,7 @@ checkTyVars pp_what equals_or_where tc tparms for_widening _ = AddEpAnn AnnAnyclass (EpaDelta (SameLine 0) []) for_widening_ann :: HsBndrVis GhcPs -> EpAnn [AddEpAnn] - for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan r _mb)) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments + for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan (RealSrcSpan r _mb))) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments for_widening_ann _ = EpAnnNotUsed @@ -1111,14 +1112,14 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c []) cs) + an = EpAnn (EpaSpan (RealSrcSpan lr Strict.Nothing)) (NameAnn NameParens o (srcSpan2e l) c []) cs in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) - in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) + lr = RealSrcSpan (combineRealSrcSpans (anchor ap) (anchor as)) Strict.Nothing + an = EpAnn (EpaSpan lr) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs) + in SrcSpanAnn an lr -- | Yield a parse error if we have a function applied directly to a do block -- etc. and BlockArguments is not enabled. @@ -3210,14 +3211,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan (RealSrcSpan r mb)) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) +token_location_widenR (TokenLoc (EpaSpan s1)) s2 = + (TokenLoc (EpaSpan (combineSrcSpans s1 s2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -99,10 +99,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.hs:7:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.hs:7:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.hs:7:3-7 }))] @@ -390,10 +390,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.ppr.hs:5:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.ppr.hs:5:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.ppr.hs:5:3-7 }))] ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -422,7 +422,7 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do debugM $ "enterAnn:starting:(p,pe,anchor',a) =" ++ show (p, pe0, showAst anchor', astId a) prevAnchor <- getAnchorU let curAnchor = case anchor' of - EpaSpan r _ -> r + EpaSpan (RealSrcSpan r _) -> r _ -> prevAnchor debugM $ "enterAnn:(curAnchor):=" ++ show (rs2range curAnchor) case canUpdateAnchor of @@ -495,10 +495,11 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do Just (EpaDelta dp _) -> dp -- Replace original with desired one. Allows all -- list entry values to be DP (1,0) - Just (EpaSpan r _) -> dp + Just (EpaSpan (RealSrcSpan r _)) -> dp where dp = adjustDeltaForOffset off (ss2delta priorEndAfterComments r) + Just (EpaSpan (UnhelpfulSpan r)) -> panic $ "enterAnn: UnhelpfulSpan:" ++ show r -- --------------------------------------------- -- Preparation complete, perform the action when (priorEndAfterComments < spanStart) (do @@ -543,9 +544,10 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do case anchor' of EpaDelta _ _ -> return () - EpaSpan rss _ -> do + EpaSpan (RealSrcSpan rss _) -> do setAcceptSpan False setPriorEndD (snd $ rs2range rss) + EpaSpan _ -> return () -- Outside the anchor, mark any trailing postCs <- cua canUpdateAnchor takeAppliedCommentsPop @@ -723,7 +725,8 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (RealSrcSpan r _)) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (UnhelpfulSpan _)) s = printStringAtAAC capture (EpaDelta (SameLine 0) []) s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ printOneComment $ concatMap tokComment cs pe1 <- getPriorEndD @@ -798,10 +801,10 @@ markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do markLToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) => Located (HsToken tok) -> EP w m (Located (HsToken tok)) markLToken (L (RealSrcSpan aa mb) t) = do - epaLoc'<- printStringAtAA (EpaSpan aa mb) (symbolVal (Proxy @tok)) + epaLoc'<- printStringAtAA (EpaSpan (RealSrcSpan aa mb)) (symbolVal (Proxy @tok)) case epaLoc' of - EpaSpan aa' mb' -> return (L (RealSrcSpan aa' mb') t) - _ -> return (L (RealSrcSpan aa mb ) t) + EpaSpan (RealSrcSpan aa' mb') -> return (L (RealSrcSpan aa' mb') t) + _ -> return (L (RealSrcSpan aa mb ) t) markLToken (L lt t) = return (L lt t) markToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) @@ -1403,12 +1406,13 @@ printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c dp <-case loc of EpaDelta dp _ -> return dp - EpaSpan r _ -> do + EpaSpan (RealSrcSpan r _) -> do pe <- getPriorEndD debugM $ "printOneComment:pe=" ++ showGhc pe let dp = ss2delta pe r debugM $ "printOneComment:(dp,pe,loc)=" ++ showGhc (dp,pe,loc) adjustDeltaForOffsetM dp + EpaSpan (UnhelpfulSpan _) -> return (SameLine 0) mep <- getExtraDP dp' <- case mep of Just (EpaDelta edp _) -> do @@ -1429,12 +1433,13 @@ updateAndApplyComment (Comment str anc pp mo) dp = do (r,c) = ss2posEnd pp dp'' = case anc of EpaDelta dp1 _ -> dp1 - EpaSpan la _ -> + EpaSpan (RealSrcSpan la _) -> if r == 0 then (ss2delta (r,c+0) la) else (ss2delta (r,c) la) + EpaSpan (UnhelpfulSpan _) -> SameLine 0 dp' = case anc of - EpaSpan r1 _ -> + EpaSpan (RealSrcSpan r1 _) -> if pp == r1 then dp else dp'' @@ -1459,7 +1464,7 @@ commentAllocationBefore ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2pos r) <= (ss2pos ss) + EpaSpan (RealSrcSpan r _) -> (ss2pos r) <= (ss2pos ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -1475,7 +1480,7 @@ commentAllocationIn ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2posEnd r) <= (ss2posEnd ss) + EpaSpan (RealSrcSpan r _) -> (ss2posEnd r) <= (ss2posEnd ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -4376,7 +4381,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ _ -> return anc + EpaSpan _ -> return anc EpaDelta dp [] -> return $ EpaDelta dp [] EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Orphans.hs ===================================== @@ -5,65 +5,61 @@ module Orphans where import GHC hiding (EpaComment) --- --------------------------------------------------------------------- --- Orphan NoAnn instances. See https://gitlab.haskell.org/ghc/ghc/-/issues/20372 +-- -- --------------------------------------------------------------------- instance NoAnn [a] where noAnn = [] -instance NoAnn AnnPragma where - noAnn = AnnPragma noAnn noAnn noAnn - -instance NoAnn EpAnnImportDecl where - noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing +instance (NoAnn a, NoAnn b) => NoAnn (a, b) where + noAnn = (noAnn, noAnn) -instance NoAnn AnnParen where - noAnn = AnnParen AnnParens noAnn noAnn +instance NoAnn EpaLocation where + noAnn = EpaDelta (SameLine 0) [] -instance NoAnn HsRuleAnn where - noAnn = HsRuleAnn Nothing Nothing noAnn +instance NoAnn EpAnnSumPat where + noAnn = EpAnnSumPat [] [] [] -instance NoAnn AnnSig where - noAnn = AnnSig noAnn noAnn +instance NoAnn AnnPragma where + noAnn = AnnPragma noAnn noAnn [] -instance NoAnn GrhsAnn where - noAnn = GrhsAnn Nothing noAnn +instance NoAnn AddEpAnn where + noAnn = AddEpAnn noAnn noAnn -instance NoAnn EpAnnUnboundVar where - noAnn = EpAnnUnboundVar noAnn noAnn +instance NoAnn AnnKeywordId where + noAnn = Annlarrowtail {- gotta pick one -} -instance (NoAnn a, NoAnn b) => NoAnn (a, b) where - noAnn = (noAnn, noAnn) +instance NoAnn AnnParen where + noAnn = AnnParen AnnParens noAnn noAnn -instance NoAnn AnnExplicitSum where - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn +instance NoAnn AnnsIf where + noAnn = AnnsIf noAnn noAnn noAnn Nothing Nothing instance NoAnn EpAnnHsCase where noAnn = EpAnnHsCase noAnn noAnn noAnn -instance NoAnn AnnsIf where - noAnn = AnnsIf noAnn noAnn noAnn noAnn noAnn - -instance NoAnn (Maybe a) where - noAnn = Nothing +instance NoAnn AnnFieldLabel where + noAnn = AnnFieldLabel Nothing instance NoAnn AnnProjection where noAnn = AnnProjection noAnn noAnn -instance NoAnn AnnFieldLabel where - noAnn = AnnFieldLabel Nothing +instance NoAnn AnnExplicitSum where + noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn -instance NoAnn EpaLocation where - noAnn = EpaDelta (SameLine 0) [] +instance NoAnn EpAnnUnboundVar where + noAnn = EpAnnUnboundVar noAnn noAnn -instance NoAnn AddEpAnn where - noAnn = AddEpAnn noAnn noAnn +instance NoAnn GrhsAnn where + noAnn = GrhsAnn Nothing noAnn -instance NoAnn AnnKeywordId where - noAnn = Annlarrowtail {- gotta pick one -} +instance NoAnn HsRuleAnn where + noAnn = HsRuleAnn Nothing Nothing noAnn -instance NoAnn EpAnnSumPat where - noAnn = EpAnnSumPat noAnn noAnn noAnn +instance NoAnn AnnSig where + noAnn = AnnSig noAnn noAnn + +instance NoAnn EpAnnImportDecl where + noAnn = EpAnnImportDecl noAnn Nothing Nothing Nothing Nothing Nothing instance NoAnn AnnsModule where - noAnn = AnnsModule [] mempty Nothing + noAnn = AnnsModule [] [] Nothing ===================================== utils/check-exact/Parsers.hs ===================================== @@ -284,7 +284,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance cs = cs' where cs' = case GHC.hsmodLayout $ GHC.hsmodExt p of - GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan ss _)) _) -> + GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan (GHC.RealSrcSpan ss _))) _) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -222,8 +222,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) - EpaDelta _ _ -> AddEpAnn kw dca + EpaSpan (RealSrcSpan r _) -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + _ -> AddEpAnn kw dca -- --------------------------------- @@ -232,7 +232,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let anc0 = case dca of - EpaSpan r _ -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (RealSrcSpan r _) -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (UnhelpfulSpan _) -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc0 noAnn emptyComments) ll) b) (L (SrcSpanAnn (EpAnn anc0 a c) ll) b) @@ -240,7 +241,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H anc' = case anc0 of EpaDelta _ _ -> anc0 _ -> case dca of - EpaSpan _ _ -> EpaDelta (SameLine 1) [] + EpaSpan _ -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc' a c) ll) b) @@ -268,7 +269,11 @@ setEntryDP (L (SrcSpanAnn EpAnnNotUsed l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) noAnn emptyComments) l) a -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _ _) an (EpaComments [])) l) a) dp +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (UnhelpfulSpan _)) an cs) l) a) dp + = L (SrcSpanAnn + (EpAnn (EpaDelta dp []) an cs) + l) a +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _) an (EpaComments [])) l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) an (EpaComments [])) l) a @@ -299,8 +304,8 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaDelta d csd) an cs) l) a) dp in (dp0, c':t, EpaCommentsBalanced [] ts) go (L (EpaDelta _ c0) c) = (d, L (EpaDelta dp c0) c) - go (L (EpaSpan _ _) c) = (d, L (EpaDelta dp []) c) -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp + go (L (EpaSpan _) c) = (d, L (EpaDelta dp []) c) +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r _)) an cs) l) a) dp = case sortEpaComments (priorComments cs) of [] -> L (SrcSpanAnn @@ -315,8 +320,9 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp csd = L (EpaDelta dp []) c:cs' lc = last $ (L ca c:cs') delta = case getLoc lc of - EpaSpan rr _ -> ss2delta (ss2pos rr) r - EpaDelta _dp _ -> DifferentLine 1 0 + EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r + EpaSpan _ -> (SameLine 0) + EpaDelta _ _ -> DifferentLine 1 0 -- cs'' = setPriorComments cs (L (EpaDelta dp []) c:cs') -- lc = head $ reverse $ (L ca c:cs') -- delta = case getLoc lc of @@ -340,17 +346,20 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r _) +addEpaLocationDelta _off _anc s@(EpaSpan (UnhelpfulSpan _)) = s +addEpaLocationDelta off anc (EpaSpan (RealSrcSpan r _)) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor _off (EpaSpan (UnhelpfulSpan _)) (L la a) = L la a +setEntryDPFromAnchor off (EpaSpan (RealSrcSpan anc _)) ll@(L la _) = setEntryDP ll dp' where dp' = case la of (SrcSpanAnn EpAnnNotUsed l) -> adjustDeltaForOffset off (ss2deltaEnd anc (realSrcSpan l)) - (SrcSpanAnn (EpAnn (EpaSpan r' _) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r' _)) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan _) _ _) _) -> adjustDeltaForOffset off (SameLine 0) (SrcSpanAnn (EpAnn (EpaDelta dp _) _ _) _) -> adjustDeltaForOffset off dp -- --------------------------------------------------------------------- @@ -381,7 +390,7 @@ transferEntryDP (L (SrcSpanAnn EpAnnNotUsed _l1) _) (L (SrcSpanAnn (EpAnn anc2 a where anc2' = case anc2 of EpaDelta _ _ -> anc2 - EpaSpan _ _ -> EpaSpan (realSrcSpan l2) Strict.Nothing + EpaSpan _ -> EpaSpan (RealSrcSpan (realSrcSpan l2) Strict.Nothing) -- |If a and b are the same type return first arg, else return second @@ -447,7 +456,7 @@ balanceCommentsFB (L lf (FunBind x n (MG o (L lm matches)))) second = do -- + move the trailing ones to the last match. let (before,middle,after) = case s_entry lf of - EpaSpan ss _ -> + EpaSpan (RealSrcSpan ss _) -> let split = splitCommentsEnd ss (s_comments lf) split2 = splitCommentsStart ss (EpaComments (sortEpaComments $ priorComments split)) @@ -630,7 +639,7 @@ priorCommentsDeltas r cs = go r (reverse $ sortEpaComments cs) splitCommentsEnd :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsEnd p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -638,7 +647,7 @@ splitCommentsEnd p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -649,7 +658,7 @@ splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' splitCommentsStart :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsStart p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -657,7 +666,7 @@ splitCommentsStart p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsStart p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -933,7 +942,8 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (RealSrcSpan r _)) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (UnhelpfulSpan _)) -> LayoutStartCol 0 (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -123,7 +123,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) +undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan (RealSrcSpan sp Strict.Nothing)) where (l,c) = undelta (ss2pos anc) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -170,7 +170,7 @@ spanLength = (-) <$> srcSpanEndCol <*> srcSpanStartCol -- | Useful for debug dumps eloc2str :: EpaLocation -> String -eloc2str (EpaSpan r _) = "EpaSpan " ++ show (rs2range r) +eloc2str (EpaSpan r) = "EpaSpan " ++ show (ss2range r) eloc2str epaLoc = show epaLoc -- --------------------------------------------------------------------- @@ -186,7 +186,7 @@ isPointSrcSpan ss = spanLength ss == 0 -- `MovedAnchor` operation based on the original location, only if it -- does not already have one. commentOrigDelta :: LEpaComment -> LEpaComment -commentOrigDelta (L (EpaSpan la _) (GHC.EpaComment t pp)) +commentOrigDelta (L (EpaSpan (RealSrcSpan la _)) (GHC.EpaComment t pp)) = (L (EpaDelta dp []) (GHC.EpaComment t pp)) `debug` ("commentOrigDelta: (la, pp, r,c, dp)=" ++ showAst (la, pp, r,c, dp)) where @@ -331,8 +331,10 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss mb) - = Comment (keywordToString kw) (EpaSpan ss mb) ss (Just kw) +mkKWComment kw (EpaSpan (RealSrcSpan ss mb)) + = Comment (keywordToString kw) (EpaSpan (RealSrcSpan ss mb)) ss (Just kw) +mkKWComment kw (EpaSpan (UnhelpfulSpan _)) + = Comment (keywordToString kw) (EpaDelta (SameLine 0) []) placeholderRealSpan (Just kw) mkKWComment kw (EpaDelta dp cs) = Comment (keywordToString kw) (EpaDelta dp cs) placeholderRealSpan (Just kw) @@ -444,15 +446,18 @@ To be absolutely sure, we make the delta versions use -ve values. hackSrcSpanToAnchor :: SrcSpan -> Anchor hackSrcSpanToAnchor (UnhelpfulSpan s) = error $ "hackSrcSpanToAnchor : UnhelpfulSpan:" ++ show s -hackSrcSpanToAnchor (RealSrcSpan r Strict.Nothing) = EpaSpan r Strict.Nothing -hackSrcSpanToAnchor (RealSrcSpan r mb@(Strict.Just (BufSpan (BufPos s) (BufPos e)))) - = if s <= 0 && e <= 0 - then EpaDelta (deltaPos (-s) (-e)) [] - `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) - else EpaSpan r mb +hackSrcSpanToAnchor (RealSrcSpan r mb) + = case mb of + (Strict.Just (BufSpan (BufPos s) (BufPos e))) -> + if s <= 0 && e <= 0 + then EpaDelta (deltaPos (-s) (-e)) [] + `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) + -- else Anchor r UnchangedAnchor + else EpaSpan (RealSrcSpan r mb) + _ -> EpaSpan (RealSrcSpan r mb) hackAnchorToSrcSpan :: Anchor -> SrcSpan -hackAnchorToSrcSpan (EpaSpan r mb) = RealSrcSpan r mb +hackAnchorToSrcSpan (EpaSpan s) = s hackAnchorToSrcSpan _ = error $ "hackAnchorToSrcSpan" -- --------------------------------------------------------------------- ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a70ba4918b8a65abd18b16f414b6e2c3c4e38c46 +Subproject commit 96e713f7768926dab4aeec5175c1854057a833c9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64d8d36be9786186033e0e0ff94b9654f248b065...e866b16b101d1ff94127c72dff6cd4b93d81d216 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64d8d36be9786186033e0e0ff94b9654f248b065...e866b16b101d1ff94127c72dff6cd4b93d81d216 You're receiving 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 Nov 20 15:32:31 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 10:32:31 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Add regression test for #6070 Message-ID: <655b7c0f888c1_14c49b5a8e9d60291022@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 63211fe4 by Sebastian Graf at 2023-11-20T10:32:27-05:00 Add regression test for #6070 Fixes #6070. - - - - - 3 changed files: - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63211fe4e45ac5d648fd378cc632f9c489740160 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63211fe4e45ac5d648fd378cc632f9c489740160 You're receiving 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 Nov 20 18:02:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 13:02:49 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Add regression test for #6070 Message-ID: <655b9f48f0c89_14c49b5e1745a431679@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7b4d8ba6 by Sebastian Graf at 2023-11-20T13:02:44-05:00 Add regression test for #6070 Fixes #6070. - - - - - 3 changed files: - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b4d8ba6b2d05fe10fc29b13cd377f01f6985458 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b4d8ba6b2d05fe10fc29b13cd377f01f6985458 You're receiving 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 Nov 20 18:49:34 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Mon, 20 Nov 2023 13:49:34 -0500 Subject: [Git][ghc/ghc][wip/add-ddump-specialisations] Late plugins Message-ID: <655baa3e4da19_14c49b5f09c7e832956e@gitlab.mail> Finley McIlwaine pushed to branch wip/add-ddump-specialisations at Glasgow Haskell Compiler / GHC Commits: 4bec35fb by Finley McIlwaine at 2023-11-20T10:49:23-08:00 Late plugins - - - - - 3 changed files: - compiler/GHC/Core/LateCC.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Plugins.hs Changes: ===================================== compiler/GHC/Core/LateCC.hs ===================================== @@ -71,34 +71,32 @@ addLateCostCentresMG guts = do let env :: Env env = Env { thisModule = mg_module guts - , ccState = newCostCentreState , countEntries = gopt Opt_ProfCountEntries dflags , collectCCs = False -- See Note [Collecting late cost centres] } - let guts' = guts { mg_binds = fst (addLateCostCentres env (mg_binds guts)) + let guts' = guts { mg_binds = fstOf3 (addLateCostCentres env (mg_binds guts)) } return guts' -addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre) +addLateCostCentresPgm :: DynFlags -> Logger -> Module -> CoreProgram -> IO (CoreProgram, S.Set CostCentre, CostCentreState) addLateCostCentresPgm dflags logger mod binds = withTiming logger (text "LateCC"<+>brackets (ppr mod)) - (\(a,b) -> a `seqList` (b `seq` ())) $ do + (\(a,b,c) -> a `seqList` (b `seq` (c `seq` ()))) $ do let env = Env { thisModule = mod - , ccState = newCostCentreState , countEntries = gopt Opt_ProfCountEntries dflags , collectCCs = True -- See Note [Collecting late cost centres] } - (binds', ccs) = addLateCostCentres env binds + (binds', ccs, cc_state) = addLateCostCentres env binds when (dopt Opt_D_dump_late_cc dflags || dopt Opt_D_verbose_core2core dflags) $ putDumpFileMaybe logger Opt_D_dump_late_cc "LateCC" FormatCore (vcat (map ppr binds')) - return (binds', ccs) + return (binds', ccs, cc_state) -addLateCostCentres :: Env -> CoreProgram -> (CoreProgram,S.Set CostCentre) +addLateCostCentres :: Env -> CoreProgram -> (CoreProgram, S.Set CostCentre, CostCentreState) addLateCostCentres env binds = let (binds', state) = runState (mapM (doBind env) binds) initLateCCState - in (binds',lcs_ccs state) + in (binds', lcs_ccs state, lcs_state state) doBind :: Env -> CoreBind -> M CoreBind @@ -161,7 +159,6 @@ addCC !env cc = do data Env = Env { thisModule :: !Module , countEntries:: !Bool - , ccState :: !CostCentreState , collectCCs :: !Bool } ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -289,6 +289,7 @@ import GHC.Stg.InferTags.TagSig (seqTagSig) import GHC.StgToCmm.Utils (IPEStats) import GHC.Types.Unique.FM import GHC.Cmm.Config (CmmConfig) +import GHC.Types.CostCentre.State (newCostCentreState) {- ********************************************************************** @@ -1794,40 +1795,61 @@ hscGenHardCode :: HscEnv -> CgGuts -> ModLocation -> FilePath -> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], Maybe StgCgInfos, Maybe CmmCgInfos ) -- ^ @Just f@ <=> _stub.c is f hscGenHardCode hsc_env cgguts location output_filename = do - let CgGuts{ -- This is the last use of the ModGuts in a compilation. - -- From now on, we just use the bits we need. - cg_module = this_mod, + let CgGuts{ cg_module = this_mod, cg_binds = core_binds, - cg_ccs = local_ccs, - cg_tycons = tycons, - cg_foreign = foreign_stubs0, - cg_foreign_files = foreign_files, - cg_dep_pkgs = dependencies, - cg_hpc_info = hpc_info, - cg_spt_entries = spt_entries + cg_ccs = local_ccs } = cgguts dflags = hsc_dflags hsc_env logger = hsc_logger hsc_env - hooks = hsc_hooks hsc_env - tmpfs = hsc_tmpfs hsc_env - llvm_config = hsc_llvm_config hsc_env - profile = targetProfile dflags - data_tycons = filter isDataTyCon tycons - -- cg_tycons includes newtypes, for the benefit of External Core, - -- but we don't generate any code for newtypes + ------------------- -- Insert late cost centres if enabled. -- If `-fprof-late-inline` is enabled we can skip this, as it will have added -- a superset of cost centres we would add here already. - (late_cc_binds, late_local_ccs) <- + (late_cc_binds, late_local_ccs, cc_state) <- if gopt Opt_ProfLateCcs dflags && not (gopt Opt_ProfLateInlineCcs dflags) - then {-# SCC lateCC #-} do - (binds,late_ccs) <- addLateCostCentresPgm dflags logger this_mod core_binds - return ( binds, (S.toList late_ccs `mappend` local_ccs )) + then {-# SCC lateCC #-} do + (binds, late_ccs, cc_state) <- addLateCostCentresPgm dflags logger this_mod core_binds + return ( binds, (S.toList late_ccs `mappend` local_ccs ), cc_state) else - return (core_binds, local_ccs) + return (core_binds, local_ccs, newCostCentreState) + + ------------------- + -- Run late plugins + -- This is the last use of the ModGuts in a compilation. + -- From now on, we just use the bits we need. + ( CgGuts + { cg_tycons = tycons, + cg_foreign = foreign_stubs0, + cg_foreign_files = foreign_files, + cg_dep_pkgs = dependencies, + cg_hpc_info = hpc_info, + cg_spt_entries = spt_entries, + cg_binds = late_binds, + cg_ccs = late_local_ccs' + } + , _ + ) <- + {-# SCC "latePlugins" #-} + withPlugins (hsc_plugins hsc_env) + (($ hsc_env) . latePlugin) + ( cgguts + { cg_binds = late_cc_binds + , cg_ccs = late_local_ccs + } + , cc_state + ) + + let + hooks = hsc_hooks hsc_env + tmpfs = hsc_tmpfs hsc_env + llvm_config = hsc_llvm_config hsc_env + profile = targetProfile dflags + data_tycons = filter isDataTyCon tycons + -- cg_tycons includes newtypes, for the benefit of External Core, + -- but we don't generate any code for newtypes @@ -1840,7 +1862,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do (hsc_logger hsc_env) cp_cfg (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env)) - this_mod location late_cc_binds data_tycons + this_mod location late_binds data_tycons ----------------- Convert to STG ------------------ (stg_binds, denv, (caf_ccs, caf_cc_stacks), stg_cg_infos) @@ -1856,7 +1878,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do (myCoreToStg logger dflags (hsc_IC hsc_env) False this_mod location prepd_binds) let cost_centre_info = - (late_local_ccs ++ caf_ccs, caf_cc_stacks) + (late_local_ccs' ++ caf_ccs, caf_cc_stacks) platform = targetPlatform dflags prof_init | sccProfilingEnabled dflags = profilingInitCode platform this_mod cost_centre_info ===================================== compiler/GHC/Driver/Plugins.hs ===================================== @@ -89,8 +89,11 @@ import GHC.Core.Opt.Pipeline.Types ( CoreToDo ) import GHC.Hs import GHC.Types.Error (Messages) import GHC.Linker.Types +import GHC.Types.CostCentre.State +import GHC.Types.CostCentre import GHC.Types.Unique.DFM +import GHC.Unit.Module.ModGuts (CgGuts) import GHC.Utils.Fingerprint import GHC.Utils.Outputable import GHC.Utils.Panic @@ -157,6 +160,11 @@ data Plugin = Plugin { -- -- @since 8.10.1 + , latePlugin :: LatePlugin + -- ^ A plugin that runs after interface creation and after late cost centre + -- insertion. Useful for transformations that should not impact interfaces + -- or optimization at all. + , pluginRecompile :: [CommandLineOption] -> IO PluginRecompile -- ^ Specify how the plugin should affect recompilation. , parsedResultAction :: [CommandLineOption] -> ModSummary @@ -260,6 +268,7 @@ type CorePlugin = [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] type TcPlugin = [CommandLineOption] -> Maybe GHC.Tc.Types.TcPlugin type DefaultingPlugin = [CommandLineOption] -> Maybe GHC.Tc.Types.DefaultingPlugin type HoleFitPlugin = [CommandLineOption] -> Maybe HoleFitPluginR +type LatePlugin = HscEnv -> [CommandLineOption] -> (CgGuts, CostCentreState) -> IO (CgGuts, CostCentreState) purePlugin, impurePlugin, flagRecompile :: [CommandLineOption] -> IO PluginRecompile purePlugin _args = return NoForceRecompile @@ -280,6 +289,7 @@ defaultPlugin = Plugin { , defaultingPlugin = const Nothing , holeFitPlugin = const Nothing , driverPlugin = const return + , latePlugin = \_ -> const return , pluginRecompile = impurePlugin , renamedResultAction = \_ env grp -> return (env, grp) , parsedResultAction = \_ _ -> return View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bec35fb31bd4858a3a5fa3c0aff1a1bc59ef330 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bec35fb31bd4858a3a5fa3c0aff1a1bc59ef330 You're receiving 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 Nov 20 21:23:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 16:23:29 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Speed up stimes in instance Semigroup Endo Message-ID: <655bce516de16_14c49b62b8ca243438dc@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 407daed0 by David Feuer at 2023-11-20T16:23:08-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - 1f7256d7 by Andrew Lelechenko at 2023-11-20T16:23:08-05:00 base: reflect latest changes in the changelog - - - - - eb8bcaee by Alan Zimmerman at 2023-11-20T16:23:08-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - cee9bb14 by Sebastian Graf at 2023-11-20T16:23:09-05:00 Add regression test for #6070 Fixes #6070. - - - - - 20 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - libraries/base/changelog.md - libraries/base/src/Data/Semigroup/Internal.hs - libraries/base/tests/all.T - + libraries/base/tests/stimesEndo.hs - + libraries/base/tests/stimesEndo.stdout - testsuite/tests/printer/Test20297.stdout - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan s) = parens $ text "EpaSpan" <+> srcSpan s epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Hs/ImpExp.hs ===================================== @@ -42,6 +42,7 @@ import GHC.Unit.Module.Warnings import Data.Data import Data.Maybe +import qualified Data.Semigroup as Semigroup {- @@ -119,6 +120,13 @@ data EpAnnImportDecl = EpAnnImportDecl , importDeclAnnAs :: Maybe EpaLocation } deriving (Data) +instance Semigroup EpAnnImportDecl where + EpAnnImportDecl a1 b1 c1 d1 e1 f1 <> EpAnnImportDecl a2 b2 c2 d2 e2 f2 + = EpAnnImportDecl (a1 Semigroup.<> a2) (b1 Semigroup.<> b2) (c1 Semigroup.<> c2) + (d1 Semigroup.<> d2) (e1 Semigroup.<> e2) (f1 Semigroup.<> f2) +instance Monoid EpAnnImportDecl where + mempty = EpAnnImportDecl noSpanAnchor Nothing Nothing Nothing Nothing Nothing + -- --------------------------------------------------------------------- simpleImportDecl :: ModuleName -> ImportDecl GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -4308,7 +4308,7 @@ glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc glR :: HasLoc a => a -> Anchor -glR la = EpaSpan (realSrcSpan $ getHasLoc la) Strict.Nothing +glR la = EpaSpan (getHasLoc la) glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4318,7 +4318,7 @@ glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y anc :: RealSrcSpan -> Anchor -anc r = EpaSpan r Strict.Nothing +anc r = EpaSpan (RealSrcSpan r Strict.Nothing) glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l @@ -4442,7 +4442,7 @@ parseSignature :: P (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (NoAnn ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) -commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan (rs loc) Strict.Nothing) noAnn cs) loc +commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan loc) noAnn cs) loc -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -406,7 +406,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) +data EpaLocation = EpaSpan !SrcSpan | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq,Show) @@ -418,7 +418,7 @@ data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation getTokenSrcSpan :: TokenLocation -> SrcSpan getTokenSrcSpan NoTokenLoc = noSrcSpan getTokenSrcSpan (TokenLoc EpaDelta{}) = noSrcSpan -getTokenSrcSpan (TokenLoc (EpaSpan rspan mbufpos)) = RealSrcSpan rspan mbufpos +getTokenSrcSpan (TokenLoc (EpaSpan span)) = span instance Outputable a => Outputable (GenLocated TokenLocation a) where ppr (L _ x) = ppr x @@ -455,15 +455,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r _) = r -epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" +epaLocationRealSrcSpan (EpaSpan (RealSrcSpan r _)) = r +epaLocationRealSrcSpan _ = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan l +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = anc instance Outputable EpaLocation where - ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -527,18 +527,17 @@ data EpAnn ann type Anchor = EpaLocation -- Transitional anchor :: Anchor -> RealSrcSpan -anchor (EpaSpan r _) = r +anchor (EpaSpan (RealSrcSpan r _)) = r anchor _ = panic "anchor" spanAsAnchor :: SrcSpan -> Anchor -spanAsAnchor (RealSrcSpan r mb) = EpaSpan r mb -spanAsAnchor s = EpaSpan (realSrcSpan s) Strict.Nothing +spanAsAnchor ss = EpaSpan ss realSpanAsAnchor :: RealSrcSpan -> Anchor -realSpanAsAnchor r = EpaSpan r Strict.Nothing +realSpanAsAnchor s = EpaSpan (RealSrcSpan s Strict.Nothing) spanFromAnchor :: Anchor -> SrcSpan -spanFromAnchor (EpaSpan r mb) = RealSrcSpan r mb +spanFromAnchor (EpaSpan ss) = ss spanFromAnchor (EpaDelta _ _) = UnhelpfulSpan (UnhelpfulOther (fsLit "spanFromAnchor")) noSpanAnchor :: Anchor @@ -1062,8 +1061,8 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary l = mkRealSrcLoc (fsLit "realSrcSpan") (-1) (-1) srcSpan2e :: SrcSpan -> EpaLocation -srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb -srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing +srcSpan2e ss@(RealSrcSpan _ _) = EpaSpan ss +srcSpan2e span = EpaSpan (RealSrcSpan (realSrcSpan span) Strict.Nothing) la2e :: SrcSpanAnn' a -> EpaLocation la2e = srcSpan2e . locA @@ -1081,7 +1080,7 @@ reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e reAnnL anns cs (L l a) = L (SrcSpanAnn (EpAnn (spanAsAnchor l) anns cs) l) a getLocAnn :: Located a -> SrcSpanAnnA -getLocAnn (L l _) = SrcSpanAnn EpAnnNotUsed l +getLocAnn (L l _) = SrcSpanAnn noAnn l instance NoAnn (EpAnn a) where -- Short form for 'EpAnnNotUsed' @@ -1111,7 +1110,8 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s mb)):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan _):rest) = go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -1120,8 +1120,8 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest - go (AddEpAnn _ (EpaDelta _ _):rest) = go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s _)):rest) = s : go rest + go (AddEpAnn _ _:rest) = go rest realSpanFromAnns :: [AddEpAnn] -> Strict.Maybe RealSrcSpan realSpanFromAnns as = go Strict.Nothing as @@ -1130,7 +1130,7 @@ realSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineRealSrcSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan s _b):rest) = go (combine acc s) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan s _b)):rest) = go (combine acc s) rest go acc (AddEpAnn _ _ :rest) = go acc rest bufSpanFromAnns :: [AddEpAnn] -> Strict.Maybe BufSpan @@ -1140,28 +1140,27 @@ bufSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineBufSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan _ (Strict.Just mb)):rest) = go (combine acc mb) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan _ (Strict.Just mb))):rest) = go (combine acc mb) rest go acc (AddEpAnn _ _:rest) = go acc rest --- widenAnchor :: Anchor -> [AddEpAnn] -> Anchor --- widenAnchor (Anchor s op) as = Anchor (widenRealSpan s as) op widenAnchor :: Anchor -> [AddEpAnn] -> Anchor -widenAnchor (EpaSpan s mb) as - = EpaSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as)) --- widenAnchor (EpaSpan r mb) _ = EpaSpan r mb +widenAnchor (EpaSpan (RealSrcSpan s mb)) as + = EpaSpan (RealSrcSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as))) +widenAnchor (EpaSpan us) _ = EpaSpan us widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of Strict.Nothing -> a - Strict.Just r -> EpaSpan r Strict.Nothing + Strict.Just r -> EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorR :: Anchor -> RealSrcSpan -> Anchor -widenAnchorR (EpaSpan s _) r = EpaSpan (combineRealSrcSpans s r) Strict.Nothing -widenAnchorR (EpaDelta _ _) r = EpaSpan r Strict.Nothing +widenAnchorR (EpaSpan (RealSrcSpan s _)) r = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) Strict.Nothing) +widenAnchorR (EpaSpan _) r = EpaSpan (RealSrcSpan r Strict.Nothing) +widenAnchorR (EpaDelta _ _) r = EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorS :: Anchor -> SrcSpan -> Anchor -widenAnchorS (EpaSpan s mbe) (RealSrcSpan r mbr) - = EpaSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr) -widenAnchorS (EpaSpan us mb) _ = EpaSpan us mb -widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan r mb +widenAnchorS (EpaSpan (RealSrcSpan s mbe)) (RealSrcSpan r mbr) + = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr)) +widenAnchorS (EpaSpan us) _ = EpaSpan us +widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan (RealSrcSpan r mb) widenAnchorS anc _ = anc widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an @@ -1251,7 +1250,7 @@ placeholderRealSpan :: RealSrcSpan placeholderRealSpan = realSrcLocSpan (mkRealSrcLoc (mkFastString "placeholder") (-1) (-1)) comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO -comment loc cs = EpAnn (EpaSpan loc Strict.Nothing) NoEpAnns cs +comment loc cs = EpAnn (EpaSpan (RealSrcSpan loc Strict.Nothing)) NoEpAnns cs -- --------------------------------------------------------------------- -- Utilities for managing comments in an `EpAnn a` structure. @@ -1394,9 +1393,9 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- largest span instance Semigroup EpaLocation where - EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) - EpaSpan s1 m1 <> _ = EpaSpan s1 m1 - _ <> EpaSpan s2 m2 = EpaSpan s2 m2 + EpaSpan s1 <> EpaSpan s2 = EpaSpan (combineSrcSpans s1 s2) + EpaSpan s1 <> _ = EpaSpan s1 + _ <> EpaSpan s2 = EpaSpan s2 EpaDelta dp1 cs1 <> EpaDelta _dp2 cs2 = EpaDelta dp1 (cs1<>cs2) instance Semigroup EpAnnComments where ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3780,7 +3780,8 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan (RealSrcSpan lo Strict.Nothing)), + AddEpAnn AnnCloseP (EpaSpan (RealSrcSpan lc Strict.Nothing))) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -472,29 +472,30 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 - | valid_anchor (anchor a) +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs _))) (EpAnn a (AnnList anc o c r t) cs) cs2 + | valid_anchor a = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs mb)) EpAnnNotUsed cs - = EpAnn (EpaSpan rs mb) - (AnnList (Just $ EpaSpan rs mb) Nothing Nothing [an] []) cs +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs mb))) EpAnnNotUsed cs + = EpAnn (EpaSpan (RealSrcSpan rs mb)) + (AnnList (Just $ EpaSpan (RealSrcSpan rs mb)) Nothing Nothing [an] []) cs add_where (AddEpAnn _ _) _ _ = panic "add_where" -- EpaDelta should only be used for transformations -valid_anchor :: RealSrcSpan -> Bool -valid_anchor r = srcSpanStartLine r >= 0 +valid_anchor :: Anchor -> Bool +valid_anchor (EpaSpan (RealSrcSpan r _)) = srcSpanStartLine r >= 0 +valid_anchor _ = False -- If the decl list for where binds is empty, the anchor ends up -- invalid. In this case, use the parent one patch_anchor :: RealSrcSpan -> Anchor -> Anchor -patch_anchor r (EpaDelta _ _) = EpaSpan r Strict.Nothing -patch_anchor r1 (EpaSpan r0 mb) = EpaSpan r mb +patch_anchor r (EpaDelta _ _) = EpaSpan (RealSrcSpan r Strict.Nothing) +patch_anchor r1 (EpaSpan (RealSrcSpan r0 mb)) = EpaSpan (RealSrcSpan r mb) where r = if srcSpanStartLine r0 < 0 then r1 else r0 --- patch_anchor _ (EpaSpan ss mb) = EpaSpan ss mb +patch_anchor _ (EpaSpan ss) = EpaSpan ss fixValbindsAnn :: EpAnn AnnList -> EpAnn AnnList fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed @@ -504,9 +505,9 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor -stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan r rb)) _), _)) - = Just $ widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) -stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan l mb +stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan (RealSrcSpan r rb))) _), _)) + = Just $ widenAnchorS (EpaSpan (RealSrcSpan l mb)) (RealSrcSpan r rb) +stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan (RealSrcSpan l mb) stmtsAnchor _ = Nothing stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan @@ -994,7 +995,7 @@ checkTyVars pp_what equals_or_where tc tparms for_widening _ = AddEpAnn AnnAnyclass (EpaDelta (SameLine 0) []) for_widening_ann :: HsBndrVis GhcPs -> EpAnn [AddEpAnn] - for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan r _mb)) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments + for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan (RealSrcSpan r _mb))) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments for_widening_ann _ = EpAnnNotUsed @@ -1111,14 +1112,14 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c []) cs) + an = EpAnn (EpaSpan (RealSrcSpan lr Strict.Nothing)) (NameAnn NameParens o (srcSpan2e l) c []) cs in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) - in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) + lr = RealSrcSpan (combineRealSrcSpans (anchor ap) (anchor as)) Strict.Nothing + an = EpAnn (EpaSpan lr) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs) + in SrcSpanAnn an lr -- | Yield a parse error if we have a function applied directly to a do block -- etc. and BlockArguments is not enabled. @@ -3210,14 +3211,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan (RealSrcSpan r mb)) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) +token_location_widenR (TokenLoc (EpaSpan s1)) s2 = + (TokenLoc (EpaSpan (combineSrcSpans s1 s2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== libraries/base/changelog.md ===================================== @@ -3,7 +3,9 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) - * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) + * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #175](https://github.com/haskell/core-libraries-committee/issues/175)) + * Implement `stimes` for `instance Semigroup (Endo a)` explicitly ([CLC proposal #4](https://github.com/haskell/core-libraries-committee/issues/4)) + * Add laws relating between `Foldable` / `Traversable` with `Bifoldable` / `Bitraversable` ([CLC proposal #205](https://github.com/haskell/core-libraries-committee/issues/205)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` @@ -29,6 +31,8 @@ constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + ([CLC proposal #104](https://github.com/haskell/core-libraries-committee/issues/104)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/Data/Semigroup/Internal.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PolyKinds #-} @@ -134,8 +135,46 @@ newtype Endo a = Endo { appEndo :: a -> a } -- | @since 4.9.0.0 instance Semigroup (Endo a) where - (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) - stimes = stimesMonoid + (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) + + -- See Note [stimes Endo] + stimes !n0 (Endo e) = Endo (\a0 -> + -- We check separately for 0 and 1 per + -- https://github.com/haskell/core-libraries-committee/issues/4#issuecomment-955605592 + -- We are explicitly strict in the number so strictness is calculated + -- correctly even without specialization. + case n0 of + _ | n0 < 0 -> stimesEndoError + 0 -> a0 + 1 -> e a0 + _ -> go n0 a0) + where + go !0 a = a + go n a = e (go (n - 1) a) + +{-# NOINLINE stimesEndoError #-} +-- There's no reason to put this gunk in the unfolding. +stimesEndoError :: a +stimesEndoError = errorWithoutStackTrace "stimes (for Endo): negative multiplier" + +-- Note [stimes Endo] +-- ~~~~~~~~~~~~~~~~~~ +-- +-- We used to use +-- +-- stimes = stimesMonoid +-- +-- But this is pretty bad! The function it produces is represented in memory as +-- a balanced tree of compositions. To actually *apply* that function, it's +-- necessary to walk the tree. It's much better to just construct a function +-- that counts out applications. +-- +-- Why do we break open the `Endo` construction rather than just using `mempty` +-- and `<>`? We want GHC to infer that `stimes` has an arity of 3. Currently, +-- it does so by default, but there has been some talk in the past of turning +-- on -fpedantic-bottoms, which would drop the arity to 2. Indeed, if we were +-- really careless, we could theoretically get GHC to build a *list* of +-- compositions, which would be awful. -- | @since 2.01 instance Monoid (Endo a) where ===================================== libraries/base/tests/all.T ===================================== @@ -317,3 +317,4 @@ test('T23697', [ when(opsys('mingw32'), skip) # header not found , when(opsys('darwin'), skip) # permission denied ], makefile_test, ['T23697']) +test('stimesEndo', normal, compile_and_run, ['']) ===================================== libraries/base/tests/stimesEndo.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import Data.Semigroup + +adder :: Int -> Endo Int +adder n = stimes n (Endo (+ 1)) + +main :: IO () +main = print $ map (\n -> appEndo (adder n) 0) [0 .. 5] ===================================== libraries/base/tests/stimesEndo.stdout ===================================== @@ -0,0 +1 @@ +[0,1,2,3,4,5] ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -99,10 +99,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.hs:7:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.hs:7:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.hs:7:3-7 }))] @@ -390,10 +390,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.ppr.hs:5:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.ppr.hs:5:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.ppr.hs:5:3-7 }))] ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -422,7 +422,7 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do debugM $ "enterAnn:starting:(p,pe,anchor',a) =" ++ show (p, pe0, showAst anchor', astId a) prevAnchor <- getAnchorU let curAnchor = case anchor' of - EpaSpan r _ -> r + EpaSpan (RealSrcSpan r _) -> r _ -> prevAnchor debugM $ "enterAnn:(curAnchor):=" ++ show (rs2range curAnchor) case canUpdateAnchor of @@ -495,10 +495,11 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do Just (EpaDelta dp _) -> dp -- Replace original with desired one. Allows all -- list entry values to be DP (1,0) - Just (EpaSpan r _) -> dp + Just (EpaSpan (RealSrcSpan r _)) -> dp where dp = adjustDeltaForOffset off (ss2delta priorEndAfterComments r) + Just (EpaSpan (UnhelpfulSpan r)) -> panic $ "enterAnn: UnhelpfulSpan:" ++ show r -- --------------------------------------------- -- Preparation complete, perform the action when (priorEndAfterComments < spanStart) (do @@ -543,9 +544,10 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do case anchor' of EpaDelta _ _ -> return () - EpaSpan rss _ -> do + EpaSpan (RealSrcSpan rss _) -> do setAcceptSpan False setPriorEndD (snd $ rs2range rss) + EpaSpan _ -> return () -- Outside the anchor, mark any trailing postCs <- cua canUpdateAnchor takeAppliedCommentsPop @@ -723,7 +725,8 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (RealSrcSpan r _)) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (UnhelpfulSpan _)) s = printStringAtAAC capture (EpaDelta (SameLine 0) []) s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ printOneComment $ concatMap tokComment cs pe1 <- getPriorEndD @@ -798,10 +801,10 @@ markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do markLToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) => Located (HsToken tok) -> EP w m (Located (HsToken tok)) markLToken (L (RealSrcSpan aa mb) t) = do - epaLoc'<- printStringAtAA (EpaSpan aa mb) (symbolVal (Proxy @tok)) + epaLoc'<- printStringAtAA (EpaSpan (RealSrcSpan aa mb)) (symbolVal (Proxy @tok)) case epaLoc' of - EpaSpan aa' mb' -> return (L (RealSrcSpan aa' mb') t) - _ -> return (L (RealSrcSpan aa mb ) t) + EpaSpan (RealSrcSpan aa' mb') -> return (L (RealSrcSpan aa' mb') t) + _ -> return (L (RealSrcSpan aa mb ) t) markLToken (L lt t) = return (L lt t) markToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) @@ -1403,12 +1406,13 @@ printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c dp <-case loc of EpaDelta dp _ -> return dp - EpaSpan r _ -> do + EpaSpan (RealSrcSpan r _) -> do pe <- getPriorEndD debugM $ "printOneComment:pe=" ++ showGhc pe let dp = ss2delta pe r debugM $ "printOneComment:(dp,pe,loc)=" ++ showGhc (dp,pe,loc) adjustDeltaForOffsetM dp + EpaSpan (UnhelpfulSpan _) -> return (SameLine 0) mep <- getExtraDP dp' <- case mep of Just (EpaDelta edp _) -> do @@ -1429,12 +1433,13 @@ updateAndApplyComment (Comment str anc pp mo) dp = do (r,c) = ss2posEnd pp dp'' = case anc of EpaDelta dp1 _ -> dp1 - EpaSpan la _ -> + EpaSpan (RealSrcSpan la _) -> if r == 0 then (ss2delta (r,c+0) la) else (ss2delta (r,c) la) + EpaSpan (UnhelpfulSpan _) -> SameLine 0 dp' = case anc of - EpaSpan r1 _ -> + EpaSpan (RealSrcSpan r1 _) -> if pp == r1 then dp else dp'' @@ -1459,7 +1464,7 @@ commentAllocationBefore ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2pos r) <= (ss2pos ss) + EpaSpan (RealSrcSpan r _) -> (ss2pos r) <= (ss2pos ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -1475,7 +1480,7 @@ commentAllocationIn ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2posEnd r) <= (ss2posEnd ss) + EpaSpan (RealSrcSpan r _) -> (ss2posEnd r) <= (ss2posEnd ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -4376,7 +4381,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ _ -> return anc + EpaSpan _ -> return anc EpaDelta dp [] -> return $ EpaDelta dp [] EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -284,7 +284,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance cs = cs' where cs' = case GHC.hsmodLayout $ GHC.hsmodExt p of - GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan ss _)) _) -> + GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan (GHC.RealSrcSpan ss _))) _) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -222,8 +222,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) - EpaDelta _ _ -> AddEpAnn kw dca + EpaSpan (RealSrcSpan r _) -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + _ -> AddEpAnn kw dca -- --------------------------------- @@ -232,7 +232,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let anc0 = case dca of - EpaSpan r _ -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (RealSrcSpan r _) -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (UnhelpfulSpan _) -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc0 noAnn emptyComments) ll) b) (L (SrcSpanAnn (EpAnn anc0 a c) ll) b) @@ -240,7 +241,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H anc' = case anc0 of EpaDelta _ _ -> anc0 _ -> case dca of - EpaSpan _ _ -> EpaDelta (SameLine 1) [] + EpaSpan _ -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc' a c) ll) b) @@ -268,7 +269,11 @@ setEntryDP (L (SrcSpanAnn EpAnnNotUsed l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) noAnn emptyComments) l) a -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _ _) an (EpaComments [])) l) a) dp +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (UnhelpfulSpan _)) an cs) l) a) dp + = L (SrcSpanAnn + (EpAnn (EpaDelta dp []) an cs) + l) a +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _) an (EpaComments [])) l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) an (EpaComments [])) l) a @@ -299,8 +304,8 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaDelta d csd) an cs) l) a) dp in (dp0, c':t, EpaCommentsBalanced [] ts) go (L (EpaDelta _ c0) c) = (d, L (EpaDelta dp c0) c) - go (L (EpaSpan _ _) c) = (d, L (EpaDelta dp []) c) -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp + go (L (EpaSpan _) c) = (d, L (EpaDelta dp []) c) +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r _)) an cs) l) a) dp = case sortEpaComments (priorComments cs) of [] -> L (SrcSpanAnn @@ -315,8 +320,9 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp csd = L (EpaDelta dp []) c:cs' lc = last $ (L ca c:cs') delta = case getLoc lc of - EpaSpan rr _ -> ss2delta (ss2pos rr) r - EpaDelta _dp _ -> DifferentLine 1 0 + EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r + EpaSpan _ -> (SameLine 0) + EpaDelta _ _ -> DifferentLine 1 0 -- cs'' = setPriorComments cs (L (EpaDelta dp []) c:cs') -- lc = head $ reverse $ (L ca c:cs') -- delta = case getLoc lc of @@ -340,17 +346,20 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r _) +addEpaLocationDelta _off _anc s@(EpaSpan (UnhelpfulSpan _)) = s +addEpaLocationDelta off anc (EpaSpan (RealSrcSpan r _)) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor _off (EpaSpan (UnhelpfulSpan _)) (L la a) = L la a +setEntryDPFromAnchor off (EpaSpan (RealSrcSpan anc _)) ll@(L la _) = setEntryDP ll dp' where dp' = case la of (SrcSpanAnn EpAnnNotUsed l) -> adjustDeltaForOffset off (ss2deltaEnd anc (realSrcSpan l)) - (SrcSpanAnn (EpAnn (EpaSpan r' _) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r' _)) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan _) _ _) _) -> adjustDeltaForOffset off (SameLine 0) (SrcSpanAnn (EpAnn (EpaDelta dp _) _ _) _) -> adjustDeltaForOffset off dp -- --------------------------------------------------------------------- @@ -381,7 +390,7 @@ transferEntryDP (L (SrcSpanAnn EpAnnNotUsed _l1) _) (L (SrcSpanAnn (EpAnn anc2 a where anc2' = case anc2 of EpaDelta _ _ -> anc2 - EpaSpan _ _ -> EpaSpan (realSrcSpan l2) Strict.Nothing + EpaSpan _ -> EpaSpan (RealSrcSpan (realSrcSpan l2) Strict.Nothing) -- |If a and b are the same type return first arg, else return second @@ -447,7 +456,7 @@ balanceCommentsFB (L lf (FunBind x n (MG o (L lm matches)))) second = do -- + move the trailing ones to the last match. let (before,middle,after) = case s_entry lf of - EpaSpan ss _ -> + EpaSpan (RealSrcSpan ss _) -> let split = splitCommentsEnd ss (s_comments lf) split2 = splitCommentsStart ss (EpaComments (sortEpaComments $ priorComments split)) @@ -630,7 +639,7 @@ priorCommentsDeltas r cs = go r (reverse $ sortEpaComments cs) splitCommentsEnd :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsEnd p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -638,7 +647,7 @@ splitCommentsEnd p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -649,7 +658,7 @@ splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' splitCommentsStart :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsStart p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -657,7 +666,7 @@ splitCommentsStart p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsStart p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -933,7 +942,8 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (RealSrcSpan r _)) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (UnhelpfulSpan _)) -> LayoutStartCol 0 (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -123,7 +123,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) +undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan (RealSrcSpan sp Strict.Nothing)) where (l,c) = undelta (ss2pos anc) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -170,7 +170,7 @@ spanLength = (-) <$> srcSpanEndCol <*> srcSpanStartCol -- | Useful for debug dumps eloc2str :: EpaLocation -> String -eloc2str (EpaSpan r _) = "EpaSpan " ++ show (rs2range r) +eloc2str (EpaSpan r) = "EpaSpan " ++ show (ss2range r) eloc2str epaLoc = show epaLoc -- --------------------------------------------------------------------- @@ -186,7 +186,7 @@ isPointSrcSpan ss = spanLength ss == 0 -- `MovedAnchor` operation based on the original location, only if it -- does not already have one. commentOrigDelta :: LEpaComment -> LEpaComment -commentOrigDelta (L (EpaSpan la _) (GHC.EpaComment t pp)) +commentOrigDelta (L (EpaSpan (RealSrcSpan la _)) (GHC.EpaComment t pp)) = (L (EpaDelta dp []) (GHC.EpaComment t pp)) `debug` ("commentOrigDelta: (la, pp, r,c, dp)=" ++ showAst (la, pp, r,c, dp)) where @@ -331,8 +331,10 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss mb) - = Comment (keywordToString kw) (EpaSpan ss mb) ss (Just kw) +mkKWComment kw (EpaSpan (RealSrcSpan ss mb)) + = Comment (keywordToString kw) (EpaSpan (RealSrcSpan ss mb)) ss (Just kw) +mkKWComment kw (EpaSpan (UnhelpfulSpan _)) + = Comment (keywordToString kw) (EpaDelta (SameLine 0) []) placeholderRealSpan (Just kw) mkKWComment kw (EpaDelta dp cs) = Comment (keywordToString kw) (EpaDelta dp cs) placeholderRealSpan (Just kw) @@ -444,15 +446,18 @@ To be absolutely sure, we make the delta versions use -ve values. hackSrcSpanToAnchor :: SrcSpan -> Anchor hackSrcSpanToAnchor (UnhelpfulSpan s) = error $ "hackSrcSpanToAnchor : UnhelpfulSpan:" ++ show s -hackSrcSpanToAnchor (RealSrcSpan r Strict.Nothing) = EpaSpan r Strict.Nothing -hackSrcSpanToAnchor (RealSrcSpan r mb@(Strict.Just (BufSpan (BufPos s) (BufPos e)))) - = if s <= 0 && e <= 0 - then EpaDelta (deltaPos (-s) (-e)) [] - `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) - else EpaSpan r mb +hackSrcSpanToAnchor (RealSrcSpan r mb) + = case mb of + (Strict.Just (BufSpan (BufPos s) (BufPos e))) -> + if s <= 0 && e <= 0 + then EpaDelta (deltaPos (-s) (-e)) [] + `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) + -- else Anchor r UnchangedAnchor + else EpaSpan (RealSrcSpan r mb) + _ -> EpaSpan (RealSrcSpan r mb) hackAnchorToSrcSpan :: Anchor -> SrcSpan -hackAnchorToSrcSpan (EpaSpan r mb) = RealSrcSpan r mb +hackAnchorToSrcSpan (EpaSpan s) = s hackAnchorToSrcSpan _ = error $ "hackAnchorToSrcSpan" -- --------------------------------------------------------------------- ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a70ba4918b8a65abd18b16f414b6e2c3c4e38c46 +Subproject commit 96e713f7768926dab4aeec5175c1854057a833c9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b4d8ba6b2d05fe10fc29b13cd377f01f6985458...cee9bb14e6c76c27b702f8b50084435f7e20cf84 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b4d8ba6b2d05fe10fc29b13cd377f01f6985458...cee9bb14e6c76c27b702f8b50084435f7e20cf84 You're receiving 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 Nov 20 23:53:45 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 18:53:45 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Speed up stimes in instance Semigroup Endo Message-ID: <655bf189c6b7c_14c49b6658436c3568dc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 5 changed files: - libraries/base/changelog.md - libraries/base/src/Data/Semigroup/Internal.hs - libraries/base/tests/all.T - + libraries/base/tests/stimesEndo.hs - + libraries/base/tests/stimesEndo.stdout Changes: ===================================== libraries/base/changelog.md ===================================== @@ -3,7 +3,9 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) - * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) + * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #175](https://github.com/haskell/core-libraries-committee/issues/175)) + * Implement `stimes` for `instance Semigroup (Endo a)` explicitly ([CLC proposal #4](https://github.com/haskell/core-libraries-committee/issues/4)) + * Add laws relating between `Foldable` / `Traversable` with `Bifoldable` / `Bitraversable` ([CLC proposal #205](https://github.com/haskell/core-libraries-committee/issues/205)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` @@ -29,6 +31,8 @@ constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + ([CLC proposal #104](https://github.com/haskell/core-libraries-committee/issues/104)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/Data/Semigroup/Internal.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PolyKinds #-} @@ -134,8 +135,46 @@ newtype Endo a = Endo { appEndo :: a -> a } -- | @since 4.9.0.0 instance Semigroup (Endo a) where - (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) - stimes = stimesMonoid + (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) + + -- See Note [stimes Endo] + stimes !n0 (Endo e) = Endo (\a0 -> + -- We check separately for 0 and 1 per + -- https://github.com/haskell/core-libraries-committee/issues/4#issuecomment-955605592 + -- We are explicitly strict in the number so strictness is calculated + -- correctly even without specialization. + case n0 of + _ | n0 < 0 -> stimesEndoError + 0 -> a0 + 1 -> e a0 + _ -> go n0 a0) + where + go !0 a = a + go n a = e (go (n - 1) a) + +{-# NOINLINE stimesEndoError #-} +-- There's no reason to put this gunk in the unfolding. +stimesEndoError :: a +stimesEndoError = errorWithoutStackTrace "stimes (for Endo): negative multiplier" + +-- Note [stimes Endo] +-- ~~~~~~~~~~~~~~~~~~ +-- +-- We used to use +-- +-- stimes = stimesMonoid +-- +-- But this is pretty bad! The function it produces is represented in memory as +-- a balanced tree of compositions. To actually *apply* that function, it's +-- necessary to walk the tree. It's much better to just construct a function +-- that counts out applications. +-- +-- Why do we break open the `Endo` construction rather than just using `mempty` +-- and `<>`? We want GHC to infer that `stimes` has an arity of 3. Currently, +-- it does so by default, but there has been some talk in the past of turning +-- on -fpedantic-bottoms, which would drop the arity to 2. Indeed, if we were +-- really careless, we could theoretically get GHC to build a *list* of +-- compositions, which would be awful. -- | @since 2.01 instance Monoid (Endo a) where ===================================== libraries/base/tests/all.T ===================================== @@ -317,3 +317,4 @@ test('T23697', [ when(opsys('mingw32'), skip) # header not found , when(opsys('darwin'), skip) # permission denied ], makefile_test, ['T23697']) +test('stimesEndo', normal, compile_and_run, ['']) ===================================== libraries/base/tests/stimesEndo.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import Data.Semigroup + +adder :: Int -> Endo Int +adder n = stimes n (Endo (+ 1)) + +main :: IO () +main = print $ map (\n -> appEndo (adder n) 0) [0 .. 5] ===================================== libraries/base/tests/stimesEndo.stdout ===================================== @@ -0,0 +1 @@ +[0,1,2,3,4,5] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/615441ef8bbdbb09ba1b354e8dc234b4aefb863a...cf9da4b3b2af33218ad315a8b2bfb282fb010104 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/615441ef8bbdbb09ba1b354e8dc234b4aefb863a...cf9da4b3b2af33218ad315a8b2bfb282fb010104 You're receiving 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 Nov 20 23:55:15 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 18:55:15 -0500 Subject: [Git][ghc/ghc][master] EPA: Use SrcSpan in EpaSpan Message-ID: <655bf1e317d9_14c49b66593ac43636bc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 12 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - testsuite/tests/printer/Test20297.stdout - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan s) = parens $ text "EpaSpan" <+> srcSpan s epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Hs/ImpExp.hs ===================================== @@ -42,6 +42,7 @@ import GHC.Unit.Module.Warnings import Data.Data import Data.Maybe +import qualified Data.Semigroup as Semigroup {- @@ -119,6 +120,13 @@ data EpAnnImportDecl = EpAnnImportDecl , importDeclAnnAs :: Maybe EpaLocation } deriving (Data) +instance Semigroup EpAnnImportDecl where + EpAnnImportDecl a1 b1 c1 d1 e1 f1 <> EpAnnImportDecl a2 b2 c2 d2 e2 f2 + = EpAnnImportDecl (a1 Semigroup.<> a2) (b1 Semigroup.<> b2) (c1 Semigroup.<> c2) + (d1 Semigroup.<> d2) (e1 Semigroup.<> e2) (f1 Semigroup.<> f2) +instance Monoid EpAnnImportDecl where + mempty = EpAnnImportDecl noSpanAnchor Nothing Nothing Nothing Nothing Nothing + -- --------------------------------------------------------------------- simpleImportDecl :: ModuleName -> ImportDecl GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -4308,7 +4308,7 @@ glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc glR :: HasLoc a => a -> Anchor -glR la = EpaSpan (realSrcSpan $ getHasLoc la) Strict.Nothing +glR la = EpaSpan (getHasLoc la) glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4318,7 +4318,7 @@ glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y anc :: RealSrcSpan -> Anchor -anc r = EpaSpan r Strict.Nothing +anc r = EpaSpan (RealSrcSpan r Strict.Nothing) glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l @@ -4442,7 +4442,7 @@ parseSignature :: P (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (NoAnn ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) -commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan (rs loc) Strict.Nothing) noAnn cs) loc +commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan loc) noAnn cs) loc -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -406,7 +406,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) +data EpaLocation = EpaSpan !SrcSpan | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq,Show) @@ -418,7 +418,7 @@ data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation getTokenSrcSpan :: TokenLocation -> SrcSpan getTokenSrcSpan NoTokenLoc = noSrcSpan getTokenSrcSpan (TokenLoc EpaDelta{}) = noSrcSpan -getTokenSrcSpan (TokenLoc (EpaSpan rspan mbufpos)) = RealSrcSpan rspan mbufpos +getTokenSrcSpan (TokenLoc (EpaSpan span)) = span instance Outputable a => Outputable (GenLocated TokenLocation a) where ppr (L _ x) = ppr x @@ -455,15 +455,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r _) = r -epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" +epaLocationRealSrcSpan (EpaSpan (RealSrcSpan r _)) = r +epaLocationRealSrcSpan _ = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan l +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = anc instance Outputable EpaLocation where - ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -527,18 +527,17 @@ data EpAnn ann type Anchor = EpaLocation -- Transitional anchor :: Anchor -> RealSrcSpan -anchor (EpaSpan r _) = r +anchor (EpaSpan (RealSrcSpan r _)) = r anchor _ = panic "anchor" spanAsAnchor :: SrcSpan -> Anchor -spanAsAnchor (RealSrcSpan r mb) = EpaSpan r mb -spanAsAnchor s = EpaSpan (realSrcSpan s) Strict.Nothing +spanAsAnchor ss = EpaSpan ss realSpanAsAnchor :: RealSrcSpan -> Anchor -realSpanAsAnchor r = EpaSpan r Strict.Nothing +realSpanAsAnchor s = EpaSpan (RealSrcSpan s Strict.Nothing) spanFromAnchor :: Anchor -> SrcSpan -spanFromAnchor (EpaSpan r mb) = RealSrcSpan r mb +spanFromAnchor (EpaSpan ss) = ss spanFromAnchor (EpaDelta _ _) = UnhelpfulSpan (UnhelpfulOther (fsLit "spanFromAnchor")) noSpanAnchor :: Anchor @@ -1062,8 +1061,8 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary l = mkRealSrcLoc (fsLit "realSrcSpan") (-1) (-1) srcSpan2e :: SrcSpan -> EpaLocation -srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb -srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing +srcSpan2e ss@(RealSrcSpan _ _) = EpaSpan ss +srcSpan2e span = EpaSpan (RealSrcSpan (realSrcSpan span) Strict.Nothing) la2e :: SrcSpanAnn' a -> EpaLocation la2e = srcSpan2e . locA @@ -1081,7 +1080,7 @@ reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e reAnnL anns cs (L l a) = L (SrcSpanAnn (EpAnn (spanAsAnchor l) anns cs) l) a getLocAnn :: Located a -> SrcSpanAnnA -getLocAnn (L l _) = SrcSpanAnn EpAnnNotUsed l +getLocAnn (L l _) = SrcSpanAnn noAnn l instance NoAnn (EpAnn a) where -- Short form for 'EpAnnNotUsed' @@ -1111,7 +1110,8 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s mb)):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan _):rest) = go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -1120,8 +1120,8 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest - go (AddEpAnn _ (EpaDelta _ _):rest) = go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s _)):rest) = s : go rest + go (AddEpAnn _ _:rest) = go rest realSpanFromAnns :: [AddEpAnn] -> Strict.Maybe RealSrcSpan realSpanFromAnns as = go Strict.Nothing as @@ -1130,7 +1130,7 @@ realSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineRealSrcSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan s _b):rest) = go (combine acc s) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan s _b)):rest) = go (combine acc s) rest go acc (AddEpAnn _ _ :rest) = go acc rest bufSpanFromAnns :: [AddEpAnn] -> Strict.Maybe BufSpan @@ -1140,28 +1140,27 @@ bufSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineBufSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan _ (Strict.Just mb)):rest) = go (combine acc mb) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan _ (Strict.Just mb))):rest) = go (combine acc mb) rest go acc (AddEpAnn _ _:rest) = go acc rest --- widenAnchor :: Anchor -> [AddEpAnn] -> Anchor --- widenAnchor (Anchor s op) as = Anchor (widenRealSpan s as) op widenAnchor :: Anchor -> [AddEpAnn] -> Anchor -widenAnchor (EpaSpan s mb) as - = EpaSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as)) --- widenAnchor (EpaSpan r mb) _ = EpaSpan r mb +widenAnchor (EpaSpan (RealSrcSpan s mb)) as + = EpaSpan (RealSrcSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as))) +widenAnchor (EpaSpan us) _ = EpaSpan us widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of Strict.Nothing -> a - Strict.Just r -> EpaSpan r Strict.Nothing + Strict.Just r -> EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorR :: Anchor -> RealSrcSpan -> Anchor -widenAnchorR (EpaSpan s _) r = EpaSpan (combineRealSrcSpans s r) Strict.Nothing -widenAnchorR (EpaDelta _ _) r = EpaSpan r Strict.Nothing +widenAnchorR (EpaSpan (RealSrcSpan s _)) r = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) Strict.Nothing) +widenAnchorR (EpaSpan _) r = EpaSpan (RealSrcSpan r Strict.Nothing) +widenAnchorR (EpaDelta _ _) r = EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorS :: Anchor -> SrcSpan -> Anchor -widenAnchorS (EpaSpan s mbe) (RealSrcSpan r mbr) - = EpaSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr) -widenAnchorS (EpaSpan us mb) _ = EpaSpan us mb -widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan r mb +widenAnchorS (EpaSpan (RealSrcSpan s mbe)) (RealSrcSpan r mbr) + = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr)) +widenAnchorS (EpaSpan us) _ = EpaSpan us +widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan (RealSrcSpan r mb) widenAnchorS anc _ = anc widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an @@ -1251,7 +1250,7 @@ placeholderRealSpan :: RealSrcSpan placeholderRealSpan = realSrcLocSpan (mkRealSrcLoc (mkFastString "placeholder") (-1) (-1)) comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO -comment loc cs = EpAnn (EpaSpan loc Strict.Nothing) NoEpAnns cs +comment loc cs = EpAnn (EpaSpan (RealSrcSpan loc Strict.Nothing)) NoEpAnns cs -- --------------------------------------------------------------------- -- Utilities for managing comments in an `EpAnn a` structure. @@ -1394,9 +1393,9 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- largest span instance Semigroup EpaLocation where - EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) - EpaSpan s1 m1 <> _ = EpaSpan s1 m1 - _ <> EpaSpan s2 m2 = EpaSpan s2 m2 + EpaSpan s1 <> EpaSpan s2 = EpaSpan (combineSrcSpans s1 s2) + EpaSpan s1 <> _ = EpaSpan s1 + _ <> EpaSpan s2 = EpaSpan s2 EpaDelta dp1 cs1 <> EpaDelta _dp2 cs2 = EpaDelta dp1 (cs1<>cs2) instance Semigroup EpAnnComments where ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3780,7 +3780,8 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan (RealSrcSpan lo Strict.Nothing)), + AddEpAnn AnnCloseP (EpaSpan (RealSrcSpan lc Strict.Nothing))) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -472,29 +472,30 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 - | valid_anchor (anchor a) +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs _))) (EpAnn a (AnnList anc o c r t) cs) cs2 + | valid_anchor a = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs mb)) EpAnnNotUsed cs - = EpAnn (EpaSpan rs mb) - (AnnList (Just $ EpaSpan rs mb) Nothing Nothing [an] []) cs +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs mb))) EpAnnNotUsed cs + = EpAnn (EpaSpan (RealSrcSpan rs mb)) + (AnnList (Just $ EpaSpan (RealSrcSpan rs mb)) Nothing Nothing [an] []) cs add_where (AddEpAnn _ _) _ _ = panic "add_where" -- EpaDelta should only be used for transformations -valid_anchor :: RealSrcSpan -> Bool -valid_anchor r = srcSpanStartLine r >= 0 +valid_anchor :: Anchor -> Bool +valid_anchor (EpaSpan (RealSrcSpan r _)) = srcSpanStartLine r >= 0 +valid_anchor _ = False -- If the decl list for where binds is empty, the anchor ends up -- invalid. In this case, use the parent one patch_anchor :: RealSrcSpan -> Anchor -> Anchor -patch_anchor r (EpaDelta _ _) = EpaSpan r Strict.Nothing -patch_anchor r1 (EpaSpan r0 mb) = EpaSpan r mb +patch_anchor r (EpaDelta _ _) = EpaSpan (RealSrcSpan r Strict.Nothing) +patch_anchor r1 (EpaSpan (RealSrcSpan r0 mb)) = EpaSpan (RealSrcSpan r mb) where r = if srcSpanStartLine r0 < 0 then r1 else r0 --- patch_anchor _ (EpaSpan ss mb) = EpaSpan ss mb +patch_anchor _ (EpaSpan ss) = EpaSpan ss fixValbindsAnn :: EpAnn AnnList -> EpAnn AnnList fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed @@ -504,9 +505,9 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor -stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan r rb)) _), _)) - = Just $ widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) -stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan l mb +stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan (RealSrcSpan r rb))) _), _)) + = Just $ widenAnchorS (EpaSpan (RealSrcSpan l mb)) (RealSrcSpan r rb) +stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan (RealSrcSpan l mb) stmtsAnchor _ = Nothing stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan @@ -994,7 +995,7 @@ checkTyVars pp_what equals_or_where tc tparms for_widening _ = AddEpAnn AnnAnyclass (EpaDelta (SameLine 0) []) for_widening_ann :: HsBndrVis GhcPs -> EpAnn [AddEpAnn] - for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan r _mb)) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments + for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan (RealSrcSpan r _mb))) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments for_widening_ann _ = EpAnnNotUsed @@ -1111,14 +1112,14 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c []) cs) + an = EpAnn (EpaSpan (RealSrcSpan lr Strict.Nothing)) (NameAnn NameParens o (srcSpan2e l) c []) cs in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) - in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) + lr = RealSrcSpan (combineRealSrcSpans (anchor ap) (anchor as)) Strict.Nothing + an = EpAnn (EpaSpan lr) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs) + in SrcSpanAnn an lr -- | Yield a parse error if we have a function applied directly to a do block -- etc. and BlockArguments is not enabled. @@ -3210,14 +3211,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan (RealSrcSpan r mb)) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) +token_location_widenR (TokenLoc (EpaSpan s1)) s2 = + (TokenLoc (EpaSpan (combineSrcSpans s1 s2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -99,10 +99,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.hs:7:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.hs:7:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.hs:7:3-7 }))] @@ -390,10 +390,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.ppr.hs:5:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.ppr.hs:5:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.ppr.hs:5:3-7 }))] ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -422,7 +422,7 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do debugM $ "enterAnn:starting:(p,pe,anchor',a) =" ++ show (p, pe0, showAst anchor', astId a) prevAnchor <- getAnchorU let curAnchor = case anchor' of - EpaSpan r _ -> r + EpaSpan (RealSrcSpan r _) -> r _ -> prevAnchor debugM $ "enterAnn:(curAnchor):=" ++ show (rs2range curAnchor) case canUpdateAnchor of @@ -495,10 +495,11 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do Just (EpaDelta dp _) -> dp -- Replace original with desired one. Allows all -- list entry values to be DP (1,0) - Just (EpaSpan r _) -> dp + Just (EpaSpan (RealSrcSpan r _)) -> dp where dp = adjustDeltaForOffset off (ss2delta priorEndAfterComments r) + Just (EpaSpan (UnhelpfulSpan r)) -> panic $ "enterAnn: UnhelpfulSpan:" ++ show r -- --------------------------------------------- -- Preparation complete, perform the action when (priorEndAfterComments < spanStart) (do @@ -543,9 +544,10 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do case anchor' of EpaDelta _ _ -> return () - EpaSpan rss _ -> do + EpaSpan (RealSrcSpan rss _) -> do setAcceptSpan False setPriorEndD (snd $ rs2range rss) + EpaSpan _ -> return () -- Outside the anchor, mark any trailing postCs <- cua canUpdateAnchor takeAppliedCommentsPop @@ -723,7 +725,8 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (RealSrcSpan r _)) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (UnhelpfulSpan _)) s = printStringAtAAC capture (EpaDelta (SameLine 0) []) s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ printOneComment $ concatMap tokComment cs pe1 <- getPriorEndD @@ -798,10 +801,10 @@ markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do markLToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) => Located (HsToken tok) -> EP w m (Located (HsToken tok)) markLToken (L (RealSrcSpan aa mb) t) = do - epaLoc'<- printStringAtAA (EpaSpan aa mb) (symbolVal (Proxy @tok)) + epaLoc'<- printStringAtAA (EpaSpan (RealSrcSpan aa mb)) (symbolVal (Proxy @tok)) case epaLoc' of - EpaSpan aa' mb' -> return (L (RealSrcSpan aa' mb') t) - _ -> return (L (RealSrcSpan aa mb ) t) + EpaSpan (RealSrcSpan aa' mb') -> return (L (RealSrcSpan aa' mb') t) + _ -> return (L (RealSrcSpan aa mb ) t) markLToken (L lt t) = return (L lt t) markToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) @@ -1403,12 +1406,13 @@ printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c dp <-case loc of EpaDelta dp _ -> return dp - EpaSpan r _ -> do + EpaSpan (RealSrcSpan r _) -> do pe <- getPriorEndD debugM $ "printOneComment:pe=" ++ showGhc pe let dp = ss2delta pe r debugM $ "printOneComment:(dp,pe,loc)=" ++ showGhc (dp,pe,loc) adjustDeltaForOffsetM dp + EpaSpan (UnhelpfulSpan _) -> return (SameLine 0) mep <- getExtraDP dp' <- case mep of Just (EpaDelta edp _) -> do @@ -1429,12 +1433,13 @@ updateAndApplyComment (Comment str anc pp mo) dp = do (r,c) = ss2posEnd pp dp'' = case anc of EpaDelta dp1 _ -> dp1 - EpaSpan la _ -> + EpaSpan (RealSrcSpan la _) -> if r == 0 then (ss2delta (r,c+0) la) else (ss2delta (r,c) la) + EpaSpan (UnhelpfulSpan _) -> SameLine 0 dp' = case anc of - EpaSpan r1 _ -> + EpaSpan (RealSrcSpan r1 _) -> if pp == r1 then dp else dp'' @@ -1459,7 +1464,7 @@ commentAllocationBefore ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2pos r) <= (ss2pos ss) + EpaSpan (RealSrcSpan r _) -> (ss2pos r) <= (ss2pos ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -1475,7 +1480,7 @@ commentAllocationIn ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2posEnd r) <= (ss2posEnd ss) + EpaSpan (RealSrcSpan r _) -> (ss2posEnd r) <= (ss2posEnd ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -4376,7 +4381,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ _ -> return anc + EpaSpan _ -> return anc EpaDelta dp [] -> return $ EpaDelta dp [] EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -284,7 +284,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance cs = cs' where cs' = case GHC.hsmodLayout $ GHC.hsmodExt p of - GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan ss _)) _) -> + GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan (GHC.RealSrcSpan ss _))) _) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -222,8 +222,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) - EpaDelta _ _ -> AddEpAnn kw dca + EpaSpan (RealSrcSpan r _) -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + _ -> AddEpAnn kw dca -- --------------------------------- @@ -232,7 +232,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let anc0 = case dca of - EpaSpan r _ -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (RealSrcSpan r _) -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (UnhelpfulSpan _) -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc0 noAnn emptyComments) ll) b) (L (SrcSpanAnn (EpAnn anc0 a c) ll) b) @@ -240,7 +241,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H anc' = case anc0 of EpaDelta _ _ -> anc0 _ -> case dca of - EpaSpan _ _ -> EpaDelta (SameLine 1) [] + EpaSpan _ -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc' a c) ll) b) @@ -268,7 +269,11 @@ setEntryDP (L (SrcSpanAnn EpAnnNotUsed l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) noAnn emptyComments) l) a -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _ _) an (EpaComments [])) l) a) dp +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (UnhelpfulSpan _)) an cs) l) a) dp + = L (SrcSpanAnn + (EpAnn (EpaDelta dp []) an cs) + l) a +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _) an (EpaComments [])) l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) an (EpaComments [])) l) a @@ -299,8 +304,8 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaDelta d csd) an cs) l) a) dp in (dp0, c':t, EpaCommentsBalanced [] ts) go (L (EpaDelta _ c0) c) = (d, L (EpaDelta dp c0) c) - go (L (EpaSpan _ _) c) = (d, L (EpaDelta dp []) c) -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp + go (L (EpaSpan _) c) = (d, L (EpaDelta dp []) c) +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r _)) an cs) l) a) dp = case sortEpaComments (priorComments cs) of [] -> L (SrcSpanAnn @@ -315,8 +320,9 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp csd = L (EpaDelta dp []) c:cs' lc = last $ (L ca c:cs') delta = case getLoc lc of - EpaSpan rr _ -> ss2delta (ss2pos rr) r - EpaDelta _dp _ -> DifferentLine 1 0 + EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r + EpaSpan _ -> (SameLine 0) + EpaDelta _ _ -> DifferentLine 1 0 -- cs'' = setPriorComments cs (L (EpaDelta dp []) c:cs') -- lc = head $ reverse $ (L ca c:cs') -- delta = case getLoc lc of @@ -340,17 +346,20 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r _) +addEpaLocationDelta _off _anc s@(EpaSpan (UnhelpfulSpan _)) = s +addEpaLocationDelta off anc (EpaSpan (RealSrcSpan r _)) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor _off (EpaSpan (UnhelpfulSpan _)) (L la a) = L la a +setEntryDPFromAnchor off (EpaSpan (RealSrcSpan anc _)) ll@(L la _) = setEntryDP ll dp' where dp' = case la of (SrcSpanAnn EpAnnNotUsed l) -> adjustDeltaForOffset off (ss2deltaEnd anc (realSrcSpan l)) - (SrcSpanAnn (EpAnn (EpaSpan r' _) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r' _)) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan _) _ _) _) -> adjustDeltaForOffset off (SameLine 0) (SrcSpanAnn (EpAnn (EpaDelta dp _) _ _) _) -> adjustDeltaForOffset off dp -- --------------------------------------------------------------------- @@ -381,7 +390,7 @@ transferEntryDP (L (SrcSpanAnn EpAnnNotUsed _l1) _) (L (SrcSpanAnn (EpAnn anc2 a where anc2' = case anc2 of EpaDelta _ _ -> anc2 - EpaSpan _ _ -> EpaSpan (realSrcSpan l2) Strict.Nothing + EpaSpan _ -> EpaSpan (RealSrcSpan (realSrcSpan l2) Strict.Nothing) -- |If a and b are the same type return first arg, else return second @@ -447,7 +456,7 @@ balanceCommentsFB (L lf (FunBind x n (MG o (L lm matches)))) second = do -- + move the trailing ones to the last match. let (before,middle,after) = case s_entry lf of - EpaSpan ss _ -> + EpaSpan (RealSrcSpan ss _) -> let split = splitCommentsEnd ss (s_comments lf) split2 = splitCommentsStart ss (EpaComments (sortEpaComments $ priorComments split)) @@ -630,7 +639,7 @@ priorCommentsDeltas r cs = go r (reverse $ sortEpaComments cs) splitCommentsEnd :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsEnd p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -638,7 +647,7 @@ splitCommentsEnd p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -649,7 +658,7 @@ splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' splitCommentsStart :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsStart p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -657,7 +666,7 @@ splitCommentsStart p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsStart p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -933,7 +942,8 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (RealSrcSpan r _)) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (UnhelpfulSpan _)) -> LayoutStartCol 0 (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -123,7 +123,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) +undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan (RealSrcSpan sp Strict.Nothing)) where (l,c) = undelta (ss2pos anc) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -170,7 +170,7 @@ spanLength = (-) <$> srcSpanEndCol <*> srcSpanStartCol -- | Useful for debug dumps eloc2str :: EpaLocation -> String -eloc2str (EpaSpan r _) = "EpaSpan " ++ show (rs2range r) +eloc2str (EpaSpan r) = "EpaSpan " ++ show (ss2range r) eloc2str epaLoc = show epaLoc -- --------------------------------------------------------------------- @@ -186,7 +186,7 @@ isPointSrcSpan ss = spanLength ss == 0 -- `MovedAnchor` operation based on the original location, only if it -- does not already have one. commentOrigDelta :: LEpaComment -> LEpaComment -commentOrigDelta (L (EpaSpan la _) (GHC.EpaComment t pp)) +commentOrigDelta (L (EpaSpan (RealSrcSpan la _)) (GHC.EpaComment t pp)) = (L (EpaDelta dp []) (GHC.EpaComment t pp)) `debug` ("commentOrigDelta: (la, pp, r,c, dp)=" ++ showAst (la, pp, r,c, dp)) where @@ -331,8 +331,10 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss mb) - = Comment (keywordToString kw) (EpaSpan ss mb) ss (Just kw) +mkKWComment kw (EpaSpan (RealSrcSpan ss mb)) + = Comment (keywordToString kw) (EpaSpan (RealSrcSpan ss mb)) ss (Just kw) +mkKWComment kw (EpaSpan (UnhelpfulSpan _)) + = Comment (keywordToString kw) (EpaDelta (SameLine 0) []) placeholderRealSpan (Just kw) mkKWComment kw (EpaDelta dp cs) = Comment (keywordToString kw) (EpaDelta dp cs) placeholderRealSpan (Just kw) @@ -444,15 +446,18 @@ To be absolutely sure, we make the delta versions use -ve values. hackSrcSpanToAnchor :: SrcSpan -> Anchor hackSrcSpanToAnchor (UnhelpfulSpan s) = error $ "hackSrcSpanToAnchor : UnhelpfulSpan:" ++ show s -hackSrcSpanToAnchor (RealSrcSpan r Strict.Nothing) = EpaSpan r Strict.Nothing -hackSrcSpanToAnchor (RealSrcSpan r mb@(Strict.Just (BufSpan (BufPos s) (BufPos e)))) - = if s <= 0 && e <= 0 - then EpaDelta (deltaPos (-s) (-e)) [] - `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) - else EpaSpan r mb +hackSrcSpanToAnchor (RealSrcSpan r mb) + = case mb of + (Strict.Just (BufSpan (BufPos s) (BufPos e))) -> + if s <= 0 && e <= 0 + then EpaDelta (deltaPos (-s) (-e)) [] + `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) + -- else Anchor r UnchangedAnchor + else EpaSpan (RealSrcSpan r mb) + _ -> EpaSpan (RealSrcSpan r mb) hackAnchorToSrcSpan :: Anchor -> SrcSpan -hackAnchorToSrcSpan (EpaSpan r mb) = RealSrcSpan r mb +hackAnchorToSrcSpan (EpaSpan s) = s hackAnchorToSrcSpan _ = error $ "hackAnchorToSrcSpan" -- --------------------------------------------------------------------- ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a70ba4918b8a65abd18b16f414b6e2c3c4e38c46 +Subproject commit 96e713f7768926dab4aeec5175c1854057a833c9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48bf364ed888f7a7b2fda06a6620078a294b4929 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48bf364ed888f7a7b2fda06a6620078a294b4929 You're receiving 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 Nov 20 23:56:05 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 20 Nov 2023 18:56:05 -0500 Subject: [Git][ghc/ghc][master] Add regression test for #6070 Message-ID: <655bf2154c5f1_14c49b66599a6436925c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - 3 changed files: - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ec37cc28e8aa39aa7ae0b1f02d695338656009 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ec37cc28e8aa39aa7ae0b1f02d695338656009 You're receiving 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 Nov 21 01:09:25 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 20 Nov 2023 20:09:25 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 10 commits: JS: clean up some foreign imports Message-ID: <655c03454aa11_14c49b688a1b103756bf@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - c793b629 by Apoorv Ingle at 2023-11-20T19:09:12-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Make records Expand and not desugar before typechecking. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 2dd6f510 by Apoorv Ingle at 2023-11-20T19:09:12-06:00 - Renaming `GHC.Types.Basic.{Origin -> MatchOrigin}` - - - - - 039d28f3 by Apoorv Ingle at 2023-11-20T19:09:12-06:00 experimenting with hpc ticks - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - + compiler/GHC/Tc/Gen/Do.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a82fe36873243224146a4d0e6b38f60ce8d8d13...039d28f342a574f6c15204c8467d1e6da5554e11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a82fe36873243224146a4d0e6b38f60ce8d8d13...039d28f342a574f6c15204c8467d1e6da5554e11 You're receiving 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 Nov 21 01:28:06 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Mon, 20 Nov 2023 20:28:06 -0500 Subject: [Git][ghc/ghc][wip/DataToTagSmallOp] 2 commits: Introduce `dataToTagSmall#` primop (closes #21710) Message-ID: <655c07a653c24_14c49b69226b7c378295@gitlab.mail> Matthew Craven pushed to branch wip/DataToTagSmallOp at Glasgow Haskell Compiler / GHC Commits: c95aefb4 by Matthew Craven at 2023-11-20T20:26:38-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T11374 - - - - - 9e324823 by Matthew Craven at 2023-11-20T20:27:24-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 17 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Instance/Class.hs - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - testsuite/tests/codeGen/should_compile/T21710a.stderr - testsuite/tests/linters/notes.stdout - testsuite/tests/simplCore/should_compile/T22375.hs - testsuite/tests/simplCore/should_compile/T22375.stderr - testsuite/tests/simplCore/should_compile/T22375DataFamily.hs - testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr Changes: ===================================== compiler/GHC/Builtin/PrimOps.hs ===================================== @@ -921,5 +921,6 @@ instance Outputable PrimCall where primOpIsReallyInline :: PrimOp -> Bool primOpIsReallyInline = \case SeqOp -> False - DataToTagOp -> False + DataToTagSmallOp -> False + DataToTagLargeOp -> False p -> not (primOpOutOfLine p) ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3689,7 +3689,27 @@ section "Tag to enum stuff" and small integers.} ------------------------------------------------------------------------ -primop DataToTagOp "dataToTagLarge#" GenPrimOp +primop DataToTagSmallOp "dataToTagSmall#" GenPrimOp + a_levpoly -> Int# + { Used internally to implement @dataToTag#@: Use that function instead! + This one offers /no advantage/ and comes with no stability + guarantees: it may change its type, its name, or its behavior + with /no warning/ between compiler releases. + + It is expected that this function will be un-exposed in a future + release of ghc. + + For more details, look at @Note [DataToTag overview]@ + in GHC.Tc.Instance.Class in the source code for + /the specific compiler version you are using./ + } + with + deprecated_msg = { Use dataToTag# from \"GHC.Magic\" instead. } + strictness = { \ _arity -> mkClosedDmdSig [evalDmd] topDiv } + effect = ThrowsException + cheap = True + +primop DataToTagLargeOp "dataToTagLarge#" GenPrimOp a_levpoly -> Int# { Used internally to implement @dataToTag#@: Use that function instead! This one offers /no advantage/ and comes with no stability ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1142,7 +1142,8 @@ checkDataToTagPrimOpTyCon -> [CoreArg] -- ^ The arguments to the application -> LintM () checkDataToTagPrimOpTyCon (Var fun_id) args - | Just DataToTagOp <- isPrimOpId_maybe fun_id + | Just op <- isPrimOpId_maybe fun_id + , op == DataToTagSmallOp || op == DataToTagLargeOp = case args of Type _levity : Type dty : _rest | Just (tc, _) <- splitTyConApp_maybe dty ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -102,7 +102,8 @@ That is why these rules are built in here. primOpRules :: Name -> PrimOp -> Maybe CoreRule primOpRules nm = \case TagToEnumOp -> mkPrimOpRule nm 2 [ tagToEnumRule ] - DataToTagOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagSmallOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagLargeOp -> mkPrimOpRule nm 3 [ dataToTagRule ] -- Int8 operations Int8AddOp -> mkPrimOpRule nm 2 [ binaryLit (int8Op2 (+)) @@ -3374,7 +3375,8 @@ caseRules platform (App (App (Var f) type_arg) v) -- See Note [caseRules for dataToTag] caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x - | Just DataToTagOp <- isPrimOpId_maybe f + | Just op <- isPrimOpId_maybe f + , op == DataToTagSmallOp || op == DataToTagLargeOp = case splitTyConApp_maybe ty of Just (tc, _) | isValidDTT2TyCon tc -> Just (v, tx_con_dtt tc @@ -3382,9 +3384,9 @@ caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x _ -> pprTraceUserWarning warnMsg Nothing where warnMsg = vcat $ map text - [ "Found dataToTag primop applied to a non-ADT type. This" - , "could be a future bug in GHC, or it may be caused by an" - , "unsupported use of the ghc-internal primop dataToTagLarge#." + [ "Found dataToTag primop applied to a non-ADT type. This could" + , "be a future bug in GHC, or it may be caused by an unsupported" + , "use of the ghc-internal primops dataToTagSmall# and dataToTagLarge#." , "In either case, the GHC developers would like to know about it!" , "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug" ] ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -495,10 +495,9 @@ occurrence of `x` and `y` to record whether it is evaluated and properly tagged. For the vast majority of primops that's a waste of time: the argument is an `Int#` or something. -But code generation for `seq#` and `dataToTagLarge#` /does/ consult that -tag, to statically avoid generating an eval: -* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig` -* `dataToTagLarge#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`. +But code generation for `seq#` and the `dataToTag#` ops /does/ consult that +tag, to statically avoid generating an eval. All three do so via `cgIdApp`, +which in turn uses `getCallMethod` which looks at the `tagSig`. So for these we should call `rewriteArgs`. @@ -507,7 +506,7 @@ So for these we should call `rewriteArgs`. rewriteOpApp :: InferStgExpr -> RM TgStgExpr rewriteOpApp (StgOpApp op args res_ty) = case op of op@(StgPrimOp primOp) - | primOp == SeqOp || primOp == DataToTagOp + | primOp == SeqOp || primOp == DataToTagSmallOp || primOp == DataToTagLargeOp -- see Note [Rewriting primop arguments] -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty _ -> pure $! StgOpApp op args res_ty ===================================== compiler/GHC/StgToCmm/Expr.hs ===================================== @@ -37,7 +37,7 @@ import GHC.Cmm.Graph import GHC.Cmm.BlockId import GHC.Cmm hiding ( succ ) import GHC.Cmm.Info -import GHC.Cmm.Utils ( zeroExpr, cmmTagMask, mkWordCLit, mAX_PTR_TAG ) +import GHC.Cmm.Utils ( cmmTagMask, mkWordCLit, mAX_PTR_TAG ) import GHC.Core import GHC.Core.DataCon import GHC.Types.ForeignCall @@ -73,55 +73,49 @@ cgExpr (StgApp fun args) = cgIdApp fun args cgExpr (StgOpApp (StgPrimOp SeqOp) [StgVarArg a, _] _res_ty) = cgIdApp a [] +-- dataToTagSmall# :: a_levpoly -> Int# +-- See Note [DataToTag overview] in GHC.Tc.Instance.Class +cgExpr (StgOpApp (StgPrimOp DataToTagSmallOp) [StgVarArg a] _res_ty) = do + platform <- getPlatform + emitComment (mkFastString "dataToTagSmall#") + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + tag1 = cmmConstrTag1 platform a_eval_expr + + -- subtract 1 because we need to return a zero-indexed tag + emitReturn [cmmSubWord platform tag1 (CmmLit $ mkWordCLit platform 1)] + -- dataToTagLarge# :: a_levpoly -> Int# -- See Note [DataToTag overview] in GHC.Tc.Instance.Class --- TODO: There are some more optimization ideas for this code path --- in #21710 -cgExpr (StgOpApp (StgPrimOp DataToTagOp) [StgVarArg a] _res_ty) = do +cgExpr (StgOpApp (StgPrimOp DataToTagLargeOp) [StgVarArg a] _res_ty) = do platform <- getPlatform emitComment (mkFastString "dataToTagLarge#") - info <- getCgIdInfo a - let amode = idInfoToAmode info - tag_reg <- assignTemp $ cmmConstrTag1 platform amode + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + + tag1_reg <- assignTemp $ cmmConstrTag1 platform a_eval_expr result_reg <- newTemp (bWord platform) - let tag = CmmReg $ CmmLocal tag_reg - is_tagged = cmmNeWord platform tag (zeroExpr platform) - is_too_big_tag = cmmEqWord platform tag (cmmTagMask platform) - -- Here we will first check the tag bits of the pointer we were given; - -- if this doesn't work then enter the closure and use the info table - -- to determine the constructor. Note that all tag bits set means that - -- the constructor index is too large to fit in the pointer and therefore - -- we must look in the info table. See Note [Tagging big families]. - - (fast_path :: CmmAGraph) <- getCode $ do - -- Return the constructor index from the pointer tag - return_ptr_tag <- getCode $ do - emitAssign (CmmLocal result_reg) - $ cmmSubWord platform tag (CmmLit $ mkWordCLit platform 1) - -- Return the constructor index recorded in the info table - return_info_tag <- getCode $ do - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform amode) - - emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) - -- If we know the argument is already tagged there is no need to generate code to evaluate it - -- so we skip straight to the fast path. If we don't know if there is a tag we take the slow - -- path which evaluates the argument before fetching the tag. - case (idTagSig_maybe a) of - Just sig - | isTaggedSig sig - -> emit fast_path - _ -> do - slow_path <- getCode $ do - tmp <- newTemp (bWord platform) - _ <- withSequel (AssignTo [tmp] False) (cgIdApp a []) - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform (CmmReg (CmmLocal tmp))) - emit =<< mkCmmIfThenElse' is_tagged fast_path slow_path (Just True) + let tag1_expr = CmmReg $ CmmLocal tag1_reg + is_too_big_tag = cmmEqWord platform tag1_expr (cmmTagMask platform) + + -- Return the constructor index from the pointer tag + -- (Used if pointer tag is small enough to be unambiguous) + return_ptr_tag <- getCode $ do + emitAssign (CmmLocal result_reg) + $ cmmSubWord platform tag1_expr (CmmLit $ mkWordCLit platform 1) + + -- Return the constructor index recorded in the info table + return_info_tag <- getCode $ do + profile <- getProfile + align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig + emitAssign (CmmLocal result_reg) + $ getConstrTag profile align_check (cmmUntag platform a_eval_expr) + + emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) emitReturn [CmmReg $ CmmLocal result_reg] @@ -638,9 +632,10 @@ isSimpleScrut _ _ = return False isSimpleOp :: StgOp -> [StgArg] -> FCode Bool -- True iff the op cannot block or allocate isSimpleOp (StgFCallOp (CCall (CCallSpec _ _ safe)) _) _ = return $! not (playSafe safe) --- dataToTagLarge# evaluates its argument; +-- dataToTagSmall#/dataToTagLarge# evaluate an argument; -- see Note [DataToTag overview] in GHC.Tc.Instance.Class -isSimpleOp (StgPrimOp DataToTagOp) _ = return False +isSimpleOp (StgPrimOp DataToTagSmallOp) _ = return False +isSimpleOp (StgPrimOp DataToTagLargeOp) _ = return False isSimpleOp (StgPrimOp op) stg_args = do arg_exprs <- getNonVoidArgAmodes stg_args cfg <- getStgToCmmConfig @@ -851,6 +846,7 @@ cgAlts _ _ _ _ = panic "cgAlts" -- Note [alg-alt heap check] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- In an algebraic case with more than one alternative, we will have -- code like ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1640,7 +1640,8 @@ emitPrimOp cfg primop = SeqOp -> alwaysExternal GetSparkOp -> alwaysExternal NumSparks -> alwaysExternal - DataToTagOp -> alwaysExternal + DataToTagSmallOp -> alwaysExternal + DataToTagLargeOp -> alwaysExternal MkApUpd0_Op -> alwaysExternal NewBCOOp -> alwaysExternal UnpackClosureOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -967,7 +967,11 @@ genPrim prof bound ty op = case op of ------------------------------ Tag to enum stuff -------------------------------- - DataToTagOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + DataToTagSmallOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + [ stack .! PreInc sp |= var "h$dataToTag_e" + , returnS (app "h$e" [d]) + ] + DataToTagLargeOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat [ stack .! PreInc sp |= var "h$dataToTag_e" , returnS (app "h$e" [d]) ] ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -50,6 +50,8 @@ import GHC.Core.Class import GHC.Core ( Expr(..) ) +import GHC.StgToCmm.Closure ( isSmallFamily ) + import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc( splitAtList, fstOf3 ) @@ -671,15 +673,17 @@ But, to avoid all this boilerplate code, and improve optimisation opportunities, GHC generates instances like this: instance DataToTag [a] where - dataToTag# = dataToTagLarge# + dataToTag# = dataToTagSmall# -using a (temporarily strangely-named) primop `dataToTagLarge#`. The -primop has the following over-polymorphic type +using one of two dedicated primops: `dataToTagSmall#` and `dataToTagLarge#`. +(These two primops differ only in code generation; see wrinkle DTW4 below.) +Both primops have the following over-polymorphic type: dataToTagLarge# :: forall {l::levity} (a::TYPE (BoxedRep l)). a -> Int# -Every call to (dataToTagLarge# @{lev} @ty) that we generate should -satisfy these conditions: +Every call to either primop that we generate should look like +(dataToTagSmall# @{lev} @ty) with two type arguments that satisfy +these conditions: (DTT1) `lev` is concrete (either lifted or unlifted), not polymorphic. This is an invariant--we must satisfy this or Core Lint will complain. @@ -698,21 +702,21 @@ satisfy these conditions: GHC.Rename.Module. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold for why this matters. - While the dataToTagLarge# primop remains exposed from GHC.Prim + While the dataToTag# primops remain exposed from GHC.Prim (and abused in GHC.PrimopWrappers), this cannot be a true invariant. - But with a little effort we can ensure that every `dataToTagLarge#` + But with a little effort we can ensure that every primop call we generate in a DataToTag instance satisfies this condition. -The `dataToTagLarge#` primop has special handling in several parts of +These two primops have special handling in several parts of the compiler: -- It has a couple of built-in rewrite rules, implemented in +- They have a couple of built-in rewrite rules, implemented in GHC.Core.Opt.ConstantFold.dataToTagRule -- The simplifier rewrites most case expressions scrutinizing its result. +- The simplifier rewrites most case expressions scrutinizing their result. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold. -- It evaluates its argument; this is implemented via a special case in +- Each evaluates its argument; this is implemented via special cases in GHC.StgToCmm.Expr.cgExpr. - Additionally, a special case in GHC.Stg.InferTags.Rewrite.rewriteExpr ensures @@ -727,12 +731,12 @@ Wrinkles: [W] DataToTag (D (Either t1 t2)) GHC uses the built-in instance instance DataToTag (D (Either p q)) where - dataToTag# x = dataToTagLarge# @Lifted @(R:DEither p q) + dataToTag# x = dataToTagSmall# @Lifted @(R:DEither p q) (x |> sym (ax:DEither p q)) where `ax:DEither` is the axiom arising from the `data instance`: ax:DEither p q :: D (Either p q) ~ R:DEither p q - Notice that we cast `x` before giving it to `dataToTagLarge#`, so + Notice that we cast `x` before giving it to `dataToTagSmall#`, so that (DTT2) is satisfied. (DTW2) Suppose we have module A (T(..)) where { data T = TCon } @@ -747,7 +751,7 @@ Wrinkles: (DTW3) Similar to DTW2, consider this example: {-# LANGUAGE MagicHash #-} - module A (X(X2, X3), f) where + module A (X(X2, X3), g) where -- see also testsuite/tests/warnings/should_compile/DataToTagWarnings.hs import GHC.Exts (dataToTag#, Int#) data X = X1 | X2 | X3 | X4 @@ -774,10 +778,18 @@ Wrinkles: keepAlive on the constructor names. (Contrast with Note [Unused name reporting and HasField].) -(DTW4) It is expected that in the future some instances may select more - efficient specialised implementations; for example we may use a - separate `dataToTagSmall#` primop for a type with only a few - constructors; see #17079 and #21710. +(DTW4) The way tag information is stored at runtime is described in + Note [Tagging big families] in GHC.StgToCmm.Expr. In particular, + for "big data types" we must consult the heap object's info table at + least in the MAX_PTR_TAG case, while for "small data types" we can + always just examine the tag bits on the pointer itself. + + Although it is always correct to consult the info table, we can + produce slightly smaller and faster code by not doing so for "small + data types." Since types and coercions are largely erased in STG, + the simplest reliable way to achieve this is to produce different + primops in DataToTag instances depending on the number of data + constructors the relevant TyCon has. (DTW5) We make no promises about the primops used to implement DataToTag instances. Changes to GHC's representation of algebraic @@ -816,6 +828,7 @@ matchDataToTag :: Class -> [Type] -> TcM ClsInstResult matchDataToTag dataToTagClass [levity, dty] = do famEnvs <- tcGetFamInstEnvs (gbl_env, _lcl_env) <- getEnvs + platform <- getPlatform if | isConcreteType levity -- condition C3 , Just (rawTyCon, rawTyConArgs) <- tcSplitTyConApp_maybe dty , let (repTyCon, repArgs, repCo) @@ -828,13 +841,14 @@ matchDataToTag dataToTagClass [levity, dty] = do , let rdr_env = tcg_rdr_env gbl_env inScope con = isJust $ lookupGRE_Name rdr_env $ dataConName con , all inScope constrs -- condition C2 + , let repTy = mkTyConApp repTyCon repArgs - whichOp - -- TODO: More optimized implementations for: - -- * small constructor families - -- * Bool/Int/Float/etc. on JS backend + numConstrs = tyConFamilySize repTyCon + !whichOp -- see wrinkle DTW4 + | isSmallFamily platform numConstrs + = primOpId DataToTagSmallOp | otherwise - = primOpId DataToTagOp + = primOpId DataToTagLargeOp -- See wrinkle DTW1; we must apply the underlying -- operation at the representation type and cast it ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,8 +117,8 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,8 +133,8 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== testsuite/tests/codeGen/should_compile/T21710a.stderr ===================================== @@ -1,117 +1,44 @@ -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'E2_bytes" { - M.$tc'E2_bytes: - I8[] "'E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'D2_bytes" { - M.$tc'D2_bytes: - I8[] "'D" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'C2_bytes" { - M.$tc'C2_bytes: - I8[] "'C" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'B2_bytes" { - M.$tc'B2_bytes: - I8[] "'B" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'A3_bytes" { - M.$tc'A3_bytes: - I8[] "'A" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tcE2_bytes" { - M.$tcE2_bytes: - I8[] "E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule2_bytes" { - M.$trModule2_bytes: - I8[] "M" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule4_bytes" { - M.$trModule4_bytes: - I8[] "main" - }] - - - ==================== Output Cmm ==================== [M.foo_entry() { // [R2] - { info_tbls: [(cBa, - label: block_cBa_info + { info_tbls: [(cCU, + label: block_cCU_info rep: StackRep [] srt: Nothing), - (cBi, + (cD2, label: M.foo_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cBi: // global - if ((Sp + -8) < SpLim) (likely: False) goto cBj; else goto cBk; // CmmCondBranch - cBj: // global + cD2: // global + if ((Sp + -8) < SpLim) (likely: False) goto cD3; else goto cD4; // CmmCondBranch + cD3: // global R1 = M.foo_closure; // CmmAssign call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall - cBk: // global - I64[Sp - 8] = cBa; // CmmStore + cD4: // global + I64[Sp - 8] = cCU; // CmmStore R1 = R2; // CmmAssign Sp = Sp - 8; // CmmAssign - if (R1 & 7 != 0) goto cBa; else goto cBb; // CmmCondBranch - cBb: // global - call (I64[R1])(R1) returns to cBa, args: 8, res: 8, upd: 8; // CmmCall - cBa: // global - _cBh::P64 = R1 & 7; // CmmAssign - if (_cBh::P64 != 1) goto uBz; else goto cBf; // CmmCondBranch - uBz: // global - if (_cBh::P64 != 2) goto cBe; else goto cBg; // CmmCondBranch - cBe: // global - // dataToTag# - _cBn::P64 = R1 & 7; // CmmAssign - if (_cBn::P64 == 7) (likely: False) goto cBs; else goto cBr; // CmmCondBranch - cBs: // global - _cBo::I64 = %MO_UU_Conv_W32_W64(I32[I64[R1 & (-8)] - 4]); // CmmAssign - goto cBq; // CmmBranch - cBr: // global - _cBo::I64 = _cBn::P64 - 1; // CmmAssign - goto cBq; // CmmBranch - cBq: // global - R1 = _cBo::I64; // CmmAssign + if (R1 & 7 != 0) goto cCU; else goto cCV; // CmmCondBranch + cCV: // global + call (I64[R1])(R1) returns to cCU, args: 8, res: 8, upd: 8; // CmmCall + cCU: // global + _cD1::P64 = R1 & 7; // CmmAssign + if (_cD1::P64 != 1) goto uDf; else goto cCZ; // CmmCondBranch + uDf: // global + if (_cD1::P64 != 2) goto cCY; else goto cD0; // CmmCondBranch + cCY: // global + // dataToTagSmall# + R1 = R1 & 7 - 1; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBg: // global + cD0: // global R1 = 42; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBf: // global + cCZ: // global R1 = 2; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall @@ -124,190 +51,6 @@ -==================== Output Cmm ==================== -[section ""data" . M.$trModule3_closure" { - M.$trModule3_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule4_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule1_closure" { - M.$trModule1_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule_closure" { - M.$trModule_closure: - const GHC.Types.Module_con_info; - const M.$trModule3_closure+1; - const M.$trModule1_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE1_closure" { - M.$tcE1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tcE2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE_closure" { - M.$tcE_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tcE1_closure+1; - const GHC.Types.krep$*_closure+5; - const 10475418246443540865; - const 12461417314693222409; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A1_closure" { - M.$tc'A1_closure: - const GHC.Types.KindRepTyConApp_con_info; - const M.$tcE_closure+1; - const GHC.Types.[]_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A2_closure" { - M.$tc'A2_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'A3_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A_closure" { - M.$tc'A_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'A2_closure+1; - const M.$tc'A1_closure+1; - const 10991425535368257265; - const 3459663971500179679; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B1_closure" { - M.$tc'B1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'B2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B_closure" { - M.$tc'B_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'B1_closure+1; - const M.$tc'A1_closure+1; - const 13038863156169552918; - const 13430333535161531545; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C1_closure" { - M.$tc'C1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'C2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C_closure" { - M.$tc'C_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'C1_closure+1; - const M.$tc'A1_closure+1; - const 8482817676735632621; - const 8146597712321241387; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D1_closure" { - M.$tc'D1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'D2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D_closure" { - M.$tc'D_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'D1_closure+1; - const M.$tc'A1_closure+1; - const 7525207739284160575; - const 13746130127476219356; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E1_closure" { - M.$tc'E1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'E2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E_closure" { - M.$tc'E_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'E1_closure+1; - const M.$tc'A1_closure+1; - const 6748545530683684316; - const 10193016702094081137; - const 0; - const 3; - }] - - - ==================== Output Cmm ==================== [section ""data" . M.A_closure" { M.A_closure: @@ -362,14 +105,14 @@ ==================== Output Cmm ==================== [M.A_con_entry() { // [] - { info_tbls: [(cC5, + { info_tbls: [(cDt, label: M.A_con_info rep: HeapRep 1 nonptrs { Con {tag: 0 descr:"main:M.A"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cC5: // global + cDt: // global R1 = R1 + 1; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -379,14 +122,14 @@ ==================== Output Cmm ==================== [M.B_con_entry() { // [] - { info_tbls: [(cCa, + { info_tbls: [(cDy, label: M.B_con_info rep: HeapRep 1 nonptrs { Con {tag: 1 descr:"main:M.B"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCa: // global + cDy: // global R1 = R1 + 2; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -396,14 +139,14 @@ ==================== Output Cmm ==================== [M.C_con_entry() { // [] - { info_tbls: [(cCf, + { info_tbls: [(cDD, label: M.C_con_info rep: HeapRep 1 nonptrs { Con {tag: 2 descr:"main:M.C"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCf: // global + cDD: // global R1 = R1 + 3; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -413,14 +156,14 @@ ==================== Output Cmm ==================== [M.D_con_entry() { // [] - { info_tbls: [(cCk, + { info_tbls: [(cDI, label: M.D_con_info rep: HeapRep 1 nonptrs { Con {tag: 3 descr:"main:M.D"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCk: // global + cDI: // global R1 = R1 + 4; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -430,14 +173,14 @@ ==================== Output Cmm ==================== [M.E_con_entry() { // [] - { info_tbls: [(cCp, + { info_tbls: [(cDN, label: M.E_con_info rep: HeapRep 1 nonptrs { Con {tag: 4 descr:"main:M.E"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCp: // global + cDN: // global R1 = R1 + 5; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,41 +1,40 @@ -ref compiler/GHC/Core/Coercion/Axiom.hs:463:2: Note [RoughMap and rm_empty] -ref compiler/GHC/Core/Opt/OccurAnal.hs:983:7: Note [Loop breaking] -ref compiler/GHC/Core/Opt/SetLevels.hs:1574:30: Note [Top level scope] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2826:13: Note [Case binder next] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4018:8: Note [Lambda-bound unfoldings] -ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1343:37: Note [Gentle mode] -ref compiler/GHC/Core/Opt/Specialise.hs:1765:29: Note [Arity decrease] -ref compiler/GHC/Core/TyCo/Rep.hs:1565:31: Note [What prevents a constraint from floating] -ref compiler/GHC/Driver/DynFlags.hs:1245:49: Note [Eta-reduction in -O0] -ref compiler/GHC/Driver/Main.hs:1762:34: Note [simpleTidyPgm - mkBootModDetailsTc] -ref compiler/GHC/Hs/Expr.hs:194:63: Note [Pending Splices] -ref compiler/GHC/Hs/Expr.hs:1738:87: Note [Lifecycle of a splice] -ref compiler/GHC/Hs/Expr.hs:1774:7: Note [Pending Splices] -ref compiler/GHC/Hs/Extension.hs:146:5: Note [Strict argument type constraints] -ref compiler/GHC/Hs/Pat.hs:143:74: Note [Lifecycle of a splice] -ref compiler/GHC/HsToCore/Pmc/Solver.hs:858:20: Note [COMPLETE sets on data families] -ref compiler/GHC/HsToCore/Quote.hs:1476:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Stg/Unarise.hs:442:32: Note [Renaming during unarisation] -ref compiler/GHC/StgToCmm/Expr.hs:585:4: Note [case on bool] -ref compiler/GHC/StgToCmm/Expr.hs:853:3: Note [alg-alt heap check] +ref compiler/GHC/Core/Coercion/Axiom.hs:472:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/OccurAnal.hs:1157:7: Note [Loop breaking] +ref compiler/GHC/Core/Opt/SetLevels.hs:1586:30: Note [Top level scope] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2832:13: Note [Case binder next] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4023:8: Note [Lambda-bound unfoldings] +ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1342:37: Note [Gentle mode] +ref compiler/GHC/Core/Opt/Specialise.hs:1763:29: Note [Arity decrease] +ref compiler/GHC/Core/TyCo/Rep.hs:1652:31: Note [What prevents a constraint from floating] +ref compiler/GHC/Driver/DynFlags.hs:1251:52: Note [Eta-reduction in -O0] +ref compiler/GHC/Driver/Main.hs:1749:34: Note [simpleTidyPgm - mkBootModDetailsTc] +ref compiler/GHC/Hs/Expr.hs:191:63: Note [Pending Splices] +ref compiler/GHC/Hs/Expr.hs:1727:87: Note [Lifecycle of a splice] +ref compiler/GHC/Hs/Expr.hs:1763:7: Note [Pending Splices] +ref compiler/GHC/Hs/Extension.hs:147:5: Note [Strict argument type constraints] +ref compiler/GHC/Hs/Pat.hs:141:74: Note [Lifecycle of a splice] +ref compiler/GHC/HsToCore/Pmc/Solver.hs:856:20: Note [COMPLETE sets on data families] +ref compiler/GHC/HsToCore/Quote.hs:1487:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Stg/Unarise.hs:438:32: Note [Renaming during unarisation] +ref compiler/GHC/StgToCmm/Expr.hs:578:4: Note [case on bool] ref compiler/GHC/Tc/Gen/HsType.hs:556:56: Note [Skolem escape prevention] -ref compiler/GHC/Tc/Gen/HsType.hs:2621:7: Note [Matching a kind signature with a declaration] -ref compiler/GHC/Tc/Gen/Pat.hs:176:20: Note [Typing patterns in pattern bindings] -ref compiler/GHC/Tc/Gen/Pat.hs:1127:7: Note [Matching polytyped patterns] -ref compiler/GHC/Tc/Gen/Sig.hs:81:10: Note [Overview of type signatures] -ref compiler/GHC/Tc/Gen/Splice.hs:356:16: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:531:35: Note [PendingRnSplice] -ref compiler/GHC/Tc/Gen/Splice.hs:655:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:888:11: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Instance/Family.hs:474:35: Note [Constrained family instances] -ref compiler/GHC/Tc/Solver/Rewrite.hs:1009:7: Note [Stability of rewriting] -ref compiler/GHC/Tc/TyCl.hs:1130:6: Note [Unification variables need fresh Names] -ref compiler/GHC/Tc/Types/Constraint.hs:226:34: Note [NonCanonical Semantics] -ref compiler/GHC/Types/Demand.hs:302:25: Note [Preserving Boxity of results is rarely a win] -ref compiler/GHC/Unit/Module/Deps.hs:81:13: Note [Structure of dep_boot_mods] +ref compiler/GHC/Tc/Gen/HsType.hs:2676:7: Note [Matching a kind signature with a declaration] +ref compiler/GHC/Tc/Gen/Pat.hs:174:20: Note [Typing patterns in pattern bindings] +ref compiler/GHC/Tc/Gen/Pat.hs:1163:7: Note [Matching polytyped patterns] +ref compiler/GHC/Tc/Gen/Sig.hs:80:10: Note [Overview of type signatures] +ref compiler/GHC/Tc/Gen/Splice.hs:358:16: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:533:35: Note [PendingRnSplice] +ref compiler/GHC/Tc/Gen/Splice.hs:657:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:891:11: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Instance/Family.hs:406:35: Note [Constrained family instances] +ref compiler/GHC/Tc/Solver/Rewrite.hs:1010:7: Note [Stability of rewriting] +ref compiler/GHC/Tc/TyCl.hs:1316:6: Note [Unification variables need fresh Names] +ref compiler/GHC/Tc/Types/Constraint.hs:206:38: Note [NonCanonical Semantics] +ref compiler/GHC/Types/Demand.hs:301:25: Note [Preserving Boxity of results is rarely a win] +ref compiler/GHC/Unit/Module/Deps.hs:83:13: Note [Structure of dep_boot_mods] ref compiler/GHC/Utils/Monad.hs:410:34: Note [multiShotIO] ref compiler/Language/Haskell/Syntax/Binds.hs:200:31: Note [fun_id in Match] -ref configure.ac:210:10: Note [Linking ghc-bin against threaded stage0 RTS] +ref configure.ac:203: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:145:30: Note [Linking ghc-bin against threaded stage0 RTS] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ===================================== testsuite/tests/simplCore/should_compile/T22375.hs ===================================== @@ -1,12 +1,19 @@ module T22375 where -data X = A | B | C | D | E +data X + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 76, types: 41, coercions: 0, joins: 0/0} + = {terms: 96, types: 41, coercions: 0, joins: 0/0} -- RHS size: {terms: 14, types: 9, coercions: 0, joins: 0/0} T22375.$fEqX_$c== :: X -> X -> Bool @@ -50,22 +50,27 @@ T22375.$fEqX [InlPrag=CONLIKE] :: Eq X T22375.$fEqX = GHC.Classes.C:Eq @X T22375.$fEqX_$c== T22375.$fEqX_$c/= --- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0} +-- RHS size: {terms: 44, types: 3, coercions: 0, joins: 0/0} T22375.$wf [InlPrag=[2]] :: X -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375.$wf = \ (x :: X) (ww :: GHC.Prim.Int#) -> case x of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 5, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.hs ===================================== @@ -6,13 +6,20 @@ import Data.Kind type X :: Type -> Type data family X a -data instance X () = A | B | C | D | E +data instance X () + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X () -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 86, types: 65, coercions: 15, joins: 0/0} + = {terms: 116, types: 75, coercions: 25, joins: 0/0} -- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} T22375DataFamily.$WA [InlPrag=INLINE[final] CONLIKE] :: X () @@ -58,6 +58,61 @@ T22375DataFamily.$WE `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) :: T22375DataFamily.R:XUnit ~R# X ()) +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WF [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WF + = T22375DataFamily.F + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WG [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WG + = T22375DataFamily.G + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WH [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WH + = T22375DataFamily.H + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WI [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WI + = T22375DataFamily.I + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WJ [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WJ + = T22375DataFamily.J + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + -- RHS size: {terms: 14, types: 11, coercions: 2, joins: 0/0} T22375DataFamily.$fEqX_$c== :: X () -> X () -> Bool [GblId, @@ -133,7 +188,7 @@ T22375DataFamily.$fEqX = GHC.Classes.C:Eq @(X ()) T22375DataFamily.$fEqX_$c== T22375DataFamily.$fEqX_$c/= --- RHS size: {terms: 24, types: 4, coercions: 1, joins: 0/0} +-- RHS size: {terms: 44, types: 4, coercions: 1, joins: 0/0} T22375DataFamily.$wf [InlPrag=[2]] :: X () -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], @@ -141,18 +196,23 @@ T22375DataFamily.$wf [InlPrag=[2]] Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375DataFamily.$wf = \ (x :: X ()) (ww :: GHC.Prim.Int#) -> case x `cast` (T22375DataFamily.D:R:XUnit0[0] :: X () ~R# T22375DataFamily.R:XUnit) of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 6, coercions: 0, joins: 0/0} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1728dbb40eb68e71a4fb26e08136d164fdaa1ea1...9e32482383b73f7fcc854c8e171f788f1f106a92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1728dbb40eb68e71a4fb26e08136d164fdaa1ea1...9e32482383b73f7fcc854c8e171f788f1f106a92 You're receiving 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 Nov 21 01:29:04 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Mon, 20 Nov 2023 20:29:04 -0500 Subject: [Git][ghc/ghc][wip/DataToTagSmallOp] 2 commits: Introduce `dataToTagSmall#` primop (closes #21710) Message-ID: <655c07e079dc0_14c49b69470b5837858@gitlab.mail> Matthew Craven pushed to branch wip/DataToTagSmallOp at Glasgow Haskell Compiler / GHC Commits: 7021c387 by Matthew Craven at 2023-11-20T20:28:30-05:00 Introduce `dataToTagSmall#` primop (closes #21710) ...and use it to generate slightly better code when dataToTag# is used at a "small data type" where there is no need to mess with "is_too_big_tag" or potentially look at an info table. Metric Decrease: T18304 - - - - - e80d1ee9 by Matthew Craven at 2023-11-20T20:28:38-05:00 Fix formatting of Note [alg-alt heap check] - - - - - 17 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Tc/Instance/Class.hs - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs - testsuite/tests/codeGen/should_compile/T21710a.stderr - testsuite/tests/linters/notes.stdout - testsuite/tests/simplCore/should_compile/T22375.hs - testsuite/tests/simplCore/should_compile/T22375.stderr - testsuite/tests/simplCore/should_compile/T22375DataFamily.hs - testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr Changes: ===================================== compiler/GHC/Builtin/PrimOps.hs ===================================== @@ -921,5 +921,6 @@ instance Outputable PrimCall where primOpIsReallyInline :: PrimOp -> Bool primOpIsReallyInline = \case SeqOp -> False - DataToTagOp -> False + DataToTagSmallOp -> False + DataToTagLargeOp -> False p -> not (primOpOutOfLine p) ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3689,7 +3689,27 @@ section "Tag to enum stuff" and small integers.} ------------------------------------------------------------------------ -primop DataToTagOp "dataToTagLarge#" GenPrimOp +primop DataToTagSmallOp "dataToTagSmall#" GenPrimOp + a_levpoly -> Int# + { Used internally to implement @dataToTag#@: Use that function instead! + This one offers /no advantage/ and comes with no stability + guarantees: it may change its type, its name, or its behavior + with /no warning/ between compiler releases. + + It is expected that this function will be un-exposed in a future + release of ghc. + + For more details, look at @Note [DataToTag overview]@ + in GHC.Tc.Instance.Class in the source code for + /the specific compiler version you are using./ + } + with + deprecated_msg = { Use dataToTag# from \"GHC.Magic\" instead. } + strictness = { \ _arity -> mkClosedDmdSig [evalDmd] topDiv } + effect = ThrowsException + cheap = True + +primop DataToTagLargeOp "dataToTagLarge#" GenPrimOp a_levpoly -> Int# { Used internally to implement @dataToTag#@: Use that function instead! This one offers /no advantage/ and comes with no stability ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1142,7 +1142,8 @@ checkDataToTagPrimOpTyCon -> [CoreArg] -- ^ The arguments to the application -> LintM () checkDataToTagPrimOpTyCon (Var fun_id) args - | Just DataToTagOp <- isPrimOpId_maybe fun_id + | Just op <- isPrimOpId_maybe fun_id + , op == DataToTagSmallOp || op == DataToTagLargeOp = case args of Type _levity : Type dty : _rest | Just (tc, _) <- splitTyConApp_maybe dty ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -102,7 +102,8 @@ That is why these rules are built in here. primOpRules :: Name -> PrimOp -> Maybe CoreRule primOpRules nm = \case TagToEnumOp -> mkPrimOpRule nm 2 [ tagToEnumRule ] - DataToTagOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagSmallOp -> mkPrimOpRule nm 3 [ dataToTagRule ] + DataToTagLargeOp -> mkPrimOpRule nm 3 [ dataToTagRule ] -- Int8 operations Int8AddOp -> mkPrimOpRule nm 2 [ binaryLit (int8Op2 (+)) @@ -3374,7 +3375,8 @@ caseRules platform (App (App (Var f) type_arg) v) -- See Note [caseRules for dataToTag] caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x - | Just DataToTagOp <- isPrimOpId_maybe f + | Just op <- isPrimOpId_maybe f + , op == DataToTagSmallOp || op == DataToTagLargeOp = case splitTyConApp_maybe ty of Just (tc, _) | isValidDTT2TyCon tc -> Just (v, tx_con_dtt tc @@ -3382,9 +3384,9 @@ caseRules _ (Var f `App` Type lev `App` Type ty `App` v) -- dataToTag x _ -> pprTraceUserWarning warnMsg Nothing where warnMsg = vcat $ map text - [ "Found dataToTag primop applied to a non-ADT type. This" - , "could be a future bug in GHC, or it may be caused by an" - , "unsupported use of the ghc-internal primop dataToTagLarge#." + [ "Found dataToTag primop applied to a non-ADT type. This could" + , "be a future bug in GHC, or it may be caused by an unsupported" + , "use of the ghc-internal primops dataToTagSmall# and dataToTagLarge#." , "In either case, the GHC developers would like to know about it!" , "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug" ] ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -495,10 +495,9 @@ occurrence of `x` and `y` to record whether it is evaluated and properly tagged. For the vast majority of primops that's a waste of time: the argument is an `Int#` or something. -But code generation for `seq#` and `dataToTagLarge#` /does/ consult that -tag, to statically avoid generating an eval: -* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig` -* `dataToTagLarge#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`. +But code generation for `seq#` and the `dataToTag#` ops /does/ consult that +tag, to statically avoid generating an eval. All three do so via `cgIdApp`, +which in turn uses `getCallMethod` which looks at the `tagSig`. So for these we should call `rewriteArgs`. @@ -507,7 +506,7 @@ So for these we should call `rewriteArgs`. rewriteOpApp :: InferStgExpr -> RM TgStgExpr rewriteOpApp (StgOpApp op args res_ty) = case op of op@(StgPrimOp primOp) - | primOp == SeqOp || primOp == DataToTagOp + | primOp == SeqOp || primOp == DataToTagSmallOp || primOp == DataToTagLargeOp -- see Note [Rewriting primop arguments] -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty _ -> pure $! StgOpApp op args res_ty ===================================== compiler/GHC/StgToCmm/Expr.hs ===================================== @@ -37,7 +37,7 @@ import GHC.Cmm.Graph import GHC.Cmm.BlockId import GHC.Cmm hiding ( succ ) import GHC.Cmm.Info -import GHC.Cmm.Utils ( zeroExpr, cmmTagMask, mkWordCLit, mAX_PTR_TAG ) +import GHC.Cmm.Utils ( cmmTagMask, mkWordCLit, mAX_PTR_TAG ) import GHC.Core import GHC.Core.DataCon import GHC.Types.ForeignCall @@ -73,55 +73,49 @@ cgExpr (StgApp fun args) = cgIdApp fun args cgExpr (StgOpApp (StgPrimOp SeqOp) [StgVarArg a, _] _res_ty) = cgIdApp a [] +-- dataToTagSmall# :: a_levpoly -> Int# +-- See Note [DataToTag overview] in GHC.Tc.Instance.Class +cgExpr (StgOpApp (StgPrimOp DataToTagSmallOp) [StgVarArg a] _res_ty) = do + platform <- getPlatform + emitComment (mkFastString "dataToTagSmall#") + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + tag1 = cmmConstrTag1 platform a_eval_expr + + -- subtract 1 because we need to return a zero-indexed tag + emitReturn [cmmSubWord platform tag1 (CmmLit $ mkWordCLit platform 1)] + -- dataToTagLarge# :: a_levpoly -> Int# -- See Note [DataToTag overview] in GHC.Tc.Instance.Class --- TODO: There are some more optimization ideas for this code path --- in #21710 -cgExpr (StgOpApp (StgPrimOp DataToTagOp) [StgVarArg a] _res_ty) = do +cgExpr (StgOpApp (StgPrimOp DataToTagLargeOp) [StgVarArg a] _res_ty) = do platform <- getPlatform emitComment (mkFastString "dataToTagLarge#") - info <- getCgIdInfo a - let amode = idInfoToAmode info - tag_reg <- assignTemp $ cmmConstrTag1 platform amode + + a_eval_reg <- newTemp (bWord platform) + _ <- withSequel (AssignTo [a_eval_reg] False) (cgIdApp a []) + let a_eval_expr = CmmReg (CmmLocal a_eval_reg) + + tag1_reg <- assignTemp $ cmmConstrTag1 platform a_eval_expr result_reg <- newTemp (bWord platform) - let tag = CmmReg $ CmmLocal tag_reg - is_tagged = cmmNeWord platform tag (zeroExpr platform) - is_too_big_tag = cmmEqWord platform tag (cmmTagMask platform) - -- Here we will first check the tag bits of the pointer we were given; - -- if this doesn't work then enter the closure and use the info table - -- to determine the constructor. Note that all tag bits set means that - -- the constructor index is too large to fit in the pointer and therefore - -- we must look in the info table. See Note [Tagging big families]. - - (fast_path :: CmmAGraph) <- getCode $ do - -- Return the constructor index from the pointer tag - return_ptr_tag <- getCode $ do - emitAssign (CmmLocal result_reg) - $ cmmSubWord platform tag (CmmLit $ mkWordCLit platform 1) - -- Return the constructor index recorded in the info table - return_info_tag <- getCode $ do - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform amode) - - emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) - -- If we know the argument is already tagged there is no need to generate code to evaluate it - -- so we skip straight to the fast path. If we don't know if there is a tag we take the slow - -- path which evaluates the argument before fetching the tag. - case (idTagSig_maybe a) of - Just sig - | isTaggedSig sig - -> emit fast_path - _ -> do - slow_path <- getCode $ do - tmp <- newTemp (bWord platform) - _ <- withSequel (AssignTo [tmp] False) (cgIdApp a []) - profile <- getProfile - align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig - emitAssign (CmmLocal result_reg) - $ getConstrTag profile align_check (cmmUntag platform (CmmReg (CmmLocal tmp))) - emit =<< mkCmmIfThenElse' is_tagged fast_path slow_path (Just True) + let tag1_expr = CmmReg $ CmmLocal tag1_reg + is_too_big_tag = cmmEqWord platform tag1_expr (cmmTagMask platform) + + -- Return the constructor index from the pointer tag + -- (Used if pointer tag is small enough to be unambiguous) + return_ptr_tag <- getCode $ do + emitAssign (CmmLocal result_reg) + $ cmmSubWord platform tag1_expr (CmmLit $ mkWordCLit platform 1) + + -- Return the constructor index recorded in the info table + return_info_tag <- getCode $ do + profile <- getProfile + align_check <- stgToCmmAlignCheck <$> getStgToCmmConfig + emitAssign (CmmLocal result_reg) + $ getConstrTag profile align_check (cmmUntag platform a_eval_expr) + + emit =<< mkCmmIfThenElse' is_too_big_tag return_info_tag return_ptr_tag (Just False) emitReturn [CmmReg $ CmmLocal result_reg] @@ -638,9 +632,10 @@ isSimpleScrut _ _ = return False isSimpleOp :: StgOp -> [StgArg] -> FCode Bool -- True iff the op cannot block or allocate isSimpleOp (StgFCallOp (CCall (CCallSpec _ _ safe)) _) _ = return $! not (playSafe safe) --- dataToTagLarge# evaluates its argument; +-- dataToTagSmall#/dataToTagLarge# evaluate an argument; -- see Note [DataToTag overview] in GHC.Tc.Instance.Class -isSimpleOp (StgPrimOp DataToTagOp) _ = return False +isSimpleOp (StgPrimOp DataToTagSmallOp) _ = return False +isSimpleOp (StgPrimOp DataToTagLargeOp) _ = return False isSimpleOp (StgPrimOp op) stg_args = do arg_exprs <- getNonVoidArgAmodes stg_args cfg <- getStgToCmmConfig @@ -851,6 +846,7 @@ cgAlts _ _ _ _ = panic "cgAlts" -- Note [alg-alt heap check] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- In an algebraic case with more than one alternative, we will have -- code like ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1640,7 +1640,8 @@ emitPrimOp cfg primop = SeqOp -> alwaysExternal GetSparkOp -> alwaysExternal NumSparks -> alwaysExternal - DataToTagOp -> alwaysExternal + DataToTagSmallOp -> alwaysExternal + DataToTagLargeOp -> alwaysExternal MkApUpd0_Op -> alwaysExternal NewBCOOp -> alwaysExternal UnpackClosureOp -> alwaysExternal ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -967,7 +967,11 @@ genPrim prof bound ty op = case op of ------------------------------ Tag to enum stuff -------------------------------- - DataToTagOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + DataToTagSmallOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat + [ stack .! PreInc sp |= var "h$dataToTag_e" + , returnS (app "h$e" [d]) + ] + DataToTagLargeOp -> \[_r] [d] -> pure $ PRPrimCall $ mconcat [ stack .! PreInc sp |= var "h$dataToTag_e" , returnS (app "h$e" [d]) ] ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -50,6 +50,8 @@ import GHC.Core.Class import GHC.Core ( Expr(..) ) +import GHC.StgToCmm.Closure ( isSmallFamily ) + import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc( splitAtList, fstOf3 ) @@ -671,15 +673,17 @@ But, to avoid all this boilerplate code, and improve optimisation opportunities, GHC generates instances like this: instance DataToTag [a] where - dataToTag# = dataToTagLarge# + dataToTag# = dataToTagSmall# -using a (temporarily strangely-named) primop `dataToTagLarge#`. The -primop has the following over-polymorphic type +using one of two dedicated primops: `dataToTagSmall#` and `dataToTagLarge#`. +(These two primops differ only in code generation; see wrinkle DTW4 below.) +Both primops have the following over-polymorphic type: dataToTagLarge# :: forall {l::levity} (a::TYPE (BoxedRep l)). a -> Int# -Every call to (dataToTagLarge# @{lev} @ty) that we generate should -satisfy these conditions: +Every call to either primop that we generate should look like +(dataToTagSmall# @{lev} @ty) with two type arguments that satisfy +these conditions: (DTT1) `lev` is concrete (either lifted or unlifted), not polymorphic. This is an invariant--we must satisfy this or Core Lint will complain. @@ -698,21 +702,21 @@ satisfy these conditions: GHC.Rename.Module. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold for why this matters. - While the dataToTagLarge# primop remains exposed from GHC.Prim + While the dataToTag# primops remain exposed from GHC.Prim (and abused in GHC.PrimopWrappers), this cannot be a true invariant. - But with a little effort we can ensure that every `dataToTagLarge#` + But with a little effort we can ensure that every primop call we generate in a DataToTag instance satisfies this condition. -The `dataToTagLarge#` primop has special handling in several parts of +These two primops have special handling in several parts of the compiler: -- It has a couple of built-in rewrite rules, implemented in +- They have a couple of built-in rewrite rules, implemented in GHC.Core.Opt.ConstantFold.dataToTagRule -- The simplifier rewrites most case expressions scrutinizing its result. +- The simplifier rewrites most case expressions scrutinizing their result. See Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold. -- It evaluates its argument; this is implemented via a special case in +- Each evaluates its argument; this is implemented via special cases in GHC.StgToCmm.Expr.cgExpr. - Additionally, a special case in GHC.Stg.InferTags.Rewrite.rewriteExpr ensures @@ -727,12 +731,12 @@ Wrinkles: [W] DataToTag (D (Either t1 t2)) GHC uses the built-in instance instance DataToTag (D (Either p q)) where - dataToTag# x = dataToTagLarge# @Lifted @(R:DEither p q) + dataToTag# x = dataToTagSmall# @Lifted @(R:DEither p q) (x |> sym (ax:DEither p q)) where `ax:DEither` is the axiom arising from the `data instance`: ax:DEither p q :: D (Either p q) ~ R:DEither p q - Notice that we cast `x` before giving it to `dataToTagLarge#`, so + Notice that we cast `x` before giving it to `dataToTagSmall#`, so that (DTT2) is satisfied. (DTW2) Suppose we have module A (T(..)) where { data T = TCon } @@ -747,7 +751,7 @@ Wrinkles: (DTW3) Similar to DTW2, consider this example: {-# LANGUAGE MagicHash #-} - module A (X(X2, X3), f) where + module A (X(X2, X3), g) where -- see also testsuite/tests/warnings/should_compile/DataToTagWarnings.hs import GHC.Exts (dataToTag#, Int#) data X = X1 | X2 | X3 | X4 @@ -774,10 +778,18 @@ Wrinkles: keepAlive on the constructor names. (Contrast with Note [Unused name reporting and HasField].) -(DTW4) It is expected that in the future some instances may select more - efficient specialised implementations; for example we may use a - separate `dataToTagSmall#` primop for a type with only a few - constructors; see #17079 and #21710. +(DTW4) The way tag information is stored at runtime is described in + Note [Tagging big families] in GHC.StgToCmm.Expr. In particular, + for "big data types" we must consult the heap object's info table at + least in the MAX_PTR_TAG case, while for "small data types" we can + always just examine the tag bits on the pointer itself. + + Although it is always correct to consult the info table, we can + produce slightly smaller and faster code by not doing so for "small + data types." Since types and coercions are largely erased in STG, + the simplest reliable way to achieve this is to produce different + primops in DataToTag instances depending on the number of data + constructors the relevant TyCon has. (DTW5) We make no promises about the primops used to implement DataToTag instances. Changes to GHC's representation of algebraic @@ -816,6 +828,7 @@ matchDataToTag :: Class -> [Type] -> TcM ClsInstResult matchDataToTag dataToTagClass [levity, dty] = do famEnvs <- tcGetFamInstEnvs (gbl_env, _lcl_env) <- getEnvs + platform <- getPlatform if | isConcreteType levity -- condition C3 , Just (rawTyCon, rawTyConArgs) <- tcSplitTyConApp_maybe dty , let (repTyCon, repArgs, repCo) @@ -828,13 +841,14 @@ matchDataToTag dataToTagClass [levity, dty] = do , let rdr_env = tcg_rdr_env gbl_env inScope con = isJust $ lookupGRE_Name rdr_env $ dataConName con , all inScope constrs -- condition C2 + , let repTy = mkTyConApp repTyCon repArgs - whichOp - -- TODO: More optimized implementations for: - -- * small constructor families - -- * Bool/Int/Float/etc. on JS backend + numConstrs = tyConFamilySize repTyCon + !whichOp -- see wrinkle DTW4 + | isSmallFamily platform numConstrs + = primOpId DataToTagSmallOp | otherwise - = primOpId DataToTagOp + = primOpId DataToTagLargeOp -- See wrinkle DTW1; we must apply the underlying -- operation at the representation type and cast it ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,8 +117,8 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim hiding (dataToTagLarge#) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding (dataToTagSmall#, dataToTagLarge#) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -133,8 +133,8 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce, dataToTagLarge# ) - -- Hide dataToTagLarge# because it is expected to break for +import GHC.Prim hiding ( coerce, dataToTagSmall#, dataToTagLarge# ) + -- Hide dataToTag# ops because they are expected to break for -- GHC-internal reasons in the near future, and shouldn't -- be exposed from base (not even GHC.Exts) ===================================== testsuite/tests/codeGen/should_compile/T21710a.stderr ===================================== @@ -1,117 +1,44 @@ -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'E2_bytes" { - M.$tc'E2_bytes: - I8[] "'E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'D2_bytes" { - M.$tc'D2_bytes: - I8[] "'D" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'C2_bytes" { - M.$tc'C2_bytes: - I8[] "'C" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'B2_bytes" { - M.$tc'B2_bytes: - I8[] "'B" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tc'A3_bytes" { - M.$tc'A3_bytes: - I8[] "'A" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$tcE2_bytes" { - M.$tcE2_bytes: - I8[] "E" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule2_bytes" { - M.$trModule2_bytes: - I8[] "M" - }] - - - -==================== Output Cmm ==================== -[section ""cstring" . M.$trModule4_bytes" { - M.$trModule4_bytes: - I8[] "main" - }] - - - ==================== Output Cmm ==================== [M.foo_entry() { // [R2] - { info_tbls: [(cBa, - label: block_cBa_info + { info_tbls: [(cCU, + label: block_cCU_info rep: StackRep [] srt: Nothing), - (cBi, + (cD2, label: M.foo_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cBi: // global - if ((Sp + -8) < SpLim) (likely: False) goto cBj; else goto cBk; // CmmCondBranch - cBj: // global + cD2: // global + if ((Sp + -8) < SpLim) (likely: False) goto cD3; else goto cD4; // CmmCondBranch + cD3: // global R1 = M.foo_closure; // CmmAssign call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall - cBk: // global - I64[Sp - 8] = cBa; // CmmStore + cD4: // global + I64[Sp - 8] = cCU; // CmmStore R1 = R2; // CmmAssign Sp = Sp - 8; // CmmAssign - if (R1 & 7 != 0) goto cBa; else goto cBb; // CmmCondBranch - cBb: // global - call (I64[R1])(R1) returns to cBa, args: 8, res: 8, upd: 8; // CmmCall - cBa: // global - _cBh::P64 = R1 & 7; // CmmAssign - if (_cBh::P64 != 1) goto uBz; else goto cBf; // CmmCondBranch - uBz: // global - if (_cBh::P64 != 2) goto cBe; else goto cBg; // CmmCondBranch - cBe: // global - // dataToTag# - _cBn::P64 = R1 & 7; // CmmAssign - if (_cBn::P64 == 7) (likely: False) goto cBs; else goto cBr; // CmmCondBranch - cBs: // global - _cBo::I64 = %MO_UU_Conv_W32_W64(I32[I64[R1 & (-8)] - 4]); // CmmAssign - goto cBq; // CmmBranch - cBr: // global - _cBo::I64 = _cBn::P64 - 1; // CmmAssign - goto cBq; // CmmBranch - cBq: // global - R1 = _cBo::I64; // CmmAssign + if (R1 & 7 != 0) goto cCU; else goto cCV; // CmmCondBranch + cCV: // global + call (I64[R1])(R1) returns to cCU, args: 8, res: 8, upd: 8; // CmmCall + cCU: // global + _cD1::P64 = R1 & 7; // CmmAssign + if (_cD1::P64 != 1) goto uDf; else goto cCZ; // CmmCondBranch + uDf: // global + if (_cD1::P64 != 2) goto cCY; else goto cD0; // CmmCondBranch + cCY: // global + // dataToTagSmall# + R1 = R1 & 7 - 1; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBg: // global + cD0: // global R1 = 42; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall - cBf: // global + cCZ: // global R1 = 2; // CmmAssign Sp = Sp + 8; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall @@ -124,190 +51,6 @@ -==================== Output Cmm ==================== -[section ""data" . M.$trModule3_closure" { - M.$trModule3_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule4_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule1_closure" { - M.$trModule1_closure: - const GHC.Types.TrNameS_con_info; - const M.$trModule2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$trModule_closure" { - M.$trModule_closure: - const GHC.Types.Module_con_info; - const M.$trModule3_closure+1; - const M.$trModule1_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE1_closure" { - M.$tcE1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tcE2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tcE_closure" { - M.$tcE_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tcE1_closure+1; - const GHC.Types.krep$*_closure+5; - const 10475418246443540865; - const 12461417314693222409; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A1_closure" { - M.$tc'A1_closure: - const GHC.Types.KindRepTyConApp_con_info; - const M.$tcE_closure+1; - const GHC.Types.[]_closure+1; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A2_closure" { - M.$tc'A2_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'A3_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'A_closure" { - M.$tc'A_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'A2_closure+1; - const M.$tc'A1_closure+1; - const 10991425535368257265; - const 3459663971500179679; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B1_closure" { - M.$tc'B1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'B2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'B_closure" { - M.$tc'B_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'B1_closure+1; - const M.$tc'A1_closure+1; - const 13038863156169552918; - const 13430333535161531545; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C1_closure" { - M.$tc'C1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'C2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'C_closure" { - M.$tc'C_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'C1_closure+1; - const M.$tc'A1_closure+1; - const 8482817676735632621; - const 8146597712321241387; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D1_closure" { - M.$tc'D1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'D2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'D_closure" { - M.$tc'D_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'D1_closure+1; - const M.$tc'A1_closure+1; - const 7525207739284160575; - const 13746130127476219356; - const 0; - const 3; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E1_closure" { - M.$tc'E1_closure: - const GHC.Types.TrNameS_con_info; - const M.$tc'E2_bytes; - }] - - - -==================== Output Cmm ==================== -[section ""data" . M.$tc'E_closure" { - M.$tc'E_closure: - const GHC.Types.TyCon_con_info; - const M.$trModule_closure+1; - const M.$tc'E1_closure+1; - const M.$tc'A1_closure+1; - const 6748545530683684316; - const 10193016702094081137; - const 0; - const 3; - }] - - - ==================== Output Cmm ==================== [section ""data" . M.A_closure" { M.A_closure: @@ -362,14 +105,14 @@ ==================== Output Cmm ==================== [M.A_con_entry() { // [] - { info_tbls: [(cC5, + { info_tbls: [(cDt, label: M.A_con_info rep: HeapRep 1 nonptrs { Con {tag: 0 descr:"main:M.A"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cC5: // global + cDt: // global R1 = R1 + 1; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -379,14 +122,14 @@ ==================== Output Cmm ==================== [M.B_con_entry() { // [] - { info_tbls: [(cCa, + { info_tbls: [(cDy, label: M.B_con_info rep: HeapRep 1 nonptrs { Con {tag: 1 descr:"main:M.B"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCa: // global + cDy: // global R1 = R1 + 2; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -396,14 +139,14 @@ ==================== Output Cmm ==================== [M.C_con_entry() { // [] - { info_tbls: [(cCf, + { info_tbls: [(cDD, label: M.C_con_info rep: HeapRep 1 nonptrs { Con {tag: 2 descr:"main:M.C"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCf: // global + cDD: // global R1 = R1 + 3; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -413,14 +156,14 @@ ==================== Output Cmm ==================== [M.D_con_entry() { // [] - { info_tbls: [(cCk, + { info_tbls: [(cDI, label: M.D_con_info rep: HeapRep 1 nonptrs { Con {tag: 3 descr:"main:M.D"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCk: // global + cDI: // global R1 = R1 + 4; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } @@ -430,14 +173,14 @@ ==================== Output Cmm ==================== [M.E_con_entry() { // [] - { info_tbls: [(cCp, + { info_tbls: [(cDN, label: M.E_con_info rep: HeapRep 1 nonptrs { Con {tag: 4 descr:"main:M.E"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cCp: // global + cDN: // global R1 = R1 + 5; // CmmAssign call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall } ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,41 +1,40 @@ -ref compiler/GHC/Core/Coercion/Axiom.hs:463:2: Note [RoughMap and rm_empty] -ref compiler/GHC/Core/Opt/OccurAnal.hs:983:7: Note [Loop breaking] -ref compiler/GHC/Core/Opt/SetLevels.hs:1574:30: Note [Top level scope] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2826:13: Note [Case binder next] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4018:8: Note [Lambda-bound unfoldings] -ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1343:37: Note [Gentle mode] -ref compiler/GHC/Core/Opt/Specialise.hs:1765:29: Note [Arity decrease] -ref compiler/GHC/Core/TyCo/Rep.hs:1565:31: Note [What prevents a constraint from floating] -ref compiler/GHC/Driver/DynFlags.hs:1245:49: Note [Eta-reduction in -O0] -ref compiler/GHC/Driver/Main.hs:1762:34: Note [simpleTidyPgm - mkBootModDetailsTc] -ref compiler/GHC/Hs/Expr.hs:194:63: Note [Pending Splices] -ref compiler/GHC/Hs/Expr.hs:1738:87: Note [Lifecycle of a splice] -ref compiler/GHC/Hs/Expr.hs:1774:7: Note [Pending Splices] -ref compiler/GHC/Hs/Extension.hs:146:5: Note [Strict argument type constraints] -ref compiler/GHC/Hs/Pat.hs:143:74: Note [Lifecycle of a splice] -ref compiler/GHC/HsToCore/Pmc/Solver.hs:858:20: Note [COMPLETE sets on data families] -ref compiler/GHC/HsToCore/Quote.hs:1476:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Stg/Unarise.hs:442:32: Note [Renaming during unarisation] -ref compiler/GHC/StgToCmm/Expr.hs:585:4: Note [case on bool] -ref compiler/GHC/StgToCmm/Expr.hs:853:3: Note [alg-alt heap check] +ref compiler/GHC/Core/Coercion/Axiom.hs:472:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/OccurAnal.hs:1157:7: Note [Loop breaking] +ref compiler/GHC/Core/Opt/SetLevels.hs:1586:30: Note [Top level scope] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2832:13: Note [Case binder next] +ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:4023:8: Note [Lambda-bound unfoldings] +ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1342:37: Note [Gentle mode] +ref compiler/GHC/Core/Opt/Specialise.hs:1763:29: Note [Arity decrease] +ref compiler/GHC/Core/TyCo/Rep.hs:1652:31: Note [What prevents a constraint from floating] +ref compiler/GHC/Driver/DynFlags.hs:1251:52: Note [Eta-reduction in -O0] +ref compiler/GHC/Driver/Main.hs:1749:34: Note [simpleTidyPgm - mkBootModDetailsTc] +ref compiler/GHC/Hs/Expr.hs:191:63: Note [Pending Splices] +ref compiler/GHC/Hs/Expr.hs:1727:87: Note [Lifecycle of a splice] +ref compiler/GHC/Hs/Expr.hs:1763:7: Note [Pending Splices] +ref compiler/GHC/Hs/Extension.hs:147:5: Note [Strict argument type constraints] +ref compiler/GHC/Hs/Pat.hs:141:74: Note [Lifecycle of a splice] +ref compiler/GHC/HsToCore/Pmc/Solver.hs:856:20: Note [COMPLETE sets on data families] +ref compiler/GHC/HsToCore/Quote.hs:1487:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Stg/Unarise.hs:438:32: Note [Renaming during unarisation] +ref compiler/GHC/StgToCmm/Expr.hs:578:4: Note [case on bool] ref compiler/GHC/Tc/Gen/HsType.hs:556:56: Note [Skolem escape prevention] -ref compiler/GHC/Tc/Gen/HsType.hs:2621:7: Note [Matching a kind signature with a declaration] -ref compiler/GHC/Tc/Gen/Pat.hs:176:20: Note [Typing patterns in pattern bindings] -ref compiler/GHC/Tc/Gen/Pat.hs:1127:7: Note [Matching polytyped patterns] -ref compiler/GHC/Tc/Gen/Sig.hs:81:10: Note [Overview of type signatures] -ref compiler/GHC/Tc/Gen/Splice.hs:356:16: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:531:35: Note [PendingRnSplice] -ref compiler/GHC/Tc/Gen/Splice.hs:655:7: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Gen/Splice.hs:888:11: Note [How brackets and nested splices are handled] -ref compiler/GHC/Tc/Instance/Family.hs:474:35: Note [Constrained family instances] -ref compiler/GHC/Tc/Solver/Rewrite.hs:1009:7: Note [Stability of rewriting] -ref compiler/GHC/Tc/TyCl.hs:1130:6: Note [Unification variables need fresh Names] -ref compiler/GHC/Tc/Types/Constraint.hs:226:34: Note [NonCanonical Semantics] -ref compiler/GHC/Types/Demand.hs:302:25: Note [Preserving Boxity of results is rarely a win] -ref compiler/GHC/Unit/Module/Deps.hs:81:13: Note [Structure of dep_boot_mods] +ref compiler/GHC/Tc/Gen/HsType.hs:2676:7: Note [Matching a kind signature with a declaration] +ref compiler/GHC/Tc/Gen/Pat.hs:174:20: Note [Typing patterns in pattern bindings] +ref compiler/GHC/Tc/Gen/Pat.hs:1163:7: Note [Matching polytyped patterns] +ref compiler/GHC/Tc/Gen/Sig.hs:80:10: Note [Overview of type signatures] +ref compiler/GHC/Tc/Gen/Splice.hs:358:16: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:533:35: Note [PendingRnSplice] +ref compiler/GHC/Tc/Gen/Splice.hs:657:7: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Gen/Splice.hs:891:11: Note [How brackets and nested splices are handled] +ref compiler/GHC/Tc/Instance/Family.hs:406:35: Note [Constrained family instances] +ref compiler/GHC/Tc/Solver/Rewrite.hs:1010:7: Note [Stability of rewriting] +ref compiler/GHC/Tc/TyCl.hs:1316:6: Note [Unification variables need fresh Names] +ref compiler/GHC/Tc/Types/Constraint.hs:206:38: Note [NonCanonical Semantics] +ref compiler/GHC/Types/Demand.hs:301:25: Note [Preserving Boxity of results is rarely a win] +ref compiler/GHC/Unit/Module/Deps.hs:83:13: Note [Structure of dep_boot_mods] ref compiler/GHC/Utils/Monad.hs:410:34: Note [multiShotIO] ref compiler/Language/Haskell/Syntax/Binds.hs:200:31: Note [fun_id in Match] -ref configure.ac:210:10: Note [Linking ghc-bin against threaded stage0 RTS] +ref configure.ac:203: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:145:30: Note [Linking ghc-bin against threaded stage0 RTS] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ===================================== testsuite/tests/simplCore/should_compile/T22375.hs ===================================== @@ -1,12 +1,19 @@ module T22375 where -data X = A | B | C | D | E +data X + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 76, types: 41, coercions: 0, joins: 0/0} + = {terms: 96, types: 41, coercions: 0, joins: 0/0} -- RHS size: {terms: 14, types: 9, coercions: 0, joins: 0/0} T22375.$fEqX_$c== :: X -> X -> Bool @@ -50,22 +50,27 @@ T22375.$fEqX [InlPrag=CONLIKE] :: Eq X T22375.$fEqX = GHC.Classes.C:Eq @X T22375.$fEqX_$c== T22375.$fEqX_$c/= --- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0} +-- RHS size: {terms: 44, types: 3, coercions: 0, joins: 0/0} T22375.$wf [InlPrag=[2]] :: X -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375.$wf = \ (x :: X) (ww :: GHC.Prim.Int#) -> case x of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 5, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.hs ===================================== @@ -6,13 +6,20 @@ import Data.Kind type X :: Type -> Type data family X a -data instance X () = A | B | C | D | E +data instance X () + = A | B | C | D | E + | F | G | H | I | J deriving Eq f :: X () -> Int -> Int f x v - | x == A = 1 + v - | x == B = 2 + v - | x == C = 3 + v - | x == D = 4 + v - | otherwise = 5 + v + | x == A = v + 1 + | x == B = v + 2 + | x == C = v + 3 + | x == D = v + 4 + | x == E = v + 5 + | x == F = v + 6 + | x == G = v + 7 + | x == H = v + 8 + | x == I = v + 9 + | otherwise = v + 10 ===================================== testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 86, types: 65, coercions: 15, joins: 0/0} + = {terms: 116, types: 75, coercions: 25, joins: 0/0} -- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} T22375DataFamily.$WA [InlPrag=INLINE[final] CONLIKE] :: X () @@ -58,6 +58,61 @@ T22375DataFamily.$WE `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) :: T22375DataFamily.R:XUnit ~R# X ()) +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WF [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WF + = T22375DataFamily.F + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WG [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WG + = T22375DataFamily.G + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WH [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WH + = T22375DataFamily.H + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WI [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WI + = T22375DataFamily.I + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + +-- RHS size: {terms: 1, types: 0, coercions: 2, joins: 0/0} +T22375DataFamily.$WJ [InlPrag=INLINE[final] CONLIKE] :: X () +[GblId[DataConWrapper], + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=False)}] +T22375DataFamily.$WJ + = T22375DataFamily.J + `cast` (Sym (T22375DataFamily.D:R:XUnit0[0]) + :: T22375DataFamily.R:XUnit ~R# X ()) + -- RHS size: {terms: 14, types: 11, coercions: 2, joins: 0/0} T22375DataFamily.$fEqX_$c== :: X () -> X () -> Bool [GblId, @@ -133,7 +188,7 @@ T22375DataFamily.$fEqX = GHC.Classes.C:Eq @(X ()) T22375DataFamily.$fEqX_$c== T22375DataFamily.$fEqX_$c/= --- RHS size: {terms: 24, types: 4, coercions: 1, joins: 0/0} +-- RHS size: {terms: 44, types: 4, coercions: 1, joins: 0/0} T22375DataFamily.$wf [InlPrag=[2]] :: X () -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!])], @@ -141,18 +196,23 @@ T22375DataFamily.$wf [InlPrag=[2]] Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [64 0] 55 0}] + Guidance=IF_ARGS [119 0] 110 0}] T22375DataFamily.$wf = \ (x :: X ()) (ww :: GHC.Prim.Int#) -> case x `cast` (T22375DataFamily.D:R:XUnit0[0] :: X () ~R# T22375DataFamily.R:XUnit) of { - A -> GHC.Prim.+# 1# ww; - B -> GHC.Prim.+# 2# ww; - C -> GHC.Prim.+# 3# ww; - D -> GHC.Prim.+# 4# ww; - E -> GHC.Prim.+# 5# ww + A -> GHC.Prim.+# ww 1#; + B -> GHC.Prim.+# ww 2#; + C -> GHC.Prim.+# ww 3#; + D -> GHC.Prim.+# ww 4#; + E -> GHC.Prim.+# ww 5#; + F -> GHC.Prim.+# ww 6#; + G -> GHC.Prim.+# ww 7#; + H -> GHC.Prim.+# ww 8#; + I -> GHC.Prim.+# ww 9#; + J -> GHC.Prim.+# ww 10# } -- RHS size: {terms: 12, types: 6, coercions: 0, joins: 0/0} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e32482383b73f7fcc854c8e171f788f1f106a92...e80d1ee99adb0cc8462873850367cb1df1305142 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e32482383b73f7fcc854c8e171f788f1f106a92...e80d1ee99adb0cc8462873850367cb1df1305142 You're receiving 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 Nov 21 13:07:09 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 21 Nov 2023 08:07:09 -0500 Subject: [Git][ghc/ghc][wip/24107] driver: Ensure we actually clear the interactive context before reloading Message-ID: <655cab7d85c77_3a1d9d38c12a488032@gitlab.mail> Zubin pushed to branch wip/24107 at Glasgow Haskell Compiler / GHC Commits: 337e4e2f by Zubin Duggal at 2023-11-21T18:36:59+05:30 driver: Ensure we actually clear the interactive context before reloading Previously we called discardIC, but immediately after set the session back to an old HscEnv that still contained the IC Partially addresses #24107 Fixes #23405 - - - - - 4 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/ghci/T23405/T23405.hs - + testsuite/tests/ghci/T23405/T23405.script - + testsuite/tests/ghci/T23405/all.T Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -771,6 +771,7 @@ load' mhmi_cache how_much diag_wrapper mHscMessage mod_graph = do let pruneHomeUnitEnv hme = hme { homeUnitEnv_hpt = emptyHomePackageTable } setSession $ discardIC $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env + hsc_env <- getSession -- Unload everything liftIO $ unload interp hsc_env @@ -780,7 +781,6 @@ load' mhmi_cache how_much diag_wrapper mHscMessage mod_graph = do worker_limit <- liftIO $ mkWorkerLimit dflags - setSession $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env (upsweep_ok, new_deps) <- withDeferredDiagnostics $ do hsc_env <- getSession liftIO $ upsweep worker_limit hsc_env mhmi_cache diag_wrapper mHscMessage (toCache pruned_cache) build_plan ===================================== testsuite/tests/ghci/T23405/T23405.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23405 (test) where + +import Language.Haskell.TH + +test :: IO () +test = do + let s = $(getDoc (DeclDoc ''Double) >>= \doc -> [|doc|]) + print (s `seq` ()) + + ===================================== testsuite/tests/ghci/T23405/T23405.script ===================================== @@ -0,0 +1,3 @@ +:load T23405.hs +:! echo "-- an extra comment so that the hash changes" >> T18262.hs +:reload ===================================== testsuite/tests/ghci/T23405/all.T ===================================== @@ -0,0 +1 @@ +test('T23405', [extra_files(['T23405.hs'])], ghci_script, ['T23405.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/337e4e2fff6d482385a924a99040b2f48fa4d72a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/337e4e2fff6d482385a924a99040b2f48fa4d72a You're receiving 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 Nov 21 13:22:20 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 21 Nov 2023 08:22:20 -0500 Subject: [Git][ghc/ghc][wip/24107] compiler: Add some strictness annotations to ImportSpec and related constructors Message-ID: <655caf0c989b3_3a1d9d4496e1c893a5@gitlab.mail> Zubin pushed to branch wip/24107 at Glasgow Haskell Compiler / GHC Commits: 588fea96 by Zubin Duggal at 2023-11-21T18:47:12+05:30 compiler: Add some strictness annotations to ImportSpec and related constructors This prevents us from retain entire HscEnvs. Fixes #24107 - - - - - 2 changed files: - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Name/Reader.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1582,7 +1582,7 @@ gresFromIE decl_spec (L loc ie, gres) item_spec = ImpSome { is_explicit = is_explicit name , is_iloc = locA loc } set_gre_imp gre@( GRE { gre_name = nm } ) - = gre { gre_imp = unitBag $ prov_fn nm } + = gre { gre_imp = unitBag $! prov_fn nm } {- Note [Children for duplicate record fields] ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1916,8 +1916,8 @@ instance Semigroup ShadowedGREs where -- -- The 'ImportSpec' of something says how it came to be imported -- It's quite elaborate so that we can give accurate unused-name warnings. -data ImportSpec = ImpSpec { is_decl :: ImpDeclSpec, - is_item :: ImpItemSpec } +data ImportSpec = ImpSpec { is_decl :: !ImpDeclSpec, + is_item :: !ImpItemSpec } deriving( Eq, Data ) -- | Import Declaration Specification @@ -1926,15 +1926,15 @@ data ImportSpec = ImpSpec { is_decl :: ImpDeclSpec, -- shared among all the 'Provenance's for that decl data ImpDeclSpec = ImpDeclSpec { - is_mod :: Module, -- ^ Module imported, e.g. @import Muggle@ + is_mod :: !Module, -- ^ Module imported, e.g. @import Muggle@ -- Note the @Muggle@ may well not be -- the defining module for this thing! -- TODO: either should be Module, or there -- should be a Maybe UnitId here too. - is_as :: ModuleName, -- ^ Import alias, e.g. from @as M@ (or @Muggle@ if there is no @as@ clause) - is_qual :: Bool, -- ^ Was this import qualified? - is_dloc :: SrcSpan -- ^ The location of the entire import declaration + is_as :: !ModuleName, -- ^ Import alias, e.g. from @as M@ (or @Muggle@ if there is no @as@ clause) + is_qual :: !Bool, -- ^ Was this import qualified? + is_dloc :: !SrcSpan -- ^ The location of the entire import declaration } deriving (Eq, Data) -- | Import Item Specification @@ -1945,8 +1945,8 @@ data ImpItemSpec -- or had a hiding list | ImpSome { - is_explicit :: Bool, - is_iloc :: SrcSpan -- Location of the import item + is_explicit :: !Bool, + is_iloc :: !SrcSpan -- Location of the import item } -- ^ The import had an import list. -- The 'is_explicit' field is @True@ iff the thing was named -- /explicitly/ in the import specs rather View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/588fea96ff79d74e7f9812a2aafe80122addfa15 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/588fea96ff79d74e7f9812a2aafe80122addfa15 You're receiving 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 Nov 21 13:31:59 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 21 Nov 2023 08:31:59 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] 2 commits: More small changes Message-ID: <655cb14f93105_3a1d9d45d607091190@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 1507d4bf by Simon Peyton Jones at 2023-11-21T13:27:00+00:00 More small changes * Result discounts like before -- on RhsCtxt * Increase funAppDiscount and caseElimDiscount a bit - - - - - 6b3918cc by Simon Peyton Jones at 2023-11-21T13:31:15+00:00 Add RULES for eqList on [] This gives us better code when you say xs = [] or xs /= [] - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Unfold.hs - libraries/ghc-prim/GHC/Classes.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -211,7 +211,8 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance some_benefit = calc_some_benefit uf_arity enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) - UnfIfGoodArgs { ug_args = val_arg_bndrs, ug_tree = expr_tree } + UnfIfGoodArgs { ug_args = val_arg_bndrs + , ug_tree = expr_tree@(ExprTree { et_ret = ret_discount}) } | unfoldingVeryAggressive opts -> traceInline logger env fn str (mk_doc some_benefit extra_doc True) (Just unf_template) | is_wf && some_benefit && small_enough @@ -223,21 +224,15 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance some_benefit = calc_some_benefit n_bndrs small_enough = adjusted_size <= unfoldingUseThreshold opts rhs_size = exprTreeSize context expr_tree - adjusted_size = rhs_size - call_size_discount + depth_penalty + adjusted_size = rhs_size - call_size_discount - actual_ret_discount + depth_penalty -------- Compute the size of the ExprTree in this context ----------- - want_result - | n_bndrs < n_val_args = True -- Over-saturated - | otherwise = case cont_info of - CaseCtxt -> True - _ -> False + context = IC { ic_bound = bound_env + , ic_free = getFreeDigest } bound_env = mkVarEnv (val_arg_bndrs `zip` (arg_infos ++ repeat ArgNoInfo)) -- Crucial to include /all/ val_arg_bndrs, lest we treat -- them as free and use ic_free instead - context = IC { ic_bound = bound_env - , ic_free = getFreeDigest - , ic_want_res = want_result } in_scope = seInScope env getFreeDigest :: Id -> ArgDigest -- The ArgDigest of a free variable @@ -262,6 +257,23 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance arg_discount arg_info | hasArgInfo arg_info = 20 | otherwise = 10 + actual_ret_discount | n_bndrs < n_val_args + = ret_discount + | otherwise + = case cont_info of + BoringCtxt -> 0 + DiscArgCtxt -> 0 + RuleArgCtxt -> 0 + CaseCtxt -> ret_discount + ValAppCtxt -> ret_discount + RhsCtxt {} -> 40 `min` ret_discount + -- For RhsCtxt I suppose that exposing a data con is good in general + -- although 40 seems very arbitrary + -- + -- `min` thresholding: res_discount can be very large when a + -- function returns constructors; but we only want to invoke + -- that large discount when there's a case continuation. + -- Adjust by the depth scaling -- See Note [Avoid inlining into deeply nested cases] depth_threshold = unfoldingCaseThreshold opts @@ -650,6 +662,9 @@ exprDigest env e = go env e [] | Just con <- isDataConWorkId_maybe f = ArgIsCon (DataAlt con) (map (exprDigest env) val_args) + | Just rhs <- expandUnfolding_maybe unfolding + = go (zapSubstEnv env) rhs val_args + -- | DFunUnfolding {} <- unfolding | hasSomeUnfolding unfolding = ArgIsNot [] -- We (slightly hackily) use ArgIsNot [] for dfun applications @@ -663,12 +678,9 @@ exprDigest env e = go env e [] -- Actually in spectral/puzzle I found that we got a big (40%!) -- benefit from let newDest = ... in case (notSeen newDest) of ... -- We want to inline notSeen. The argument has structure (its RHS) - -- and in fact if we inline notSeen, newDest turns into a thunk + -- and in fact if we inline notSeen, newDest stops being a thunk -- (SPJ GHC log 13 Nov). - | Just rhs <- expandUnfolding_maybe unfolding - = go (zapSubstEnv env) rhs val_args - | OtherCon cs <- unfolding = ArgIsNot cs ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -206,7 +206,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- inline into Csg.calc (The unfolding for sqr never makes it -- into the interface file.) - , unfoldingUseThreshold = 70 + , unfoldingUseThreshold = 75 -- Adjusted 90 -> 80 when adding discounts for free variables which -- generally make things more likely to inline. Reducing the threshold -- eliminates some undesirable compile-time regressions (e.g. T10412a) @@ -214,7 +214,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- Previously: adjusted upwards in #18282, when I reduced -- the result discount for constructors. - , unfoldingFunAppDiscount = 30 + , unfoldingFunAppDiscount = 45 -- Be fairly keen to inline a function if that means -- we'll be able to pick the right method from a dictionary @@ -913,7 +913,7 @@ caseSize scrut_id alts caseElimDiscount :: Discount -- Bonus for eliminating a case -caseElimDiscount = 10 +caseElimDiscount = 15 {- Note [Bale out on very wide case expressions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1220,8 +1220,6 @@ binary sizes shrink significantly either. data InlineContext = IC { ic_free :: Id -> ArgDigest -- Current unfoldings for free variables , ic_bound :: IdEnv ArgDigest -- Digests for local variables - , ic_want_res :: Bool -- True <=> result is scrutinised/demanded - -- so apply result discount } data ArgDigest @@ -1254,15 +1252,8 @@ exprTreeWillInline limit (ExprTree { et_wc_tot = tot }) = tot <= limit ------------------------- exprTreeSize :: InlineContext -> ExprTree -> Size -- See Note [Overview of inlining heuristics] -exprTreeSize !ic (ExprTree { et_size = size - , et_cases = cases - , et_ret = ret_discount }) - = foldr ((+) . caseTreeSize (ic { ic_want_res = False })) - -- False: all result discount is at the top; ignore inner ones - discounted_size cases - where - discounted_size | ic_want_res ic = size - ret_discount - | otherwise = size +exprTreeSize !ic (ExprTree { et_size = size, et_cases = cases }) + = foldr ((+) . caseTreeSize ic) size cases caseTreeSize :: InlineContext -> CaseTree -> Size caseTreeSize ic (ScrutOf bndr disc) ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -146,8 +146,10 @@ class Eq a where {-# INLINE (/=) #-} {-# INLINE (==) #-} - x /= y = not (x == y) - x == y = not (x /= y) + -- Write these with no arg, so that they inline even as the argument of + -- the DFun. Then the RULES for eqList can fire. + (/=) = \x y -> not (x == y) + (==) = \x y -> not (x /= y) {-# MINIMAL (==) | (/=) #-} deriving instance Eq () @@ -189,9 +191,22 @@ instance (Eq a) => Eq [a] where {-# SPECIALISE instance Eq [[Char]] #-} {-# SPECIALISE instance Eq [Char] #-} {-# SPECIALISE instance Eq [Int] #-} - [] == [] = True - (x:xs) == (y:ys) = x == y && xs == ys - _xs == _ys = False + (==) = eqList + +-- These rules avoid the recursive function when +-- one of the arguments is the empty list. We want +-- good code for xs == [] or xs /= [] +{-# RULES +"eqList1" forall xs. eqList xs [] = case xs of { [] -> True; _ -> False } +"eqList2" forall ys. eqList [] ys = case ys of { [] -> True; _ -> False } + #-} + +eqList :: Eq a => [a] -> [a] -> Bool +{-# NOINLINE [1] eqList #-} -- Give the RULES eqList1/eqList2 a chance to fire +-- eqList should auto-specialise for the same types as specialise instance Eq above +eqList [] [] = True +eqList (x:xs) (y:ys) = x == y && eqList xs ys +eqList _xs _ys = False deriving instance Eq Module View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddd17134826249bbe87c370dbcabb12fc7a6c5d9...6b3918cc8a9e37c7ef97c49d5279acf72f9e2685 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddd17134826249bbe87c370dbcabb12fc7a6c5d9...6b3918cc8a9e37c7ef97c49d5279acf72f9e2685 You're receiving 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 Nov 21 14:23:24 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 09:23:24 -0500 Subject: [Git][ghc/ghc][wip/time-profile-tick] base: Hide timeProfileTick# Message-ID: <655cbd5ce98e8_3a1d9d5cdb8b095626@gitlab.mail> Ben Gamari pushed to branch wip/time-profile-tick at Glasgow Haskell Compiler / GHC Commits: e4617402 by Ben Gamari at 2023-11-21T14:23:21+00:00 base: Hide timeProfileTick# - - - - - 2 changed files: - libraries/base/src/GHC/Base.hs - libraries/base/src/GHC/Exts.hs Changes: ===================================== libraries/base/src/GHC/Base.hs ===================================== @@ -117,7 +117,7 @@ import GHC.Classes import GHC.CString import GHC.Magic import GHC.Magic.Dict -import GHC.Prim +import GHC.Prim hiding ( timeProfileTick# ) import GHC.Prim.Ext import GHC.Prim.PtrEq import GHC.Err ===================================== libraries/base/src/GHC/Exts.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Exts maxTupleSize, ) where -import GHC.Prim hiding ( coerce ) +import GHC.Prim hiding ( coerce, timeProfileTick# ) import GHC.Types hiding ( IO -- Exported from "GHC.IO" , Type -- Exported from "Data.Kind" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e46174023f096542ace000e71ac685ab5c851942 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e46174023f096542ace000e71ac685ab5c851942 You're receiving 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 Nov 21 15:49:47 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 10:49:47 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24205 Message-ID: <655cd19b30a4e_3a1d9d80d8a601388ef@gitlab.mail> Ben Gamari pushed new branch wip/T24205 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24205 You're receiving 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 Nov 21 17:32:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 12:32:00 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Speed up stimes in instance Semigroup Endo Message-ID: <655ce990af9b4_3a1d9da7f09f416386c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - d9c62d15 by Owen Shepherd at 2023-11-21T12:31:43-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - d9475af8 by Rodrigo Mesquita at 2023-11-21T12:31:44-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 22 changed files: - .gitlab/merge_request_templates/Default.md - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - libraries/base/changelog.md - libraries/base/src/Data/Semigroup/Internal.hs - libraries/base/tests/all.T - + libraries/base/tests/stimesEndo.hs - + libraries/base/tests/stimesEndo.stdout - testsuite/tests/printer/Test20297.stdout - + testsuite/tests/stranal/sigs/T6070.hs - + testsuite/tests/stranal/sigs/T6070.stderr - testsuite/tests/stranal/sigs/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs - utils/haddock Changes: ===================================== .gitlab/merge_request_templates/Default.md ===================================== @@ -30,7 +30,7 @@ label can be applied to perform additional validation checks if your MR affects unusual configuration. Once your change is ready please remove the `WIP:` tag and wait for review. If -no one has offerred review in a few days then please leave a comment mentioning +no one has offered a review in a few days then please leave a comment mentioning @triagers and apply the ~"Blocked on Review" label. [notes]: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/coding-style#comments-in-the-source-code ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan s) = parens $ text "EpaSpan" <+> srcSpan s epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Hs/ImpExp.hs ===================================== @@ -42,6 +42,7 @@ import GHC.Unit.Module.Warnings import Data.Data import Data.Maybe +import qualified Data.Semigroup as Semigroup {- @@ -119,6 +120,13 @@ data EpAnnImportDecl = EpAnnImportDecl , importDeclAnnAs :: Maybe EpaLocation } deriving (Data) +instance Semigroup EpAnnImportDecl where + EpAnnImportDecl a1 b1 c1 d1 e1 f1 <> EpAnnImportDecl a2 b2 c2 d2 e2 f2 + = EpAnnImportDecl (a1 Semigroup.<> a2) (b1 Semigroup.<> b2) (c1 Semigroup.<> c2) + (d1 Semigroup.<> d2) (e1 Semigroup.<> e2) (f1 Semigroup.<> f2) +instance Monoid EpAnnImportDecl where + mempty = EpAnnImportDecl noSpanAnchor Nothing Nothing Nothing Nothing Nothing + -- --------------------------------------------------------------------- simpleImportDecl :: ModuleName -> ImportDecl GhcPs ===================================== compiler/GHC/Parser.y ===================================== @@ -4308,7 +4308,7 @@ glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc glR :: HasLoc a => a -> Anchor -glR la = EpaSpan (realSrcSpan $ getHasLoc la) Strict.Nothing +glR la = EpaSpan (getHasLoc la) glMR :: Maybe (Located a) -> Located b -> Anchor glMR (Just la) _ = glR la @@ -4318,7 +4318,7 @@ glEE :: (HasLoc a, HasLoc b) => a -> b -> Anchor glEE x y = spanAsAnchor $ comb2 x y anc :: RealSrcSpan -> Anchor -anc r = EpaSpan r Strict.Nothing +anc r = EpaSpan (RealSrcSpan r Strict.Nothing) glRM :: Located a -> Maybe Anchor glRM (L l _) = Just $ spanAsAnchor l @@ -4442,7 +4442,7 @@ parseSignature :: P (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (NoAnn ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) -commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan (rs loc) Strict.Nothing) noAnn cs) loc +commentsA loc cs = SrcSpanAnn (EpAnn (EpaSpan loc) noAnn cs) loc -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -406,7 +406,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) +data EpaLocation = EpaSpan !SrcSpan | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq,Show) @@ -418,7 +418,7 @@ data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation getTokenSrcSpan :: TokenLocation -> SrcSpan getTokenSrcSpan NoTokenLoc = noSrcSpan getTokenSrcSpan (TokenLoc EpaDelta{}) = noSrcSpan -getTokenSrcSpan (TokenLoc (EpaSpan rspan mbufpos)) = RealSrcSpan rspan mbufpos +getTokenSrcSpan (TokenLoc (EpaSpan span)) = span instance Outputable a => Outputable (GenLocated TokenLocation a) where ppr (L _ x) = ppr x @@ -455,15 +455,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r _) = r -epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" +epaLocationRealSrcSpan (EpaSpan (RealSrcSpan r _)) = r +epaLocationRealSrcSpan _ = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan l +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = anc instance Outputable EpaLocation where - ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -527,18 +527,17 @@ data EpAnn ann type Anchor = EpaLocation -- Transitional anchor :: Anchor -> RealSrcSpan -anchor (EpaSpan r _) = r +anchor (EpaSpan (RealSrcSpan r _)) = r anchor _ = panic "anchor" spanAsAnchor :: SrcSpan -> Anchor -spanAsAnchor (RealSrcSpan r mb) = EpaSpan r mb -spanAsAnchor s = EpaSpan (realSrcSpan s) Strict.Nothing +spanAsAnchor ss = EpaSpan ss realSpanAsAnchor :: RealSrcSpan -> Anchor -realSpanAsAnchor r = EpaSpan r Strict.Nothing +realSpanAsAnchor s = EpaSpan (RealSrcSpan s Strict.Nothing) spanFromAnchor :: Anchor -> SrcSpan -spanFromAnchor (EpaSpan r mb) = RealSrcSpan r mb +spanFromAnchor (EpaSpan ss) = ss spanFromAnchor (EpaDelta _ _) = UnhelpfulSpan (UnhelpfulOther (fsLit "spanFromAnchor")) noSpanAnchor :: Anchor @@ -1062,8 +1061,8 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary l = mkRealSrcLoc (fsLit "realSrcSpan") (-1) (-1) srcSpan2e :: SrcSpan -> EpaLocation -srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb -srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing +srcSpan2e ss@(RealSrcSpan _ _) = EpaSpan ss +srcSpan2e span = EpaSpan (RealSrcSpan (realSrcSpan span) Strict.Nothing) la2e :: SrcSpanAnn' a -> EpaLocation la2e = srcSpan2e . locA @@ -1081,7 +1080,7 @@ reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e reAnnL anns cs (L l a) = L (SrcSpanAnn (EpAnn (spanAsAnchor l) anns cs) l) a getLocAnn :: Located a -> SrcSpanAnnA -getLocAnn (L l _) = SrcSpanAnn EpAnnNotUsed l +getLocAnn (L l _) = SrcSpanAnn noAnn l instance NoAnn (EpAnn a) where -- Short form for 'EpAnnNotUsed' @@ -1111,7 +1110,8 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s mb)):rest) = RealSrcSpan s mb : go rest + go (AddEpAnn _ (EpaSpan _):rest) = go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -1120,8 +1120,8 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest - go (AddEpAnn _ (EpaDelta _ _):rest) = go rest + go (AddEpAnn _ (EpaSpan (RealSrcSpan s _)):rest) = s : go rest + go (AddEpAnn _ _:rest) = go rest realSpanFromAnns :: [AddEpAnn] -> Strict.Maybe RealSrcSpan realSpanFromAnns as = go Strict.Nothing as @@ -1130,7 +1130,7 @@ realSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineRealSrcSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan s _b):rest) = go (combine acc s) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan s _b)):rest) = go (combine acc s) rest go acc (AddEpAnn _ _ :rest) = go acc rest bufSpanFromAnns :: [AddEpAnn] -> Strict.Maybe BufSpan @@ -1140,28 +1140,27 @@ bufSpanFromAnns as = go Strict.Nothing as combine (Strict.Just l) r = Strict.Just $ combineBufSpans l r go acc [] = acc - go acc (AddEpAnn _ (EpaSpan _ (Strict.Just mb)):rest) = go (combine acc mb) rest + go acc (AddEpAnn _ (EpaSpan (RealSrcSpan _ (Strict.Just mb))):rest) = go (combine acc mb) rest go acc (AddEpAnn _ _:rest) = go acc rest --- widenAnchor :: Anchor -> [AddEpAnn] -> Anchor --- widenAnchor (Anchor s op) as = Anchor (widenRealSpan s as) op widenAnchor :: Anchor -> [AddEpAnn] -> Anchor -widenAnchor (EpaSpan s mb) as - = EpaSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as)) --- widenAnchor (EpaSpan r mb) _ = EpaSpan r mb +widenAnchor (EpaSpan (RealSrcSpan s mb)) as + = EpaSpan (RealSrcSpan (widenRealSpan s as) (liftA2 combineBufSpans mb (bufSpanFromAnns as))) +widenAnchor (EpaSpan us) _ = EpaSpan us widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of Strict.Nothing -> a - Strict.Just r -> EpaSpan r Strict.Nothing + Strict.Just r -> EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorR :: Anchor -> RealSrcSpan -> Anchor -widenAnchorR (EpaSpan s _) r = EpaSpan (combineRealSrcSpans s r) Strict.Nothing -widenAnchorR (EpaDelta _ _) r = EpaSpan r Strict.Nothing +widenAnchorR (EpaSpan (RealSrcSpan s _)) r = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) Strict.Nothing) +widenAnchorR (EpaSpan _) r = EpaSpan (RealSrcSpan r Strict.Nothing) +widenAnchorR (EpaDelta _ _) r = EpaSpan (RealSrcSpan r Strict.Nothing) widenAnchorS :: Anchor -> SrcSpan -> Anchor -widenAnchorS (EpaSpan s mbe) (RealSrcSpan r mbr) - = EpaSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr) -widenAnchorS (EpaSpan us mb) _ = EpaSpan us mb -widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan r mb +widenAnchorS (EpaSpan (RealSrcSpan s mbe)) (RealSrcSpan r mbr) + = EpaSpan (RealSrcSpan (combineRealSrcSpans s r) (liftA2 combineBufSpans mbe mbr)) +widenAnchorS (EpaSpan us) _ = EpaSpan us +widenAnchorS (EpaDelta _ _) (RealSrcSpan r mb) = EpaSpan (RealSrcSpan r mb) widenAnchorS anc _ = anc widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an @@ -1251,7 +1250,7 @@ placeholderRealSpan :: RealSrcSpan placeholderRealSpan = realSrcLocSpan (mkRealSrcLoc (mkFastString "placeholder") (-1) (-1)) comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO -comment loc cs = EpAnn (EpaSpan loc Strict.Nothing) NoEpAnns cs +comment loc cs = EpAnn (EpaSpan (RealSrcSpan loc Strict.Nothing)) NoEpAnns cs -- --------------------------------------------------------------------- -- Utilities for managing comments in an `EpAnn a` structure. @@ -1394,9 +1393,9 @@ instance (Semigroup a) => Semigroup (EpAnn a) where -- largest span instance Semigroup EpaLocation where - EpaSpan s1 m1 <> EpaSpan s2 m2 = EpaSpan (combineRealSrcSpans s1 s2) (liftA2 combineBufSpans m1 m2) - EpaSpan s1 m1 <> _ = EpaSpan s1 m1 - _ <> EpaSpan s2 m2 = EpaSpan s2 m2 + EpaSpan s1 <> EpaSpan s2 = EpaSpan (combineSrcSpans s1 s2) + EpaSpan s1 <> _ = EpaSpan s1 + _ <> EpaSpan s2 = EpaSpan s2 EpaDelta dp1 cs1 <> EpaDelta _dp2 cs2 = EpaDelta dp1 (cs1<>cs2) instance Semigroup EpAnnComments where ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3780,7 +3780,8 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan (RealSrcSpan lo Strict.Nothing)), + AddEpAnn AnnCloseP (EpaSpan (RealSrcSpan lc Strict.Nothing))) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -472,29 +472,30 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 - | valid_anchor (anchor a) +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs _))) (EpAnn a (AnnList anc o c r t) cs) cs2 + | valid_anchor a = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs mb)) EpAnnNotUsed cs - = EpAnn (EpaSpan rs mb) - (AnnList (Just $ EpaSpan rs mb) Nothing Nothing [an] []) cs +add_where an@(AddEpAnn _ (EpaSpan (RealSrcSpan rs mb))) EpAnnNotUsed cs + = EpAnn (EpaSpan (RealSrcSpan rs mb)) + (AnnList (Just $ EpaSpan (RealSrcSpan rs mb)) Nothing Nothing [an] []) cs add_where (AddEpAnn _ _) _ _ = panic "add_where" -- EpaDelta should only be used for transformations -valid_anchor :: RealSrcSpan -> Bool -valid_anchor r = srcSpanStartLine r >= 0 +valid_anchor :: Anchor -> Bool +valid_anchor (EpaSpan (RealSrcSpan r _)) = srcSpanStartLine r >= 0 +valid_anchor _ = False -- If the decl list for where binds is empty, the anchor ends up -- invalid. In this case, use the parent one patch_anchor :: RealSrcSpan -> Anchor -> Anchor -patch_anchor r (EpaDelta _ _) = EpaSpan r Strict.Nothing -patch_anchor r1 (EpaSpan r0 mb) = EpaSpan r mb +patch_anchor r (EpaDelta _ _) = EpaSpan (RealSrcSpan r Strict.Nothing) +patch_anchor r1 (EpaSpan (RealSrcSpan r0 mb)) = EpaSpan (RealSrcSpan r mb) where r = if srcSpanStartLine r0 < 0 then r1 else r0 --- patch_anchor _ (EpaSpan ss mb) = EpaSpan ss mb +patch_anchor _ (EpaSpan ss) = EpaSpan ss fixValbindsAnn :: EpAnn AnnList -> EpAnn AnnList fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed @@ -504,9 +505,9 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor -stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan r rb)) _), _)) - = Just $ widenAnchorS (EpaSpan l mb) (RealSrcSpan r rb) -stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan l mb +stmtsAnchor (L (RealSrcSpan l mb) ((ConsOL (AddEpAnn _ (EpaSpan (RealSrcSpan r rb))) _), _)) + = Just $ widenAnchorS (EpaSpan (RealSrcSpan l mb)) (RealSrcSpan r rb) +stmtsAnchor (L (RealSrcSpan l mb) _) = Just $ EpaSpan (RealSrcSpan l mb) stmtsAnchor _ = Nothing stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan @@ -994,7 +995,7 @@ checkTyVars pp_what equals_or_where tc tparms for_widening _ = AddEpAnn AnnAnyclass (EpaDelta (SameLine 0) []) for_widening_ann :: HsBndrVis GhcPs -> EpAnn [AddEpAnn] - for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan r _mb)) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments + for_widening_ann (HsBndrInvisible (L (TokenLoc (EpaSpan (RealSrcSpan r _mb))) _)) = EpAnn (realSpanAsAnchor r) [] emptyComments for_widening_ann _ = EpAnnNotUsed @@ -1111,14 +1112,14 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c []) cs) + an = EpAnn (EpaSpan (RealSrcSpan lr Strict.Nothing)) (NameAnn NameParens o (srcSpan2e l) c []) cs in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) - in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) + lr = RealSrcSpan (combineRealSrcSpans (anchor ap) (anchor as)) Strict.Nothing + an = EpAnn (EpaSpan lr) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs) + in SrcSpanAnn an lr -- | Yield a parse error if we have a function applied directly to a do block -- etc. and BlockArguments is not enabled. @@ -3210,14 +3211,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan (RealSrcSpan r mb)) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) +token_location_widenR (TokenLoc (EpaSpan s1)) s2 = + (TokenLoc (EpaSpan (combineSrcSpans s1 s2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -163,14 +163,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show ===================================== libraries/base/changelog.md ===================================== @@ -3,7 +3,9 @@ ## 4.20.0.0 *TBA* * Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167)) * Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68)) - * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) + * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #175](https://github.com/haskell/core-libraries-committee/issues/175)) + * Implement `stimes` for `instance Semigroup (Endo a)` explicitly ([CLC proposal #4](https://github.com/haskell/core-libraries-committee/issues/4)) + * Add laws relating between `Foldable` / `Traversable` with `Bifoldable` / `Bitraversable` ([CLC proposal #205](https://github.com/haskell/core-libraries-committee/issues/205)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` @@ -29,6 +31,8 @@ constructors in scope and the levity of `t` is statically known, then the constraint `DataToTag t` can always be solved. + ([CLC proposal #104](https://github.com/haskell/core-libraries-committee/issues/104)) + ## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ===================================== libraries/base/src/Data/Semigroup/Internal.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PolyKinds #-} @@ -134,8 +135,46 @@ newtype Endo a = Endo { appEndo :: a -> a } -- | @since 4.9.0.0 instance Semigroup (Endo a) where - (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) - stimes = stimesMonoid + (<>) = coerce ((.) :: (a -> a) -> (a -> a) -> (a -> a)) + + -- See Note [stimes Endo] + stimes !n0 (Endo e) = Endo (\a0 -> + -- We check separately for 0 and 1 per + -- https://github.com/haskell/core-libraries-committee/issues/4#issuecomment-955605592 + -- We are explicitly strict in the number so strictness is calculated + -- correctly even without specialization. + case n0 of + _ | n0 < 0 -> stimesEndoError + 0 -> a0 + 1 -> e a0 + _ -> go n0 a0) + where + go !0 a = a + go n a = e (go (n - 1) a) + +{-# NOINLINE stimesEndoError #-} +-- There's no reason to put this gunk in the unfolding. +stimesEndoError :: a +stimesEndoError = errorWithoutStackTrace "stimes (for Endo): negative multiplier" + +-- Note [stimes Endo] +-- ~~~~~~~~~~~~~~~~~~ +-- +-- We used to use +-- +-- stimes = stimesMonoid +-- +-- But this is pretty bad! The function it produces is represented in memory as +-- a balanced tree of compositions. To actually *apply* that function, it's +-- necessary to walk the tree. It's much better to just construct a function +-- that counts out applications. +-- +-- Why do we break open the `Endo` construction rather than just using `mempty` +-- and `<>`? We want GHC to infer that `stimes` has an arity of 3. Currently, +-- it does so by default, but there has been some talk in the past of turning +-- on -fpedantic-bottoms, which would drop the arity to 2. Indeed, if we were +-- really careless, we could theoretically get GHC to build a *list* of +-- compositions, which would be awful. -- | @since 2.01 instance Monoid (Endo a) where ===================================== libraries/base/tests/all.T ===================================== @@ -317,3 +317,4 @@ test('T23697', [ when(opsys('mingw32'), skip) # header not found , when(opsys('darwin'), skip) # permission denied ], makefile_test, ['T23697']) +test('stimesEndo', normal, compile_and_run, ['']) ===================================== libraries/base/tests/stimesEndo.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import Data.Semigroup + +adder :: Int -> Endo Int +adder n = stimes n (Endo (+ 1)) + +main :: IO () +main = print $ map (\n -> appEndo (adder n) 0) [0 .. 5] ===================================== libraries/base/tests/stimesEndo.stdout ===================================== @@ -0,0 +1 @@ +[0,1,2,3,4,5] ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -99,10 +99,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.hs:7:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.hs:7:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.hs:7:3-7 }))] @@ -390,10 +390,10 @@ {OccName: x}))))))] (HsValBinds (EpAnn - (EpaSpan { Test20297.ppr.hs:5:3-7 }) + (EpaSpan { }) (AnnList (Just - (EpaSpan { Test20297.ppr.hs:5:3-7 })) + (EpaSpan { })) (Nothing) (Nothing) [(AddEpAnn AnnWhere (EpaSpan { Test20297.ppr.hs:5:3-7 }))] ===================================== testsuite/tests/stranal/sigs/T6070.hs ===================================== @@ -0,0 +1,13 @@ +module T6070 where + +import qualified Data.Map as M + +-- Should unbox `x`, so signature 1!P(..,..) +h :: (Int, Int) -> Int -> (Int, Int) +h x y = if y > 10 + then x + else h (case h x 0 of (y1, y2) -> (y2, y1)) (y + 1) + +-- Should unbox `(a,b)`, so signature 1!P(..,..) +c :: M.Map Int Int -> (Int, Int) +c m = M.foldrWithKey (\k v (a, b) -> if k + v > 2 then (a, b) else (b, a)) (0, 1) m ===================================== testsuite/tests/stranal/sigs/T6070.stderr ===================================== @@ -0,0 +1,18 @@ + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T6070.c: 1 +T6070.h: 1 + + + +==================== Strictness signatures ==================== +T6070.c: <1L> +T6070.h: <1!P(L,L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -18,6 +18,7 @@ test('DmdAnalGADTs', normal, compile, ['']) test('T12370', normal, compile, ['']) test('NewtypeArity', normal, compile, ['']) test('T5075', normal, compile, ['']) +test('T6070', normal, compile, ['']) test('T17932', normal, compile, ['']) test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -422,7 +422,7 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do debugM $ "enterAnn:starting:(p,pe,anchor',a) =" ++ show (p, pe0, showAst anchor', astId a) prevAnchor <- getAnchorU let curAnchor = case anchor' of - EpaSpan r _ -> r + EpaSpan (RealSrcSpan r _) -> r _ -> prevAnchor debugM $ "enterAnn:(curAnchor):=" ++ show (rs2range curAnchor) case canUpdateAnchor of @@ -495,10 +495,11 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do Just (EpaDelta dp _) -> dp -- Replace original with desired one. Allows all -- list entry values to be DP (1,0) - Just (EpaSpan r _) -> dp + Just (EpaSpan (RealSrcSpan r _)) -> dp where dp = adjustDeltaForOffset off (ss2delta priorEndAfterComments r) + Just (EpaSpan (UnhelpfulSpan r)) -> panic $ "enterAnn: UnhelpfulSpan:" ++ show r -- --------------------------------------------- -- Preparation complete, perform the action when (priorEndAfterComments < spanStart) (do @@ -543,9 +544,10 @@ enterAnn (Entry anchor' trailing_anns cs flush canUpdateAnchor) a = do case anchor' of EpaDelta _ _ -> return () - EpaSpan rss _ -> do + EpaSpan (RealSrcSpan rss _) -> do setAcceptSpan False setPriorEndD (snd $ rs2range rss) + EpaSpan _ -> return () -- Outside the anchor, mark any trailing postCs <- cua canUpdateAnchor takeAppliedCommentsPop @@ -723,7 +725,8 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (RealSrcSpan r _)) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan (UnhelpfulSpan _)) s = printStringAtAAC capture (EpaDelta (SameLine 0) []) s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ printOneComment $ concatMap tokComment cs pe1 <- getPriorEndD @@ -798,10 +801,10 @@ markEpAnnLMS' (EpAnn anc a cs) l kw (Just str) = do markLToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) => Located (HsToken tok) -> EP w m (Located (HsToken tok)) markLToken (L (RealSrcSpan aa mb) t) = do - epaLoc'<- printStringAtAA (EpaSpan aa mb) (symbolVal (Proxy @tok)) + epaLoc'<- printStringAtAA (EpaSpan (RealSrcSpan aa mb)) (symbolVal (Proxy @tok)) case epaLoc' of - EpaSpan aa' mb' -> return (L (RealSrcSpan aa' mb') t) - _ -> return (L (RealSrcSpan aa mb ) t) + EpaSpan (RealSrcSpan aa' mb') -> return (L (RealSrcSpan aa' mb') t) + _ -> return (L (RealSrcSpan aa mb ) t) markLToken (L lt t) = return (L lt t) markToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok) @@ -1403,12 +1406,13 @@ printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c dp <-case loc of EpaDelta dp _ -> return dp - EpaSpan r _ -> do + EpaSpan (RealSrcSpan r _) -> do pe <- getPriorEndD debugM $ "printOneComment:pe=" ++ showGhc pe let dp = ss2delta pe r debugM $ "printOneComment:(dp,pe,loc)=" ++ showGhc (dp,pe,loc) adjustDeltaForOffsetM dp + EpaSpan (UnhelpfulSpan _) -> return (SameLine 0) mep <- getExtraDP dp' <- case mep of Just (EpaDelta edp _) -> do @@ -1429,12 +1433,13 @@ updateAndApplyComment (Comment str anc pp mo) dp = do (r,c) = ss2posEnd pp dp'' = case anc of EpaDelta dp1 _ -> dp1 - EpaSpan la _ -> + EpaSpan (RealSrcSpan la _) -> if r == 0 then (ss2delta (r,c+0) la) else (ss2delta (r,c) la) + EpaSpan (UnhelpfulSpan _) -> SameLine 0 dp' = case anc of - EpaSpan r1 _ -> + EpaSpan (RealSrcSpan r1 _) -> if pp == r1 then dp else dp'' @@ -1459,7 +1464,7 @@ commentAllocationBefore ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2pos r) <= (ss2pos ss) + EpaSpan (RealSrcSpan r _) -> (ss2pos r) <= (ss2pos ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -1475,7 +1480,7 @@ commentAllocationIn ss = do -- TODO: this is inefficient, use Pos all the way through let (earlier,later) = partition (\(Comment _str loc _r _mo) -> case loc of - EpaSpan r _ -> (ss2posEnd r) <= (ss2posEnd ss) + EpaSpan (RealSrcSpan r _) -> (ss2posEnd r) <= (ss2posEnd ss) _ -> True -- Choose one ) cs putUnallocatedComments later @@ -4376,7 +4381,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ _ -> return anc + EpaSpan _ -> return anc EpaDelta dp [] -> return $ EpaDelta dp [] EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -284,7 +284,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance cs = cs' where cs' = case GHC.hsmodLayout $ GHC.hsmodExt p of - GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan ss _)) _) -> + GHC.ExplicitBraces _ (GHC.L (GHC.TokenLoc (GHC.EpaSpan (GHC.RealSrcSpan ss _))) _) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -222,8 +222,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) - EpaDelta _ _ -> AddEpAnn kw dca + EpaSpan (RealSrcSpan r _) -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + _ -> AddEpAnn kw dca -- --------------------------------- @@ -232,7 +232,8 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let anc0 = case dca of - EpaSpan r _ -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (RealSrcSpan r _) -> EpaDelta (ss2delta (ss2posEnd r) (realSrcSpan ll)) [] + EpaSpan (UnhelpfulSpan _) -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc0 noAnn emptyComments) ll) b) (L (SrcSpanAnn (EpAnn anc0 a c) ll) b) @@ -240,7 +241,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H anc' = case anc0 of EpaDelta _ _ -> anc0 _ -> case dca of - EpaSpan _ _ -> EpaDelta (SameLine 1) [] + EpaSpan _ -> EpaDelta (SameLine 1) [] EpaDelta _ cs0 -> EpaDelta (SameLine 1) cs0 in (L (SrcSpanAnn (EpAnn anc' a c) ll) b) @@ -268,7 +269,11 @@ setEntryDP (L (SrcSpanAnn EpAnnNotUsed l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) noAnn emptyComments) l) a -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _ _) an (EpaComments [])) l) a) dp +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (UnhelpfulSpan _)) an cs) l) a) dp + = L (SrcSpanAnn + (EpAnn (EpaDelta dp []) an cs) + l) a +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan _) an (EpaComments [])) l) a) dp = L (SrcSpanAnn (EpAnn (EpaDelta dp []) an (EpaComments [])) l) a @@ -299,8 +304,8 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaDelta d csd) an cs) l) a) dp in (dp0, c':t, EpaCommentsBalanced [] ts) go (L (EpaDelta _ c0) c) = (d, L (EpaDelta dp c0) c) - go (L (EpaSpan _ _) c) = (d, L (EpaDelta dp []) c) -setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp + go (L (EpaSpan _) c) = (d, L (EpaDelta dp []) c) +setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r _)) an cs) l) a) dp = case sortEpaComments (priorComments cs) of [] -> L (SrcSpanAnn @@ -315,8 +320,9 @@ setEntryDP (L (SrcSpanAnn (EpAnn (EpaSpan r _) an cs) l) a) dp csd = L (EpaDelta dp []) c:cs' lc = last $ (L ca c:cs') delta = case getLoc lc of - EpaSpan rr _ -> ss2delta (ss2pos rr) r - EpaDelta _dp _ -> DifferentLine 1 0 + EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r + EpaSpan _ -> (SameLine 0) + EpaDelta _ _ -> DifferentLine 1 0 -- cs'' = setPriorComments cs (L (EpaDelta dp []) c:cs') -- lc = head $ reverse $ (L ca c:cs') -- delta = case getLoc lc of @@ -340,17 +346,20 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r _) +addEpaLocationDelta _off _anc s@(EpaSpan (UnhelpfulSpan _)) = s +addEpaLocationDelta off anc (EpaSpan (RealSrcSpan r _)) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor _off (EpaSpan (UnhelpfulSpan _)) (L la a) = L la a +setEntryDPFromAnchor off (EpaSpan (RealSrcSpan anc _)) ll@(L la _) = setEntryDP ll dp' where dp' = case la of (SrcSpanAnn EpAnnNotUsed l) -> adjustDeltaForOffset off (ss2deltaEnd anc (realSrcSpan l)) - (SrcSpanAnn (EpAnn (EpaSpan r' _) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan (RealSrcSpan r' _)) _ _) _) -> adjustDeltaForOffset off (ss2deltaEnd anc r') + (SrcSpanAnn (EpAnn (EpaSpan _) _ _) _) -> adjustDeltaForOffset off (SameLine 0) (SrcSpanAnn (EpAnn (EpaDelta dp _) _ _) _) -> adjustDeltaForOffset off dp -- --------------------------------------------------------------------- @@ -381,7 +390,7 @@ transferEntryDP (L (SrcSpanAnn EpAnnNotUsed _l1) _) (L (SrcSpanAnn (EpAnn anc2 a where anc2' = case anc2 of EpaDelta _ _ -> anc2 - EpaSpan _ _ -> EpaSpan (realSrcSpan l2) Strict.Nothing + EpaSpan _ -> EpaSpan (RealSrcSpan (realSrcSpan l2) Strict.Nothing) -- |If a and b are the same type return first arg, else return second @@ -447,7 +456,7 @@ balanceCommentsFB (L lf (FunBind x n (MG o (L lm matches)))) second = do -- + move the trailing ones to the last match. let (before,middle,after) = case s_entry lf of - EpaSpan ss _ -> + EpaSpan (RealSrcSpan ss _) -> let split = splitCommentsEnd ss (s_comments lf) split2 = splitCommentsStart ss (EpaComments (sortEpaComments $ priorComments split)) @@ -630,7 +639,7 @@ priorCommentsDeltas r cs = go r (reverse $ sortEpaComments cs) splitCommentsEnd :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsEnd p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -638,7 +647,7 @@ splitCommentsEnd p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -649,7 +658,7 @@ splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' splitCommentsStart :: RealSrcSpan -> EpAnnComments -> EpAnnComments splitCommentsStart p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = case after of @@ -657,7 +666,7 @@ splitCommentsStart p (EpaComments cs) = cs' _ -> EpaCommentsBalanced before after splitCommentsStart p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _) _) = ss2pos l > ss2posEnd p + cmp (L (EpaSpan (RealSrcSpan l _)) _) = ss2pos l > ss2posEnd p cmp (L _ _) = True (before, after) = break cmp cs cs' = before @@ -933,7 +942,8 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (RealSrcSpan r _)) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan (UnhelpfulSpan _)) -> LayoutStartCol 0 (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -123,7 +123,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) +undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan (RealSrcSpan sp Strict.Nothing)) where (l,c) = undelta (ss2pos anc) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -170,7 +170,7 @@ spanLength = (-) <$> srcSpanEndCol <*> srcSpanStartCol -- | Useful for debug dumps eloc2str :: EpaLocation -> String -eloc2str (EpaSpan r _) = "EpaSpan " ++ show (rs2range r) +eloc2str (EpaSpan r) = "EpaSpan " ++ show (ss2range r) eloc2str epaLoc = show epaLoc -- --------------------------------------------------------------------- @@ -186,7 +186,7 @@ isPointSrcSpan ss = spanLength ss == 0 -- `MovedAnchor` operation based on the original location, only if it -- does not already have one. commentOrigDelta :: LEpaComment -> LEpaComment -commentOrigDelta (L (EpaSpan la _) (GHC.EpaComment t pp)) +commentOrigDelta (L (EpaSpan (RealSrcSpan la _)) (GHC.EpaComment t pp)) = (L (EpaDelta dp []) (GHC.EpaComment t pp)) `debug` ("commentOrigDelta: (la, pp, r,c, dp)=" ++ showAst (la, pp, r,c, dp)) where @@ -331,8 +331,10 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss mb) - = Comment (keywordToString kw) (EpaSpan ss mb) ss (Just kw) +mkKWComment kw (EpaSpan (RealSrcSpan ss mb)) + = Comment (keywordToString kw) (EpaSpan (RealSrcSpan ss mb)) ss (Just kw) +mkKWComment kw (EpaSpan (UnhelpfulSpan _)) + = Comment (keywordToString kw) (EpaDelta (SameLine 0) []) placeholderRealSpan (Just kw) mkKWComment kw (EpaDelta dp cs) = Comment (keywordToString kw) (EpaDelta dp cs) placeholderRealSpan (Just kw) @@ -444,15 +446,18 @@ To be absolutely sure, we make the delta versions use -ve values. hackSrcSpanToAnchor :: SrcSpan -> Anchor hackSrcSpanToAnchor (UnhelpfulSpan s) = error $ "hackSrcSpanToAnchor : UnhelpfulSpan:" ++ show s -hackSrcSpanToAnchor (RealSrcSpan r Strict.Nothing) = EpaSpan r Strict.Nothing -hackSrcSpanToAnchor (RealSrcSpan r mb@(Strict.Just (BufSpan (BufPos s) (BufPos e)))) - = if s <= 0 && e <= 0 - then EpaDelta (deltaPos (-s) (-e)) [] - `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) - else EpaSpan r mb +hackSrcSpanToAnchor (RealSrcSpan r mb) + = case mb of + (Strict.Just (BufSpan (BufPos s) (BufPos e))) -> + if s <= 0 && e <= 0 + then EpaDelta (deltaPos (-s) (-e)) [] + `debug` ("hackSrcSpanToAnchor: (r,s,e)=" ++ showAst (r,s,e) ) + -- else Anchor r UnchangedAnchor + else EpaSpan (RealSrcSpan r mb) + _ -> EpaSpan (RealSrcSpan r mb) hackAnchorToSrcSpan :: Anchor -> SrcSpan -hackAnchorToSrcSpan (EpaSpan r mb) = RealSrcSpan r mb +hackAnchorToSrcSpan (EpaSpan s) = s hackAnchorToSrcSpan _ = error $ "hackAnchorToSrcSpan" -- --------------------------------------------------------------------- ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a70ba4918b8a65abd18b16f414b6e2c3c4e38c46 +Subproject commit 96e713f7768926dab4aeec5175c1854057a833c9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cee9bb14e6c76c27b702f8b50084435f7e20cf84...d9475af88d267c7dcb79ec54dff55cb0c6842860 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cee9bb14e6c76c27b702f8b50084435f7e20cf84...d9475af88d267c7dcb79ec54dff55cb0c6842860 You're receiving 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 Nov 21 19:14:18 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 21 Nov 2023 14:14:18 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-present-noann Message-ID: <655d018ae5650_3a1d9dceb11881849f6@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-present-noann at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-present-noann You're receiving 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 Nov 21 20:52:16 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 15:52:16 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: chore: Correct typo in the gitlab MR template Message-ID: <655d18803486c_3a1d9df86bd0c20952f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 77834263 by Owen Shepherd at 2023-11-21T15:52:11-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - 91b5d191 by Rodrigo Mesquita at 2023-11-21T15:52:11-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 58857f25 by Ben Gamari at 2023-11-21T15:52:12-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 3 changed files: - .gitlab/merge_request_templates/Default.md - docs/users_guide/exts/quantified_constraints.rst - hadrian/src/Hadrian/Oracles/TextFile.hs Changes: ===================================== .gitlab/merge_request_templates/Default.md ===================================== @@ -30,7 +30,7 @@ label can be applied to perform additional validation checks if your MR affects unusual configuration. Once your change is ready please remove the `WIP:` tag and wait for review. If -no one has offerred review in a few days then please leave a comment mentioning +no one has offered a review in a few days then please leave a comment mentioning @triagers and apply the ~"Blocked on Review" label. [notes]: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/coding-style#comments-in-the-source-code ===================================== docs/users_guide/exts/quantified_constraints.rst ===================================== @@ -6,6 +6,7 @@ Quantified constraints .. extension:: QuantifiedConstraints :shortdesc: Allow ``forall`` quantifiers in constraints. + :implies: :extension:`ExplicitForAll` :since: 8.6.1 Allow constraints to quantify over types. ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -163,14 +163,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9475af88d267c7dcb79ec54dff55cb0c6842860...58857f250e9c55f0eb1434850e70b4b456d6348d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9475af88d267c7dcb79ec54dff55cb0c6842860...58857f250e9c55f0eb1434850e70b4b456d6348d You're receiving 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 Nov 21 21:09:17 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 16:09:17 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T24211 Message-ID: <655d1c7d607c7_3a1d9d101067f0216151@gitlab.mail> Ben Gamari pushed new branch wip/T24211 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24211 You're receiving 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 Nov 21 21:33:37 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 16:33:37 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T23674 Message-ID: <655d223134f55_3a1d9d102e0e542197e0@gitlab.mail> Ben Gamari pushed new branch wip/T23674 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23674 You're receiving 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 Nov 21 21:52:42 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 16:52:42 -0500 Subject: [Git][ghc/ghc][wip/T23674] 2 commits: ghc-toolchain: Support otool and install_name_tool Message-ID: <655d26aadad83_3a1d9d10ecfe182218bc@gitlab.mail> Ben Gamari pushed to branch wip/T23674 at Glasgow Haskell Compiler / GHC Commits: 4c60f25e by Ben Gamari at 2023-11-21T16:46:17-05:00 ghc-toolchain: Support otool and install_name_tool Partially addresses #23674. - - - - - a74f7b48 by Ben Gamari at 2023-11-21T16:52:25-05:00 configure: Ensure that otool and install-name-tool exist Otherwise set them to "false" to unambiguously indicate that they are unavailable. - - - - - 10 changed files: - configure.ac - distrib/configure.ac.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - m4/prep_target_file.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/ghc-toolchain.cabal - utils/ghc-toolchain/src/GHC/Toolchain/Target.hs - + utils/ghc-toolchain/src/GHC/Toolchain/Tools/InstallNameTool.hs - + utils/ghc-toolchain/src/GHC/Toolchain/Tools/Otool.hs Changes: ===================================== configure.ac ===================================== @@ -489,13 +489,13 @@ AC_SUBST([StripCmd]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], [false]) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [false]) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== distrib/configure.ac.in ===================================== @@ -208,13 +208,13 @@ AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], []) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], []) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -35,6 +35,8 @@ Target , tgtRanlib = Nothing , tgtNm = Nm {nmProgram = Program {prgPath = "", prgFlags = []}} +, tgtOtool = Nothing +, tgtInstallNameTool = Nothing , tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = ["-r"]}, mergeObjsSupportsResponseFiles = False}) , tgtWindres = Nothing } ===================================== hadrian/cfg/default.target.in ===================================== @@ -35,6 +35,8 @@ Target , tgtRanlib = Just (Ranlib {ranlibProgram = Program {prgPath = "@RanlibCmd@", prgFlags = []}}) , tgtNm = Nm {nmProgram = Program {prgPath = "@NmCmd@", prgFlags = []}} +, tgtOtool = @OtoolCmdMaybe@ +, tgtInstallNameTool = @InstallNameToolCmdMaybe@ , tgtMergeObjs = @MergeObjsCmdMaybe@ , tgtWindres = @WindresCmdMaybeProg@ } ===================================== m4/prep_target_file.m4 ===================================== @@ -161,6 +161,19 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_LIST([CONF_CXX_OPTS_STAGE0]) PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE0]) + if test "$OtoolCmd" = "false"; then + OtoolCmdMaybe=Nothing + else + OtoolCmdMaybe="Just (Otool {otoolProgram = Program{prgPath = \"$OtoolCmd\", prgFlags = @<:@@:>@)" + fi + AC_SUBST([OtoolCmdMaybe]) + + if test "$InstallNameToolCmd" = "false"; then + InstallNameToolCmdMaybe=Nothing + else + InstallNameToolCmdMaybe="Just (InstallNameTool {installNameToolProgram = Program{prgPath = \"$InstallNameToolCmd\", prgFlags = @<:@@:>@)" + fi + AC_SUBST([InstallNameToolCmdMaybe]) if test -z "$MergeObjsCmd"; then MergeObjsCmdMaybe=Nothing ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -29,6 +29,8 @@ import GHC.Toolchain.Tools.Link import GHC.Toolchain.Tools.Ar import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Nm +import GHC.Toolchain.Tools.Otool +import GHC.Toolchain.Tools.InstallNameTool import GHC.Toolchain.Tools.MergeObjs import GHC.Toolchain.Tools.Readelf import GHC.Toolchain.NormaliseTriple (normaliseTriple) @@ -47,6 +49,8 @@ data Opts = Opts , optAr :: ProgOpt , optRanlib :: ProgOpt , optNm :: ProgOpt + , optOtool :: ProgOpt + , optInstallNameTool :: ProgOpt , optReadelf :: ProgOpt , optMergeObjs :: ProgOpt , optWindres :: ProgOpt @@ -92,6 +96,8 @@ emptyOpts = Opts , optAr = po0 , optRanlib = po0 , optNm = po0 + , optOtool = po0 + , optInstallNameTool = po0 , optReadelf = po0 , optMergeObjs = po0 , optWindres = po0 @@ -117,6 +123,8 @@ _optCcLink = Lens optCcLink (\x o -> o {optCcLink=x}) _optAr = Lens optAr (\x o -> o {optAr=x}) _optRanlib = Lens optRanlib (\x o -> o {optRanlib=x}) _optNm = Lens optNm (\x o -> o {optNm=x}) +_optOtool = Lens optOtool (\x o -> o {optOtool=x}) +_optInstallNameTool = Lens optInstallNameTool (\x o -> o {optInstallNameTool=x}) _optReadelf = Lens optReadelf (\x o -> o {optReadelf=x}) _optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x}) _optWindres = Lens optWindres (\x o -> o {optWindres=x}) @@ -172,6 +180,8 @@ options = , progOpts "ar" "ar archiver" _optAr , progOpts "ranlib" "ranlib utility" _optRanlib , progOpts "nm" "nm archiver" _optNm + , progOpts "otool" "otool utility" _optOtool + , progOpts "install-name-tool" "install_name_tool utility" _optInstallNameTool , progOpts "readelf" "readelf utility" _optReadelf , progOpts "merge-objs" "linker for merging objects" _optMergeObjs , progOpts "windres" "windres utility" _optWindres @@ -407,6 +417,15 @@ mkTarget opts = do when (isNothing mergeObjs && not (arSupportsDashL ar)) $ throwE "Neither a object-merging tool (e.g. ld -r) nor an ar that supports -L is available" + -- Darwin-specific utilities + (otool, installNameTool) <- + case archOS_OS archOs of + OSDarwin -> do + otool <- findOtool (optOtool opts) + installNameTool <- findInstallNameTool (optInstallNameTool opts) + return (Just otool, Just installNameTool) + _ -> return (Nothing, Nothing) + -- Windows-specific utilities windres <- case archOS_OS archOs of @@ -448,6 +467,8 @@ mkTarget opts = do , tgtCCompilerLink = ccLink , tgtRanlib = ranlib , tgtNm = nm + , tgtOtool = otool + , tgtInstallNameTool = installNameTool , tgtMergeObjs = mergeObjs , tgtWindres = windres , tgtWordSize ===================================== utils/ghc-toolchain/ghc-toolchain.cabal ===================================== @@ -25,6 +25,8 @@ library GHC.Toolchain.Tools.Cxx, GHC.Toolchain.Tools.Cpp, GHC.Toolchain.Tools.Link, + GHC.Toolchain.Tools.Otool, + GHC.Toolchain.Tools.InstallNameTool, GHC.Toolchain.Tools.Nm, GHC.Toolchain.Tools.Ranlib, GHC.Toolchain.Tools.Readelf, ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Target.hs ===================================== @@ -14,6 +14,8 @@ import GHC.Toolchain.Tools.Ar import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Link import GHC.Toolchain.Tools.Nm +import GHC.Toolchain.Tools.Otool +import GHC.Toolchain.Tools.InstallNameTool import GHC.Toolchain.Tools.MergeObjs data WordSize = WS4 | WS8 @@ -25,8 +27,6 @@ data Endianness = LittleEndian | BigEndian -- TODO(#23674): Move the remaining relevant `settings-xxx` to Target: -- * llc command -- * opt command --- * install_name_tool --- * otool command -- -- Those are all things that are put into GHC's settings, and that might be -- different across targets @@ -66,6 +66,8 @@ data Target = Target , tgtRanlib :: Maybe Ranlib -- ^ N.B. Most @ar@ implementations will add an index by default without @ranlib@ so this is often optional , tgtNm :: Nm + , tgtOtool :: Maybe Otool + , tgtInstallNameTool :: Maybe InstallNameTool , tgtMergeObjs :: Maybe MergeObjs -- ^ We don't need a merge objects tool if we @Ar@ supports @-L@ @@ -115,6 +117,8 @@ instance Show Target where , ", tgtAr = " ++ show tgtAr , ", tgtRanlib = " ++ show tgtRanlib , ", tgtNm = " ++ show tgtNm + , ", tgtOtool = " ++ show tgtOtool + , ", tgtInstallNameTool = " ++ show tgtInstallNameTool , ", tgtMergeObjs = " ++ show tgtMergeObjs , ", tgtWindres = " ++ show tgtWindres , "}" ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/InstallNameTool.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} + +module GHC.Toolchain.Tools.InstallNameTool where + +import Control.Monad + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program + +newtype InstallNameTool = InstallNameTool { installNameToolProgram :: Program + } + deriving (Show, Read, Eq, Ord) + +findInstallNameTool :: ProgOpt -> M InstallNameTool +findInstallNameTool progOpt = checking "for install_name_tool" $ do + installNameToolProgram <- findProgram "install_name_tool utility" progOpt ["install_name_tool"] + return InstallNameTool {..} ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Otool.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} + +module GHC.Toolchain.Tools.Otool where + +import Control.Monad + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program + +newtype Otool = Otool { otoolProgram :: Program + } + deriving (Show, Read, Eq, Ord) + +findOtool :: ProgOpt -> M Otool +findOtool progOpt = checking "for otool" $ do + otoolProgram <- findProgram "otool utility" progOpt ["otool"] + return Otool {..} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/325a0c5f1a7f34c4b24d7257fd5c95e4d65c4d51...a74f7b48df8e3210a61413133e61f46e1713f21c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/325a0c5f1a7f34c4b24d7257fd5c95e4d65c4d51...a74f7b48df8e3210a61413133e61f46e1713f21c You're receiving 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 Nov 21 21:55:00 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 16:55:00 -0500 Subject: [Git][ghc/ghc][wip/T24211] distrib: Rediscover otool and install_name_tool on Darwin Message-ID: <655d27349624d_3a1d9d113969242222ba@gitlab.mail> Ben Gamari pushed to branch wip/T24211 at Glasgow Haskell Compiler / GHC Commits: dec871e9 by Ben Gamari at 2023-11-21T16:24:41-05:00 distrib: Rediscover otool and install_name_tool on Darwin In the bindist configure script we must rediscover the `otool` and `install_name_tool`s since they may be different from the build environment. Fixes #24211. - - - - - 1 changed file: - distrib/configure.ac.in Changes: ===================================== distrib/configure.ac.in ===================================== @@ -206,6 +206,18 @@ dnl Identify C++ standard library flavour and location FP_FIND_CXX_STD_LIB AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf]) +dnl ** Which otool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +OtoolCmd="$OTOOL" +AC_SUBST(OtoolCmd) + +dnl ** Which install_name_tool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +InstallNameToolCmd="$INSTALL_NAME_TOOL" +AC_SUBST(InstallNameToolCmd) + # Check that we have the same emsdk version as the one we were built with. ConfiguredEmsdkVersion=@ConfiguredEmsdkVersion@ EMSDK_VERSION("", "", ${ConfiguredEmsdkVersion}) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dec871e9140083e927df07f53dfbdc2164ee59b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dec871e9140083e927df07f53dfbdc2164ee59b4 You're receiving 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 Nov 21 21:58:21 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 21 Nov 2023 16:58:21 -0500 Subject: [Git][ghc/ghc][wip/T23674] configure: Ensure that otool and install-name-tool exist Message-ID: <655d27fdcf108_3a1d9d1139a95c222692@gitlab.mail> Ben Gamari pushed to branch wip/T23674 at Glasgow Haskell Compiler / GHC Commits: 816c2860 by Ben Gamari at 2023-11-21T16:58:11-05:00 configure: Ensure that otool and install-name-tool exist Otherwise set them to "false" to unambiguously indicate that they are unavailable. - - - - - 3 changed files: - configure.ac - distrib/configure.ac.in - m4/prep_target_file.m4 Changes: ===================================== configure.ac ===================================== @@ -489,13 +489,13 @@ AC_SUBST([StripCmd]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], [false]) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [false]) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== distrib/configure.ac.in ===================================== @@ -208,13 +208,13 @@ AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], [false]) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [false]) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== m4/prep_target_file.m4 ===================================== @@ -161,14 +161,14 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_LIST([CONF_CXX_OPTS_STAGE0]) PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE0]) - if test -z "$OtoolCmd"; then + if test "$OtoolCmd" = "false"; then OtoolCmdMaybe=Nothing else OtoolCmdMaybe="Just (Otool {otoolProgram = Program{prgPath = \"$OtoolCmd\", prgFlags = @<:@@:>@)" fi AC_SUBST([OtoolCmdMaybe]) - if test -z "$InstallNameToolCmd"; then + if test "$InstallNameToolCmd" = "false"; then InstallNameToolCmdMaybe=Nothing else InstallNameToolCmdMaybe="Just (InstallNameTool {installNameToolProgram = Program{prgPath = \"$InstallNameToolCmd\", prgFlags = @<:@@:>@)" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/816c28605e3690681e952b3e7505659f9faa20ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/816c28605e3690681e952b3e7505659f9faa20ff You're receiving 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 Nov 21 23:32:38 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 18:32:38 -0500 Subject: [Git][ghc/ghc][master] chore: Correct typo in the gitlab MR template Message-ID: <655d3e16cbfd0_3a1d9d13850738233445@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - 1 changed file: - .gitlab/merge_request_templates/Default.md Changes: ===================================== .gitlab/merge_request_templates/Default.md ===================================== @@ -30,7 +30,7 @@ label can be applied to perform additional validation checks if your MR affects unusual configuration. Once your change is ready please remove the `WIP:` tag and wait for review. If -no one has offerred review in a few days then please leave a comment mentioning +no one has offered a review in a few days then please leave a comment mentioning @triagers and apply the ~"Blocked on Review" label. [notes]: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/coding-style#comments-in-the-source-code View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9d5ae4141209d17175f784be499af09aab95eed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9d5ae4141209d17175f784be499af09aab95eed You're receiving 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 Nov 21 23:33:28 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 18:33:28 -0500 Subject: [Git][ghc/ghc][master] Improve error message when reading invalid `.target` files Message-ID: <655d3e483808b_3a1d9d13cd88782381c8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 1 changed file: - hadrian/src/Hadrian/Oracles/TextFile.hs Changes: ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -163,14 +163,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f158a8d08fd21fb0778593de3dd1426650e844d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f158a8d08fd21fb0778593de3dd1426650e844d3 You're receiving 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 Nov 21 23:33:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 18:33:56 -0500 Subject: [Git][ghc/ghc][master] users guide: Note that QuantifiedConstraints implies ExplicitForAll Message-ID: <655d3e6474e81_3a1d9d138507382414ba@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 1 changed file: - docs/users_guide/exts/quantified_constraints.rst Changes: ===================================== docs/users_guide/exts/quantified_constraints.rst ===================================== @@ -6,6 +6,7 @@ Quantified constraints .. extension:: QuantifiedConstraints :shortdesc: Allow ``forall`` quantifiers in constraints. + :implies: :extension:`ExplicitForAll` :since: 8.6.1 Allow constraints to quantify over types. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/955520c6c4f07187b6d5e4770ecf681cc78374f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/955520c6c4f07187b6d5e4770ecf681cc78374f2 You're receiving 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 Nov 21 23:35:14 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 21 Nov 2023 18:35:14 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 22 commits: Properly compute unpacked sizes for -funpack-small-strict-fields. Message-ID: <655d3eb2dc85_3a1d9d140877942416d1@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - 536364f3 by Alan Zimmerman at 2023-11-21T17:58:21+00:00 EPA: Present no longer has annotation - - - - - ea6a4190 by Alan Zimmerman at 2023-11-21T20:27:49+00:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - f45d07aa by Alan Zimmerman at 2023-11-21T21:39:04+00:00 EPA: Remove parenthesizeHsType - - - - - 9101f0ef by Alan Zimmerman at 2023-11-21T22:52:36+00:00 Summary: Patch: epa-remove-epannnotused Author: Alan Zimmerman <alan.zimm at gmail.com> Date: 2023-07-31 20:14:37 +0100 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] [2023-11-21 Tue] Failures T15242 - - - - - 1d872e75 by Alan Zimmerman at 2023-11-21T22:52:43+00:00 EPA: Remove SrcSpanAnn [2023-10-12 Thu] Failures HsDocTy T15242 - - - - - 534f7ccc by Alan Zimmerman at 2023-11-21T22:52:43+00:00 EPA: Remove SrcSpanAnn completely - - - - - cb6c340b by Alan Zimmerman at 2023-11-21T22:52:43+00:00 Clean up mkScope - - - - - c59c9488 by Alan Zimmerman at 2023-11-21T22:52:43+00:00 EPA: Clean up TC Monad Utils - - - - - 5fee8b98 by Alan Zimmerman at 2023-11-21T22:52:43+00:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - 1ef4d749 by Alan Zimmerman at 2023-11-21T22:52:44+00:00 Semigroup instances for AnnList and AnnContext - - - - - 30 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Parser/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Deriv/Generate.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36439c0d4504b61864117d8c1d39781306e148ba...1ef4d7498ce01eb647c5f590adffaec5f8ec58f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36439c0d4504b61864117d8c1d39781306e148ba...1ef4d7498ce01eb647c5f590adffaec5f8ec58f5 You're receiving 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 Nov 22 00:04:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 21 Nov 2023 19:04:54 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: chore: Correct typo in the gitlab MR template Message-ID: <655d45a65ee0d_3a1d9d15274bf0243343@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - decfa95b by Owen Shepherd at 2023-11-21T19:04:43-05:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 4ef82b1c by Samuel Thibault at 2023-11-21T19:04:47-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - 5 changed files: - .gitlab/merge_request_templates/Default.md - docs/users_guide/exts/quantified_constraints.rst - hadrian/src/Hadrian/Haskell/Cabal.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== .gitlab/merge_request_templates/Default.md ===================================== @@ -30,7 +30,7 @@ label can be applied to perform additional validation checks if your MR affects unusual configuration. Once your change is ready please remove the `WIP:` tag and wait for review. If -no one has offerred review in a few days then please leave a comment mentioning +no one has offered a review in a few days then please leave a comment mentioning @triagers and apply the ~"Blocked on Review" label. [notes]: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/coding-style#comments-in-the-source-code ===================================== docs/users_guide/exts/quantified_constraints.rst ===================================== @@ -6,6 +6,7 @@ Quantified constraints .. extension:: QuantifiedConstraints :shortdesc: Allow ``forall`` quantifiers in constraints. + :implies: :extension:`ExplicitForAll` :since: 8.6.1 Allow constraints to quantify over types. ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -75,5 +75,6 @@ cabalOsString :: String -> String cabalOsString "mingw32" = "windows" cabalOsString "darwin" = "osx" cabalOsString "solaris2" = "solaris" +cabalOsString "gnu" = "hurd" cabalOsString other = other ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -163,14 +163,23 @@ textFileOracle = do putVerbose $ "| TargetFile oracle: reading " ++ quote file ++ "..." mtarget <- readMaybe <$> readFile' file case mtarget of - Nothing -> error $ "Failed to read a Toolchain.Target from " ++ quote file + Nothing -> error $ unlines ["Error parsing a Toolchain.Target from " ++ quote file, + "Perhaps the `.target` file is out of date.", + "Try re-running `./configure`." + ] + Just target -> return (target :: Toolchain.Target) void $ addOracleCache $ \(TargetFile file) -> tf file -- Orphan instances for (ShakeValue Toolchain.Target) instance Binary Toolchain.Target where - put = put . show - get = read <$> get + put = put . show + get = fromMaybe (error $ unlines ["Error parsing a toolchain `.target` file from its binary representation in hadrian.", + "This is likely caused by a stale hadrian/shake cache", + "which has saved an old `.target` file that can't be parsed", + "into a more recent `Toolchain.Target`. It is recommended to reset", + "by running `./hadrian/build clean`." + ]) . readMaybe <$> get instance Hashable Toolchain.Target where hashWithSalt s = hashWithSalt s . show ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -44,11 +44,11 @@ module Data.List.NonEmpty ( , (<|), cons -- :: a -> NonEmpty a -> NonEmpty a , uncons -- :: NonEmpty a -> (a, Maybe (NonEmpty a)) , unfoldr -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b - , sort -- :: NonEmpty a -> NonEmpty a + , sort -- :: Ord a => NonEmpty a -> NonEmpty a , reverse -- :: NonEmpty a -> NonEmpty a - , inits -- :: Foldable f => f a -> NonEmpty a + , inits -- :: Foldable f => f a -> NonEmpty [a] , inits1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) - , tails -- :: Foldable f => f a -> NonEmpty a + , tails -- :: Foldable f => f a -> NonEmpty [a] , tails1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) , append -- :: NonEmpty a -> NonEmpty a -> NonEmpty a , appendList -- :: NonEmpty a -> [a] -> NonEmpty a @@ -57,31 +57,31 @@ module Data.List.NonEmpty ( , iterate -- :: (a -> a) -> a -> NonEmpty a , repeat -- :: a -> NonEmpty a , cycle -- :: NonEmpty a -> NonEmpty a - , unfold -- :: (a -> (b, Maybe a) -> a -> NonEmpty b + , unfold -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b , insert -- :: (Foldable f, Ord a) => a -> f a -> NonEmpty a , some1 -- :: Alternative f => f a -> f (NonEmpty a) -- * Extracting sublists , take -- :: Int -> NonEmpty a -> [a] , drop -- :: Int -> NonEmpty a -> [a] , splitAt -- :: Int -> NonEmpty a -> ([a], [a]) - , takeWhile -- :: Int -> NonEmpty a -> [a] - , dropWhile -- :: Int -> NonEmpty a -> [a] - , span -- :: Int -> NonEmpty a -> ([a],[a]) - , break -- :: Int -> NonEmpty a -> ([a],[a]) + , takeWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , dropWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , span -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) + , break -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) , filter -- :: (a -> Bool) -> NonEmpty a -> [a] , partition -- :: (a -> Bool) -> NonEmpty a -> ([a],[a]) - , group -- :: Foldable f => Eq a => f a -> [NonEmpty a] + , group -- :: (Foldable f, Eq a) => f a -> [NonEmpty a] , groupBy -- :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] , groupWith -- :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] - , groupAllWith -- :: (Foldable f, Ord b) => (a -> b) -> f a -> [NonEmpty a] + , groupAllWith -- :: Ord b => (a -> b) -> [a] -> [NonEmpty a] , group1 -- :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) - , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , permutations - , permutations1 + , groupWith1 -- :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , groupAllWith1 -- :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , permutations -- :: [a] -> NonEmpty [a] + , permutations1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) -- * Sublist predicates - , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool + , isPrefixOf -- :: Eq a => [a] -> NonEmpty a -> Bool -- * \"Set\" operations , nub -- :: Eq a => NonEmpty a -> NonEmpty a , nubBy -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a @@ -90,12 +90,12 @@ module Data.List.NonEmpty ( -- * Zipping and unzipping streams , zip -- :: NonEmpty a -> NonEmpty b -> NonEmpty (a,b) , zipWith -- :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c - , unzip -- :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) + , unzip -- :: Functor f => f (a,b) -> (f a, f b) -- * Converting to and from a list , fromList -- :: [a] -> NonEmpty a , toList -- :: NonEmpty a -> [a] , nonEmpty -- :: [a] -> Maybe (NonEmpty a) - , xor -- :: NonEmpty a -> Bool + , xor -- :: NonEmpty Bool -> Bool ) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58857f250e9c55f0eb1434850e70b4b456d6348d...4ef82b1c9f5a86d8aa5b5e2bc22e4d19e47fee48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58857f250e9c55f0eb1434850e70b4b456d6348d...4ef82b1c9f5a86d8aa5b5e2bc22e4d19e47fee48 You're receiving 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 Nov 22 05:46:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 00:46:42 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: fix: Change type signatures in NonEmpty export comments to reflect reality Message-ID: <655d95c222541_3a1d9d1d1e5a60263250@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ffc9130b by Owen Shepherd at 2023-11-22T00:46:33-05:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 6e2b0531 by Samuel Thibault at 2023-11-22T00:46:37-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - 2 changed files: - hadrian/src/Hadrian/Haskell/Cabal.hs - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -75,5 +75,6 @@ cabalOsString :: String -> String cabalOsString "mingw32" = "windows" cabalOsString "darwin" = "osx" cabalOsString "solaris2" = "solaris" +cabalOsString "gnu" = "hurd" cabalOsString other = other ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -44,11 +44,11 @@ module Data.List.NonEmpty ( , (<|), cons -- :: a -> NonEmpty a -> NonEmpty a , uncons -- :: NonEmpty a -> (a, Maybe (NonEmpty a)) , unfoldr -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b - , sort -- :: NonEmpty a -> NonEmpty a + , sort -- :: Ord a => NonEmpty a -> NonEmpty a , reverse -- :: NonEmpty a -> NonEmpty a - , inits -- :: Foldable f => f a -> NonEmpty a + , inits -- :: Foldable f => f a -> NonEmpty [a] , inits1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) - , tails -- :: Foldable f => f a -> NonEmpty a + , tails -- :: Foldable f => f a -> NonEmpty [a] , tails1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) , append -- :: NonEmpty a -> NonEmpty a -> NonEmpty a , appendList -- :: NonEmpty a -> [a] -> NonEmpty a @@ -57,31 +57,31 @@ module Data.List.NonEmpty ( , iterate -- :: (a -> a) -> a -> NonEmpty a , repeat -- :: a -> NonEmpty a , cycle -- :: NonEmpty a -> NonEmpty a - , unfold -- :: (a -> (b, Maybe a) -> a -> NonEmpty b + , unfold -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b , insert -- :: (Foldable f, Ord a) => a -> f a -> NonEmpty a , some1 -- :: Alternative f => f a -> f (NonEmpty a) -- * Extracting sublists , take -- :: Int -> NonEmpty a -> [a] , drop -- :: Int -> NonEmpty a -> [a] , splitAt -- :: Int -> NonEmpty a -> ([a], [a]) - , takeWhile -- :: Int -> NonEmpty a -> [a] - , dropWhile -- :: Int -> NonEmpty a -> [a] - , span -- :: Int -> NonEmpty a -> ([a],[a]) - , break -- :: Int -> NonEmpty a -> ([a],[a]) + , takeWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , dropWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , span -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) + , break -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) , filter -- :: (a -> Bool) -> NonEmpty a -> [a] , partition -- :: (a -> Bool) -> NonEmpty a -> ([a],[a]) - , group -- :: Foldable f => Eq a => f a -> [NonEmpty a] + , group -- :: (Foldable f, Eq a) => f a -> [NonEmpty a] , groupBy -- :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] , groupWith -- :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] - , groupAllWith -- :: (Foldable f, Ord b) => (a -> b) -> f a -> [NonEmpty a] + , groupAllWith -- :: Ord b => (a -> b) -> [a] -> [NonEmpty a] , group1 -- :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) - , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , permutations - , permutations1 + , groupWith1 -- :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , groupAllWith1 -- :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , permutations -- :: [a] -> NonEmpty [a] + , permutations1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) -- * Sublist predicates - , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool + , isPrefixOf -- :: Eq a => [a] -> NonEmpty a -> Bool -- * \"Set\" operations , nub -- :: Eq a => NonEmpty a -> NonEmpty a , nubBy -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a @@ -90,12 +90,12 @@ module Data.List.NonEmpty ( -- * Zipping and unzipping streams , zip -- :: NonEmpty a -> NonEmpty b -> NonEmpty (a,b) , zipWith -- :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c - , unzip -- :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) + , unzip -- :: Functor f => f (a,b) -> (f a, f b) -- * Converting to and from a list , fromList -- :: [a] -> NonEmpty a , toList -- :: NonEmpty a -> [a] , nonEmpty -- :: [a] -> Maybe (NonEmpty a) - , xor -- :: NonEmpty a -> Bool + , xor -- :: NonEmpty Bool -> Bool ) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ef82b1c9f5a86d8aa5b5e2bc22e4d19e47fee48...6e2b05313c4119649f71f666af2b18ce6f2825b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ef82b1c9f5a86d8aa5b5e2bc22e4d19e47fee48...6e2b05313c4119649f71f666af2b18ce6f2825b5 You're receiving 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 Nov 22 10:37:44 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 05:37:44 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: fix: Change type signatures in NonEmpty export comments to reflect reality Message-ID: <655dd9f83cd9c_3a1d9d23de302830709c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 55ec8ec1 by Samuel Thibault at 2023-11-22T05:37:33-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - 8306ea93 by Alan Zimmerman at 2023-11-22T05:37:34-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 8 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - hadrian/src/Hadrian/Haskell/Cabal.hs - libraries/base/src/Data/List/NonEmpty.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -416,7 +416,7 @@ type instance XXPragE (GhcPass _) = DataConCantHappen type instance XCDotFieldOcc (GhcPass _) = EpAnn AnnFieldLabel type instance XXDotFieldOcc (GhcPass _) = DataConCantHappen -type instance XPresent (GhcPass _) = EpAnn [AddEpAnn] +type instance XPresent (GhcPass _) = NoExtField type instance XMissing GhcPs = EpAnn EpaLocation type instance XMissing GhcRn = NoExtField ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -666,7 +666,7 @@ mkLHsTupleExpr :: [LHsExpr (GhcPass p)] -> XExplicitTuple (GhcPass p) -- Makes a pre-typechecker boxed tuple, deals with 1 case mkLHsTupleExpr [e] _ = e mkLHsTupleExpr es ext - = noLocA $ ExplicitTuple ext (map (Present noAnn) es) Boxed + = noLocA $ ExplicitTuple ext (map (Present noExtField) es) Boxed mkLHsVarTuple :: IsSrcSpanAnn p a => [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3151,7 +3151,7 @@ mkSumOrTupleExpr l boxity (Tuple es) anns = do where toTupArg :: Either (EpAnn EpaLocation) (LHsExpr GhcPs) -> HsTupArg GhcPs toTupArg (Left ann) = missingTupArg ann - toTupArg (Right a) = Present noAnn a + toTupArg (Right a) = Present noExtField a -- Sum -- mkSumOrTupleExpr l Unboxed (Sum alt arity e) = ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -1037,7 +1037,7 @@ tcPatToExpr args pat = go pat ; return $ ExplicitList noExtField exprs } go1 (TuplePat _ pats box) = do { exprs <- mapM go pats ; return $ ExplicitTuple noExtField - (map (Present noAnn) exprs) box } + (map (Present noExtField) exprs) box } go1 (SumPat _ pat alt arity) = do { expr <- go1 (unLoc pat) ; return $ ExplicitSum noExtField alt arity (noLocA expr) ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1218,7 +1218,7 @@ cvtDD (FromThenToR x y z) = do { x' <- cvtl x; y' <- cvtl y; z' <- cvtl z; retur cvt_tup :: [Maybe Exp] -> Boxity -> CvtM (HsExpr GhcPs) cvt_tup es boxity = do { let cvtl_maybe Nothing = return (missingTupArg noAnn) - cvtl_maybe (Just e) = fmap (Present noAnn) (cvtl e) + cvtl_maybe (Just e) = fmap (Present noExtField) (cvtl e) ; es' <- mapM cvtl_maybe es ; return $ ExplicitTuple noAnn ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -75,5 +75,6 @@ cabalOsString :: String -> String cabalOsString "mingw32" = "windows" cabalOsString "darwin" = "osx" cabalOsString "solaris2" = "solaris" +cabalOsString "gnu" = "hurd" cabalOsString other = other ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -44,11 +44,11 @@ module Data.List.NonEmpty ( , (<|), cons -- :: a -> NonEmpty a -> NonEmpty a , uncons -- :: NonEmpty a -> (a, Maybe (NonEmpty a)) , unfoldr -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b - , sort -- :: NonEmpty a -> NonEmpty a + , sort -- :: Ord a => NonEmpty a -> NonEmpty a , reverse -- :: NonEmpty a -> NonEmpty a - , inits -- :: Foldable f => f a -> NonEmpty a + , inits -- :: Foldable f => f a -> NonEmpty [a] , inits1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) - , tails -- :: Foldable f => f a -> NonEmpty a + , tails -- :: Foldable f => f a -> NonEmpty [a] , tails1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) , append -- :: NonEmpty a -> NonEmpty a -> NonEmpty a , appendList -- :: NonEmpty a -> [a] -> NonEmpty a @@ -57,31 +57,31 @@ module Data.List.NonEmpty ( , iterate -- :: (a -> a) -> a -> NonEmpty a , repeat -- :: a -> NonEmpty a , cycle -- :: NonEmpty a -> NonEmpty a - , unfold -- :: (a -> (b, Maybe a) -> a -> NonEmpty b + , unfold -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b , insert -- :: (Foldable f, Ord a) => a -> f a -> NonEmpty a , some1 -- :: Alternative f => f a -> f (NonEmpty a) -- * Extracting sublists , take -- :: Int -> NonEmpty a -> [a] , drop -- :: Int -> NonEmpty a -> [a] , splitAt -- :: Int -> NonEmpty a -> ([a], [a]) - , takeWhile -- :: Int -> NonEmpty a -> [a] - , dropWhile -- :: Int -> NonEmpty a -> [a] - , span -- :: Int -> NonEmpty a -> ([a],[a]) - , break -- :: Int -> NonEmpty a -> ([a],[a]) + , takeWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , dropWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , span -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) + , break -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) , filter -- :: (a -> Bool) -> NonEmpty a -> [a] , partition -- :: (a -> Bool) -> NonEmpty a -> ([a],[a]) - , group -- :: Foldable f => Eq a => f a -> [NonEmpty a] + , group -- :: (Foldable f, Eq a) => f a -> [NonEmpty a] , groupBy -- :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] , groupWith -- :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] - , groupAllWith -- :: (Foldable f, Ord b) => (a -> b) -> f a -> [NonEmpty a] + , groupAllWith -- :: Ord b => (a -> b) -> [a] -> [NonEmpty a] , group1 -- :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) - , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , permutations - , permutations1 + , groupWith1 -- :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , groupAllWith1 -- :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , permutations -- :: [a] -> NonEmpty [a] + , permutations1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) -- * Sublist predicates - , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool + , isPrefixOf -- :: Eq a => [a] -> NonEmpty a -> Bool -- * \"Set\" operations , nub -- :: Eq a => NonEmpty a -> NonEmpty a , nubBy -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a @@ -90,12 +90,12 @@ module Data.List.NonEmpty ( -- * Zipping and unzipping streams , zip -- :: NonEmpty a -> NonEmpty b -> NonEmpty (a,b) , zipWith -- :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c - , unzip -- :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) + , unzip -- :: Functor f => f (a,b) -> (f a, f b) -- * Converting to and from a list , fromList -- :: [a] -> NonEmpty a , toList -- :: NonEmpty a -> [a] , nonEmpty -- :: [a] -> Maybe (NonEmpty a) - , xor -- :: NonEmpty a -> Bool + , xor -- :: NonEmpty Bool -> Bool ) where ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3431,10 +3431,10 @@ instance ExactPrint (DotFieldOcc GhcPs) where -- --------------------------------------------------------------------- instance ExactPrint (HsTupArg GhcPs) where - getAnnotationEntry (Present an _) = fromAnn an + getAnnotationEntry (Present _ _) = NoEntryVal getAnnotationEntry (Missing an) = fromAnn an - setAnnotationAnchor (Present an a) anc ts cs = Present (setAnchorEpa an anc ts cs) a + setAnnotationAnchor (Present a b) _ _ _ = Present a b setAnnotationAnchor (Missing an) anc ts cs = Missing (setAnchorEpa an anc ts cs) exact (Present a e) = Present a <$> markAnnotated e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e2b05313c4119649f71f666af2b18ce6f2825b5...8306ea93da82677c5af37f9cb5203bc1a84cd50b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e2b05313c4119649f71f666af2b18ce6f2825b5...8306ea93da82677c5af37f9cb5203bc1a84cd50b You're receiving 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 Nov 22 13:48:26 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 08:48:26 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix the platform string for GNU/Hurd Message-ID: <655e06aa9fa2b_3a1d9d283f5a84336124@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d0b446f1 by Samuel Thibault at 2023-11-22T08:48:18-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - ff21810c by Alan Zimmerman at 2023-11-22T08:48:18-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 7 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - hadrian/src/Hadrian/Haskell/Cabal.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -416,7 +416,7 @@ type instance XXPragE (GhcPass _) = DataConCantHappen type instance XCDotFieldOcc (GhcPass _) = EpAnn AnnFieldLabel type instance XXDotFieldOcc (GhcPass _) = DataConCantHappen -type instance XPresent (GhcPass _) = EpAnn [AddEpAnn] +type instance XPresent (GhcPass _) = NoExtField type instance XMissing GhcPs = EpAnn EpaLocation type instance XMissing GhcRn = NoExtField ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -666,7 +666,7 @@ mkLHsTupleExpr :: [LHsExpr (GhcPass p)] -> XExplicitTuple (GhcPass p) -- Makes a pre-typechecker boxed tuple, deals with 1 case mkLHsTupleExpr [e] _ = e mkLHsTupleExpr es ext - = noLocA $ ExplicitTuple ext (map (Present noAnn) es) Boxed + = noLocA $ ExplicitTuple ext (map (Present noExtField) es) Boxed mkLHsVarTuple :: IsSrcSpanAnn p a => [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3151,7 +3151,7 @@ mkSumOrTupleExpr l boxity (Tuple es) anns = do where toTupArg :: Either (EpAnn EpaLocation) (LHsExpr GhcPs) -> HsTupArg GhcPs toTupArg (Left ann) = missingTupArg ann - toTupArg (Right a) = Present noAnn a + toTupArg (Right a) = Present noExtField a -- Sum -- mkSumOrTupleExpr l Unboxed (Sum alt arity e) = ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -1037,7 +1037,7 @@ tcPatToExpr args pat = go pat ; return $ ExplicitList noExtField exprs } go1 (TuplePat _ pats box) = do { exprs <- mapM go pats ; return $ ExplicitTuple noExtField - (map (Present noAnn) exprs) box } + (map (Present noExtField) exprs) box } go1 (SumPat _ pat alt arity) = do { expr <- go1 (unLoc pat) ; return $ ExplicitSum noExtField alt arity (noLocA expr) ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1218,7 +1218,7 @@ cvtDD (FromThenToR x y z) = do { x' <- cvtl x; y' <- cvtl y; z' <- cvtl z; retur cvt_tup :: [Maybe Exp] -> Boxity -> CvtM (HsExpr GhcPs) cvt_tup es boxity = do { let cvtl_maybe Nothing = return (missingTupArg noAnn) - cvtl_maybe (Just e) = fmap (Present noAnn) (cvtl e) + cvtl_maybe (Just e) = fmap (Present noExtField) (cvtl e) ; es' <- mapM cvtl_maybe es ; return $ ExplicitTuple noAnn ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -75,5 +75,6 @@ cabalOsString :: String -> String cabalOsString "mingw32" = "windows" cabalOsString "darwin" = "osx" cabalOsString "solaris2" = "solaris" +cabalOsString "gnu" = "hurd" cabalOsString other = other ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3431,10 +3431,10 @@ instance ExactPrint (DotFieldOcc GhcPs) where -- --------------------------------------------------------------------- instance ExactPrint (HsTupArg GhcPs) where - getAnnotationEntry (Present an _) = fromAnn an + getAnnotationEntry (Present _ _) = NoEntryVal getAnnotationEntry (Missing an) = fromAnn an - setAnnotationAnchor (Present an a) anc ts cs = Present (setAnchorEpa an anc ts cs) a + setAnnotationAnchor (Present a b) _ _ _ = Present a b setAnnotationAnchor (Missing an) anc ts cs = Missing (setAnchorEpa an anc ts cs) exact (Present a e) = Present a <$> markAnnotated e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8306ea93da82677c5af37f9cb5203bc1a84cd50b...ff21810cf3e509587cbdb78718e44eaee285b854 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8306ea93da82677c5af37f9cb5203bc1a84cd50b...ff21810cf3e509587cbdb78718e44eaee285b854 You're receiving 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 Nov 22 13:54:42 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 22 Nov 2023 08:54:42 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Adjust default thresholds slightly Message-ID: <655e082216121_3a1d9d2853791034315@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: d8b35e38 by Simon Peyton Jones at 2023-11-22T13:54:14+00:00 Adjust default thresholds slightly - - - - - 2 changed files: - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -263,11 +263,11 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance = case cont_info of BoringCtxt -> 0 DiscArgCtxt -> 0 - RuleArgCtxt -> 0 + RuleArgCtxt -> ret_discount CaseCtxt -> ret_discount ValAppCtxt -> ret_discount RhsCtxt {} -> 40 `min` ret_discount - -- For RhsCtxt I suppose that exposing a data con is good in general + -- For RhsCtxt I suppose that exposing a data con is good in general; -- although 40 seems very arbitrary -- -- `min` thresholding: res_discount can be very large when a ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -206,7 +206,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- inline into Csg.calc (The unfolding for sqr never makes it -- into the interface file.) - , unfoldingUseThreshold = 75 + , unfoldingUseThreshold = 80 -- Adjusted 90 -> 80 when adding discounts for free variables which -- generally make things more likely to inline. Reducing the threshold -- eliminates some undesirable compile-time regressions (e.g. T10412a) @@ -214,7 +214,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- Previously: adjusted upwards in #18282, when I reduced -- the result discount for constructors. - , unfoldingFunAppDiscount = 45 + , unfoldingFunAppDiscount = 30 -- Be fairly keen to inline a function if that means -- we'll be able to pick the right method from a dictionary View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d8b35e381b843c217ae2c07fe6a134eb9fbbcf48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d8b35e381b843c217ae2c07fe6a134eb9fbbcf48 You're receiving 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 Nov 22 14:07:36 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 22 Nov 2023 09:07:36 -0500 Subject: [Git][ghc/ghc][wip/T23674] 2 commits: ghc-toolchain: Support otool and install_name_tool Message-ID: <655e0b28e5300_3a1d9d28f5fd843454fa@gitlab.mail> Ben Gamari pushed to branch wip/T23674 at Glasgow Haskell Compiler / GHC Commits: 915c56b1 by Ben Gamari at 2023-11-22T09:07:24-05:00 ghc-toolchain: Support otool and install_name_tool Partially addresses #23674. - - - - - fd6b1407 by Ben Gamari at 2023-11-22T09:07:24-05:00 configure: Ensure that otool and install-name-tool exist Otherwise set them to "false" to unambiguously indicate that they are unavailable. - - - - - 10 changed files: - configure.ac - distrib/configure.ac.in - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - m4/prep_target_file.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/ghc-toolchain.cabal - utils/ghc-toolchain/src/GHC/Toolchain/Target.hs - + utils/ghc-toolchain/src/GHC/Toolchain/Tools/InstallNameTool.hs - + utils/ghc-toolchain/src/GHC/Toolchain/Tools/Otool.hs Changes: ===================================== configure.ac ===================================== @@ -489,13 +489,13 @@ AC_SUBST([StripCmd]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], [false]) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [false]) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== distrib/configure.ac.in ===================================== @@ -208,13 +208,13 @@ AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf]) dnl ** Which otool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +AC_CHECK_TARGET_TOOL([OTOOL], [otool], [false]) OtoolCmd="$OTOOL" AC_SUBST(OtoolCmd) dnl ** Which install_name_tool to use on macOS dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [false]) InstallNameToolCmd="$INSTALL_NAME_TOOL" AC_SUBST(InstallNameToolCmd) ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -35,6 +35,8 @@ Target , tgtRanlib = Nothing , tgtNm = Nm {nmProgram = Program {prgPath = "", prgFlags = []}} +, tgtOtool = Nothing +, tgtInstallNameTool = Nothing , tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@LD_STAGE0@", prgFlags = ["-r"]}, mergeObjsSupportsResponseFiles = False}) , tgtWindres = Nothing } ===================================== hadrian/cfg/default.target.in ===================================== @@ -35,6 +35,8 @@ Target , tgtRanlib = Just (Ranlib {ranlibProgram = Program {prgPath = "@RanlibCmd@", prgFlags = []}}) , tgtNm = Nm {nmProgram = Program {prgPath = "@NmCmd@", prgFlags = []}} +, tgtOtool = @OtoolCmdMaybe@ +, tgtInstallNameTool = @InstallNameToolCmdMaybe@ , tgtMergeObjs = @MergeObjsCmdMaybe@ , tgtWindres = @WindresCmdMaybeProg@ } ===================================== m4/prep_target_file.m4 ===================================== @@ -161,6 +161,19 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_LIST([CONF_CXX_OPTS_STAGE0]) PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE0]) + if test "$OtoolCmd" = "false"; then + OtoolCmdMaybe=Nothing + else + OtoolCmdMaybe="Just (Otool {otoolProgram = Program{prgPath = \"$OtoolCmd\", prgFlags = @<:@@:>@)" + fi + AC_SUBST([OtoolCmdMaybe]) + + if test "$InstallNameToolCmd" = "false"; then + InstallNameToolCmdMaybe=Nothing + else + InstallNameToolCmdMaybe="Just (InstallNameTool {installNameToolProgram = Program{prgPath = \"$InstallNameToolCmd\", prgFlags = @<:@@:>@)" + fi + AC_SUBST([InstallNameToolCmdMaybe]) if test -z "$MergeObjsCmd"; then MergeObjsCmdMaybe=Nothing ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -29,6 +29,8 @@ import GHC.Toolchain.Tools.Link import GHC.Toolchain.Tools.Ar import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Nm +import GHC.Toolchain.Tools.Otool +import GHC.Toolchain.Tools.InstallNameTool import GHC.Toolchain.Tools.MergeObjs import GHC.Toolchain.Tools.Readelf import GHC.Toolchain.NormaliseTriple (normaliseTriple) @@ -47,6 +49,8 @@ data Opts = Opts , optAr :: ProgOpt , optRanlib :: ProgOpt , optNm :: ProgOpt + , optOtool :: ProgOpt + , optInstallNameTool :: ProgOpt , optReadelf :: ProgOpt , optMergeObjs :: ProgOpt , optWindres :: ProgOpt @@ -92,6 +96,8 @@ emptyOpts = Opts , optAr = po0 , optRanlib = po0 , optNm = po0 + , optOtool = po0 + , optInstallNameTool = po0 , optReadelf = po0 , optMergeObjs = po0 , optWindres = po0 @@ -107,7 +113,8 @@ emptyOpts = Opts po0 = emptyProgOpt _optCc, _optCxx, _optCpp, _optHsCpp, _optCcLink, _optAr, _optRanlib, _optNm, - _optReadelf, _optMergeObjs, _optWindres, _optLd + _optOtool, _optInstallNameTool, _optReadelf, _optMergeObjs, _optWindres, + _optLd :: Lens Opts ProgOpt _optCc = Lens optCc (\x o -> o {optCc=x}) _optCxx = Lens optCxx (\x o -> o {optCxx=x}) @@ -117,6 +124,8 @@ _optCcLink = Lens optCcLink (\x o -> o {optCcLink=x}) _optAr = Lens optAr (\x o -> o {optAr=x}) _optRanlib = Lens optRanlib (\x o -> o {optRanlib=x}) _optNm = Lens optNm (\x o -> o {optNm=x}) +_optOtool = Lens optOtool (\x o -> o {optOtool=x}) +_optInstallNameTool = Lens optInstallNameTool (\x o -> o {optInstallNameTool=x}) _optReadelf = Lens optReadelf (\x o -> o {optReadelf=x}) _optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x}) _optWindres = Lens optWindres (\x o -> o {optWindres=x}) @@ -172,6 +181,8 @@ options = , progOpts "ar" "ar archiver" _optAr , progOpts "ranlib" "ranlib utility" _optRanlib , progOpts "nm" "nm archiver" _optNm + , progOpts "otool" "otool utility" _optOtool + , progOpts "install-name-tool" "install_name_tool utility" _optInstallNameTool , progOpts "readelf" "readelf utility" _optReadelf , progOpts "merge-objs" "linker for merging objects" _optMergeObjs , progOpts "windres" "windres utility" _optWindres @@ -407,6 +418,15 @@ mkTarget opts = do when (isNothing mergeObjs && not (arSupportsDashL ar)) $ throwE "Neither a object-merging tool (e.g. ld -r) nor an ar that supports -L is available" + -- Darwin-specific utilities + (otool, installNameTool) <- + case archOS_OS archOs of + OSDarwin -> do + otool <- findOtool (optOtool opts) + installNameTool <- findInstallNameTool (optInstallNameTool opts) + return (Just otool, Just installNameTool) + _ -> return (Nothing, Nothing) + -- Windows-specific utilities windres <- case archOS_OS archOs of @@ -448,6 +468,8 @@ mkTarget opts = do , tgtCCompilerLink = ccLink , tgtRanlib = ranlib , tgtNm = nm + , tgtOtool = otool + , tgtInstallNameTool = installNameTool , tgtMergeObjs = mergeObjs , tgtWindres = windres , tgtWordSize ===================================== utils/ghc-toolchain/ghc-toolchain.cabal ===================================== @@ -25,6 +25,8 @@ library GHC.Toolchain.Tools.Cxx, GHC.Toolchain.Tools.Cpp, GHC.Toolchain.Tools.Link, + GHC.Toolchain.Tools.Otool, + GHC.Toolchain.Tools.InstallNameTool, GHC.Toolchain.Tools.Nm, GHC.Toolchain.Tools.Ranlib, GHC.Toolchain.Tools.Readelf, ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Target.hs ===================================== @@ -14,6 +14,8 @@ import GHC.Toolchain.Tools.Ar import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Link import GHC.Toolchain.Tools.Nm +import GHC.Toolchain.Tools.Otool +import GHC.Toolchain.Tools.InstallNameTool import GHC.Toolchain.Tools.MergeObjs data WordSize = WS4 | WS8 @@ -25,8 +27,6 @@ data Endianness = LittleEndian | BigEndian -- TODO(#23674): Move the remaining relevant `settings-xxx` to Target: -- * llc command -- * opt command --- * install_name_tool --- * otool command -- -- Those are all things that are put into GHC's settings, and that might be -- different across targets @@ -66,6 +66,8 @@ data Target = Target , tgtRanlib :: Maybe Ranlib -- ^ N.B. Most @ar@ implementations will add an index by default without @ranlib@ so this is often optional , tgtNm :: Nm + , tgtOtool :: Maybe Otool + , tgtInstallNameTool :: Maybe InstallNameTool , tgtMergeObjs :: Maybe MergeObjs -- ^ We don't need a merge objects tool if we @Ar@ supports @-L@ @@ -115,6 +117,8 @@ instance Show Target where , ", tgtAr = " ++ show tgtAr , ", tgtRanlib = " ++ show tgtRanlib , ", tgtNm = " ++ show tgtNm + , ", tgtOtool = " ++ show tgtOtool + , ", tgtInstallNameTool = " ++ show tgtInstallNameTool , ", tgtMergeObjs = " ++ show tgtMergeObjs , ", tgtWindres = " ++ show tgtWindres , "}" ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/InstallNameTool.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} + +module GHC.Toolchain.Tools.InstallNameTool where + +import Control.Monad + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program + +newtype InstallNameTool = InstallNameTool { installNameToolProgram :: Program + } + deriving (Show, Read, Eq, Ord) + +findInstallNameTool :: ProgOpt -> M InstallNameTool +findInstallNameTool progOpt = checking "for install_name_tool" $ do + installNameToolProgram <- findProgram "install_name_tool utility" progOpt ["install_name_tool"] + return InstallNameTool {..} ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Otool.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} + +module GHC.Toolchain.Tools.Otool where + +import Control.Monad + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program + +newtype Otool = Otool { otoolProgram :: Program + } + deriving (Show, Read, Eq, Ord) + +findOtool :: ProgOpt -> M Otool +findOtool progOpt = checking "for otool" $ do + otoolProgram <- findProgram "otool utility" progOpt ["otool"] + return Otool {..} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/816c28605e3690681e952b3e7505659f9faa20ff...fd6b14077cb30fe1d55e7f3ebc7e7270f41a7450 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/816c28605e3690681e952b3e7505659f9faa20ff...fd6b14077cb30fe1d55e7f3ebc7e7270f41a7450 You're receiving 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 Nov 22 14:24:50 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Wed, 22 Nov 2023 09:24:50 -0500 Subject: [Git][ghc/ghc][wip/add-ddump-specialisations] 3 commits: rts/eventlog: Fix off-by-one in assertion Message-ID: <655e0f32e614d_3a1d9d292bbeec3494ab@gitlab.mail> Finley McIlwaine pushed to branch wip/add-ddump-specialisations at Glasgow Haskell Compiler / GHC Commits: 96c1c4f8 by Ben Gamari at 2023-11-22T06:24:12-08:00 rts/eventlog: Fix off-by-one in assertion Previously we failed to account for the NULL terminator `postString` asserted that there is enough room in the buffer for the string. - - - - - 2f1ba11d by Ben Gamari at 2023-11-22T06:24:23-08:00 rts/eventlog: Honor result of ensureRoomForVariableEvent is Previously we would keep plugging along, even if isn't enough room for the event. - - - - - bc361d2f by Ben Gamari at 2023-11-22T06:24:32-08:00 rts/eventlog: Avoid truncating event sizes Previously ensureRoomForVariableEvent would truncate the desired size to 16-bits, resulting in #24197. Fixes #24197. - - - - - 2 changed files: - rts/eventlog/EventLog.c - rts/include/Stg.h Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -136,12 +136,12 @@ static void postBlockMarker(EventsBuf *eb); static void closeBlockMarker(EventsBuf *ebuf); static StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum); -static StgBool hasRoomForVariableEvent(EventsBuf *eb, uint32_t payload_bytes); +static StgBool hasRoomForVariableEvent(EventsBuf *eb, StgWord payload_bytes); static void freeEventLoggingBuffer(void); static void ensureRoomForEvent(EventsBuf *eb, EventTypeNum tag); -static int ensureRoomForVariableEvent(EventsBuf *eb, StgWord16 size); +static int ensureRoomForVariableEvent(EventsBuf *eb, StgWord size); static inline void postWord8(EventsBuf *eb, StgWord8 i) { @@ -180,7 +180,7 @@ static inline void postString(EventsBuf *eb, const char *buf) { if (buf) { const int len = strlen(buf); - ASSERT(eb->begin + eb->size > eb->pos + len); + ASSERT(eb->begin + eb->size > eb->pos + len + 1); memcpy(eb->pos, buf, len); eb->pos += len; } @@ -1218,7 +1218,7 @@ void postHeapProfBegin(StgWord8 profile_id) 1+8+4 + modSelector_len + descrSelector_len + typeSelector_len + ccSelector_len + ccsSelector_len + retainerSelector_len + bioSelector_len + 7; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_HEAP_PROF_BEGIN); postPayloadSize(&eventBuf, len); postWord8(&eventBuf, profile_id); @@ -1270,7 +1270,7 @@ void postHeapProfSampleString(StgWord8 profile_id, ACQUIRE_LOCK(&eventBufMutex); StgWord label_len = strlen(label); StgWord len = 1+8+label_len+1; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_HEAP_PROF_SAMPLE_STRING); postPayloadSize(&eventBuf, len); postWord8(&eventBuf, profile_id); @@ -1291,7 +1291,7 @@ void postHeapProfCostCentre(StgWord32 ccID, StgWord module_len = strlen(module); StgWord srcloc_len = strlen(srcloc); StgWord len = 4+label_len+module_len+srcloc_len+3+1; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_HEAP_PROF_COST_CENTRE); postPayloadSize(&eventBuf, len); postWord32(&eventBuf, ccID); @@ -1314,7 +1314,7 @@ void postHeapProfSampleCostCentre(StgWord8 profile_id, if (depth > 0xff) depth = 0xff; StgWord len = 1+8+1+depth*4; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_HEAP_PROF_SAMPLE_COST_CENTRE); postPayloadSize(&eventBuf, len); postWord8(&eventBuf, profile_id); @@ -1340,7 +1340,7 @@ void postProfSampleCostCentre(Capability *cap, if (depth > 0xff) depth = 0xff; StgWord len = 4+8+1+depth*4; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_PROF_SAMPLE_COST_CENTRE); postPayloadSize(&eventBuf, len); postWord32(&eventBuf, cap->no); @@ -1370,7 +1370,7 @@ void postProfBegin(void) static void postTickyCounterDef(EventsBuf *eb, StgEntCounter *p) { StgWord len = 8 + 2 + strlen(p->arg_kinds)+1 + strlen(p->str)+1 + 8 + strlen(p->ticky_json)+1; - ensureRoomForVariableEvent(eb, len); + CHECK(!ensureRoomForVariableEvent(eb, len)); postEventHeader(eb, EVENT_TICKY_COUNTER_DEF); postPayloadSize(eb, len); @@ -1437,7 +1437,7 @@ void postIPE(const InfoProvEnt *ipe) // 1 null after each string // 1 colon between src_file and src_span StgWord len = 8+table_name_len+1+closure_desc_len+1+ty_desc_len+1+label_len+1+module_len+1+src_file_len+1+src_span_len+1; - ensureRoomForVariableEvent(&eventBuf, len); + CHECK(!ensureRoomForVariableEvent(&eventBuf, len)); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); @@ -1494,6 +1494,7 @@ void resetEventsBuf(EventsBuf* eb) eb->marker = NULL; } +STG_WARN_UNUSED_RESULT StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum) { uint32_t size = sizeof(EventTypeNum) + sizeof(EventTimestamp) + eventTypes[eNum].size; @@ -1505,9 +1506,10 @@ StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum) } } -StgBool hasRoomForVariableEvent(EventsBuf *eb, uint32_t payload_bytes) +STG_WARN_UNUSED_RESULT +StgBool hasRoomForVariableEvent(EventsBuf *eb, StgWord payload_bytes) { - uint32_t size = sizeof(EventTypeNum) + sizeof(EventTimestamp) + + StgWord size = sizeof(EventTypeNum) + sizeof(EventTimestamp) + sizeof(EventPayloadSize) + payload_bytes; if (eb->pos + size > eb->begin + eb->size) { @@ -1522,16 +1524,19 @@ void ensureRoomForEvent(EventsBuf *eb, EventTypeNum tag) if (!hasRoomForEvent(eb, tag)) { // Flush event buffer to make room for new event. printAndClearEventBuf(eb); + ASSERT(hasRoomForEvent(eb, tag)); } } -int ensureRoomForVariableEvent(EventsBuf *eb, StgWord16 size) +STG_WARN_UNUSED_RESULT +int ensureRoomForVariableEvent(EventsBuf *eb, StgWord size) { if (!hasRoomForVariableEvent(eb, size)) { // Flush event buffer to make room for new event. printAndClearEventBuf(eb); - if (!hasRoomForVariableEvent(eb, size)) + if (!hasRoomForVariableEvent(eb, size)) { return 1; // Not enough space + } } return 0; } ===================================== rts/include/Stg.h ===================================== @@ -221,6 +221,7 @@ #define STG_UNUSED GNUC3_ATTRIBUTE(__unused__) #define STG_USED GNUC3_ATTRIBUTE(__used__) +#define STG_WARN_UNUSED_RESULT GNUC3_ATTRIBUTE(warn_unused_result) /* Prevent functions from being optimized. See Note [Windows Stack allocations] */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bec35fb31bd4858a3a5fa3c0aff1a1bc59ef330...bc361d2f675e5e2c1da07f66a91666914311e4c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bec35fb31bd4858a3a5fa3c0aff1a1bc59ef330...bc361d2f675e5e2c1da07f66a91666914311e4c3 You're receiving 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 Nov 22 15:41:29 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 22 Nov 2023 10:41:29 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/document_rts_-I Message-ID: <655e2129628e_28b34fe71b983076f@gitlab.mail> Bryan R pushed new branch wip/document_rts_-I at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/document_rts_-I You're receiving 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 Nov 22 15:46:23 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 22 Nov 2023 10:46:23 -0500 Subject: [Git][ghc/ghc][wip/andreask/expose-overloaded-unfoldings] 1414 commits: JS: avoid head/tail and unpackFS Message-ID: <655e224f2844e_28b34f1186130357f6@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/expose-overloaded-unfoldings at Glasgow Haskell Compiler / GHC Commits: c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00 JS: avoid head/tail and unpackFS - - - - - a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00 testsuite: Fix Python warnings (#22856) - - - - - 9ee761bf by sheaf at 2023-02-08T14:40:40-05:00 Fix tyvar scoping within class SPECIALISE pragmas Type variables from class/instance headers scope over class/instance method type signatures, but DO NOT scope over the type signatures in SPECIALISE and SPECIALISE instance pragmas. The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for SPECIALISE inline pragmas, but forgot to apply the same treatment to method SPECIALISE pragmas, which lead to a Core Lint failure with an out-of-scope type variable. This patch makes sure we apply the same logic for both cases. Fixes #22913 - - - - - 7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00 Revert "Don't keep exit join points so much" This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 ------------------------- - - - - - 633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: remove config.use_threads This patch simplifies the testsuite driver by removing the use_threads config field. It's just a degenerate case of threads=1. - - - - - ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: use concurrent.futures.ThreadPoolExecutor in the driver The testsuite driver used to create one thread per test case, and explicitly use semaphore and locks for rate limiting and synchronization. This is a bad practice in any language, and occasionally may result in livelock conditions (e.g. #22889). This patch uses concurrent.futures.ThreadPoolExecutor for scheduling test case runs, which is simpler and more robust. - - - - - f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00 EPA: Comment between module and where should be in header comments Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919 - - - - - d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00 JS generated refs: update testsuite conditions - - - - - 2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00 Bump transformers to 0.6.1.0 This allows us to avoid orphans for Foldable1 instances, fixing #22898. Updates transformers submodule. - - - - - d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00 Update `Data.List.singleton` doc comment - - - - - fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00 gitlab-template: Emphasize `user facing` label My sense is that the current mention of the ~"user facing" label is overlooked by many MR authors. Let's move this point up in the list to make it more likely that it is seen. Also rephrase some of the points. - - - - - e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00 Refactor the simplifier a bit to fix #22761 The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now. - - - - - 11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00 Detect the `mold` linker Enables support for the `mold` linker by rui314. - - - - - 59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00 Add Lift instance for Fixed - - - - - c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00 Testsuite: decrease length001 timeout for JS (#22921) - - - - - 133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00 compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData` instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf` - - - - - 1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00 Refresh profiling docs I went through the whole of the profiling docs and tried to amend them to reflect current best practices and tooling. In particular I removed some old references to tools such as hp2any and replaced them with references to eventlog2html. - - - - - da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00 docs: Add section about profiling and foreign calls Previously there was no documentation for how foreign calls interacted with the profiler. This can be quite confusing for users so getting it into the user guide is the first step to a potentially better solution. See the ticket for more insightful discussion. Fixes #21764 - - - - - 081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00 Document that -fproc-alignment was introduced only in GHC 8.6 - - - - - 16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00 Add clangd flag to include generated header files This enables clangd to correctly check C files that import Rts.h. (The added include directory contains ghcautoconf.h et. al.) - - - - - c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00 Mention new `Foreign.Marshal.Pool` implementation in User's Guide - - - - - b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00 upload_ghc_libs: More control over which packages to operate on Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to limit which packages to upload. This is often necessary when one package is not uploadable (e.g. see #22740). - - - - - aa3a262d by PHO at 2023-02-14T11:28:29-05:00 Assume platforms support rpaths if they use either ELF or Mach-O Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability of rpaths based on the object format, not on OS. - - - - - 47716024 by PHO at 2023-02-14T11:29:09-05:00 RTS linker: Improve compatibility with NetBSD 1. Hint address to NetBSD mmap(2) has a different semantics from that of Linux. When a hint address is provided, mmap(2) searches for a free region at or below the hint but *never* above it. This means we can't reliably search for free regions incrementally on the userland, especially when ASLR is enabled. Let the kernel do it for us if we don't care where the mapped address is going to be. 2. NetBSD not only hates to map pages as rwx, but also disallows to switch pages from rw- to r-x unless the intention is declared when pages are initially requested. This means we need a new MemoryAccess mode for pages that are going to be changed to r-x. - - - - - 11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00 base: Move changelog entry to its place - - - - - 75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00 nativeGen/AArch64: Emit Atomic{Read,Write} inline Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115. - - - - - d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00 Fix some correctness issues around tag inference when targeting the bytecode generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840 - - - - - 9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00 Introduce warning for loopy superclass solve Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905 - - - - - 1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00 rts: make it possible to change mblock size on 32-bit targets The MBLOCK_SHIFT macro must be the single source of truth for defining the mblock size, and changing it should only affect performance, not correctness. This patch makes it truly possible to reconfigure mblock size, at least on 32-bit targets, by fixing places which implicitly relied on the previous MBLOCK_SHIFT constant. Fixes #22901. - - - - - 78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00 Update outdated references to notes - - - - - e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00 Documentation: Improve Foldable1 documentation * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater detail, the text is mostly adapted from documentation of Foldable. * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above functions instead of redoing the full explanation. * Small updates to documentation of fold1, foldMap1 and toNonEmpty, again adapting from Foldable. * Update the foldMap1 example to lists instead of Sum since this is recommended for lazy right-associative folds. Fixes #22847 - - - - - 85a1a575 by romes at 2023-02-14T11:34:25-05:00 fix: Mark ghci Prelude import as implicit Fixes #22829 In GHCi, we were creating an import declaration for Prelude but we were not setting it as an implicit declaration. Therefore, ghci's import of Prelude triggered -Wmissing-import-lists. Adds regression test T22829 to testsuite - - - - - 3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00 compiler: fix generateCgIPEStub for no-tables-next-to-code builds generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896. - - - - - 08c0822c by doyougnu at 2023-02-15T00:16:39-05:00 docs: release notes, user guide: add js backend Follow up from #21078 - - - - - 79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00 Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate See #22343 - - - - - 9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00 rts: add the rts_clearMemory function This patch adds the rts_clearMemory function that does its best to zero out unused RTS memory for a wasm backend use case. See the comment above rts_clearMemory() prototype declaration for more detailed explanation. Closes #22920. - - - - - 26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00 Add -single-threaded flag to force single threaded rts This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240 - - - - - 631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00 docs: add a section for the wasm backend Fixes #22658 - - - - - 1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00 tests: Mark T12903 fragile everywhere See #21184 - - - - - b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00 Mark all T5435 variants as fragile See #22970. - - - - - df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00 Testsuite: mark T13167 as fragile for JS (#22921) - - - - - 324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00 JS: disable debugging info for heap objects - - - - - 518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00 Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching - - - - - 34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00 base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog Fixes #22883. - - - - - 12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00 Narrow the dont-decompose-newtype test Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae at cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary - - - - - 5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00 Documentation: add an example of SPEC usage - - - - - 681e0e8c by sheaf at 2023-02-16T14:09:56-05:00 No default finalizer exception handler Commit cfc8e2e2 introduced a mechanism for handling of exceptions that occur during Handle finalization, and 372cf730 set the default handler to print out the error to stderr. However, #21680 pointed out we might not want to set this by default, as it might pollute users' terminals with unwanted information. So, for the time being, the default handler discards the exception. Fixes #21680 - - - - - b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00 unicode: Don't inline bitmap in generalCategory generalCategory contains a huge literal string but is marked INLINE, this will duplicate the string into any use site of generalCategory. In particular generalCategory is used in functions like isSpace and the literal gets inlined into this function which makes it massive. https://github.com/haskell/core-libraries-committee/issues/130 Fixes #22949 ------------------------- Metric Decrease: T4029 T18304 ------------------------- - - - - - 8988eeef by sheaf at 2023-02-16T20:32:27-05:00 Expand synonyms in RoughMap We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985 - - - - - 3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Add test artifact Add the released testsuite tarball to the generated ghcup metadata. - - - - - c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Use Ubuntu and Rocky bindists Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu and Linux Mint. Prefer to use the Rocky 8 binary distribution on unknown distributions. - - - - - be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00 Add INLINABLE pragmas to `generic*` functions in Data.OldList These functions are * recursive * overloaded So it's important to add an `INLINABLE` pragma to each so that they can be specialised at the use site when the specific numeric type is known. Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020) https://github.com/haskell/core-libraries-committee/issues/129 - - - - - a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00 Merge libiserv with ghci `libiserv` serves no purpose. As it depends on `ghci` and doesn't have more dependencies than the `ghci` package, its code could live in the `ghci` package too. This commit also moves most of the code from the `iserv` program into the `ghci` package as well so that it can be reused. This is especially useful for the implementation of TH for the JS backend (#22261, !9779). - - - - - 7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00 Improve GHC.Tc.Gen.App.tcInstFun It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447 - - - - - 2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00 compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. - - - - - 26243de1 by Alexis King at 2023-02-20T15:27:17-05:00 Handle top-level Addr# literals in the bytecode compiler Fixes #22376. - - - - - 0196cc2b by romes at 2023-02-20T15:27:52-05:00 fix: Explicitly flush stdout on plugin Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed. - - - - - 4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00 Don't generate datacon wrappers for `type data` declarations Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948. - - - - - 96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00 Treat type data declarations as empty when checking pattern-matching coverage The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964. - - - - - ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00 Disallow `tagToEnum#` on `type data` types We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level. - - - - - 8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00 Bump submodule text to 2.0.2 - - - - - 172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00 GHC proposal 496 - Nullary record wildcards This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161 - - - - - f70a0239 by sheaf at 2023-02-21T18:36:35-05:00 ghc-prim: levity-polymorphic array equality ops This patch changes the pointer-equality comparison operations in GHC.Prim.PtrEq to work with arrays of unlifted values, e.g. sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# Fixes #22976 - - - - - 9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00 base: Correct @since annotation for FP<->Integral bit cast operations. Fixes #22708 - - - - - f11d9c27 by romes at 2023-02-21T23:58:42-05:00 fix: Update documentation links Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note. - - - - - fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-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. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-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. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-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. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-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. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-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. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-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. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 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: ...lots of lines omitted... 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. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04: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. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04: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. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 02efc181 by John Ericson at 2023-10-22T02:48:55-04: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. - - - - - 5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00 Move over a number of C-style checks to RTS configure - - - - - 5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 4a40271e by John Ericson at 2023-10-22T02:48:55-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT 'where' clause span - Capture full range for a CaseAlt Match - - - - - d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00 Update primitives.rst - - - - - 4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00 JS/userguide: add explanation of writing jsbits - - - - - 07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00 testsuite: increase timeout of ghc-api tests for wasm32 ghc-api tests for wasm32 are more likely to timeout due to the large wasm module sizes, especially when testing with wasm native tail calls, given wasmtime's handling of tail call opcodes are suboptimal at the moment. It makes sense to increase timeout specifically for these tests on wasm32. This doesn't affect other targets, and for wasm32 we don't increase timeout for all tests, so not to risk letting major performance regressions slip through the testsuite. - - - - - 0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00 Explicitly require RLIMIT_AS before use in OSMem.c This is done elsewhere in the source tree. It also suddenly is required on OpenBSD. - - - - - 9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00 Modularity: modularize external linker Decouple runLink from DynFlags to allow calling runLink more easily. This is preliminary work for calling Emscripten's linker (emcc) from our JavaScript linker. - - - - - e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00 js: add JStg IR, remove unsaturated constructor - Major step towards #22736 and adding the optimizer in #22261 - - - - - 35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00 Fix a bug in tail calls with ticks See #24078 for the diagnosis. The change affects only the Tick case of occurrence analysis. It's a bit hard to test, so no regression test (yet anyway). - - - - - 9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00 [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra 48e391952c17ff7eab10b0b1456e3f2a2af28a9b introduced `SYM_TYPE_DUP_DISCARD` to the bitfield. The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value. Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions. - - - - - 5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00 Fix and test for issue #24111, TH.Ppr output of pattern synonyms - - - - - 723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00 EPA: print doc comments as normal comments And ignore the ones allocated in haddock processing. It does not guarantee that every original haddock-like comment appears in the output, as it discards ones that have no legal attachment point. closes #23459 - - - - - 21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00 Fix non-termination bug in equality solver constraint left-to-right then right to left, forever. Easily fixed. - - - - - 270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00 ghc-toolchain: build with `-package-env=-` (#24131) Otherwise globally installed libraries (via `cabal install --lib`) break the build. Fixes #24131. - - - - - 7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00 docs: fix ScopedTypeVariables example (#24101) The previous example didn't compile. Furthermore, it wasn't demonstrating the point properly. I have changed it to an example which shows that 'a' in the signature must be the same 'a' as in the instance head. - - - - - 49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00 Fix pretty-printing of type family dependencies "where" should be after the injectivity annotation. - - - - - 73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00 gitlab-ci: Bump LLVM bootstrap jobs to Debian 12 As the Debian 10 images have too old an LLVM. Addresses #24056. - - - - - 5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00 ci: Run aarch64 llvm backend job with "LLVM backend" label This brings it into line with the x86 LLVM backend job. - - - - - 9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00 JS: fix FFI "wrapper" and "dynamic" Fix codegen and helper functions for "wrapper" and "dynamic" foreign imports. Fix tests: - ffi006 - ffi011 - T2469 - T4038 Related to #22363 - - - - - 81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00 EPA: Use full range for Anchor This change requires a series of related changes, which must all land at the same time, otherwise all the EPA tests break. * Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. * Add DArrow to TrailingAnn * EPA Introduce HasTrailing in ExactPrint Use [TrailingAnn] in enterAnn and remove it from ExactPrint (LocatedN RdrName) * In HsDo, put TrailingAnns at top of LastStmt * EPA: do not convert comments to deltas when balancing. * EPA: deal with fallout from getMonoBind * EPA fix captureLineSpacing * EPA print any comments in the span before exiting it * EPA: Add comments to AnchorOperation * EPA: remove AnnEofComment, it is no longer used Updates Haddock submodule - - - - - 03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00 Fix in docs regarding SSymbol, SNat, SChar (#24119) - - - - - 362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00 hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1) Updating the bootstrap plans with more recent GHC versions. - - - - - 00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00 ci: Add 9.8.1 bootstrap testing job - - - - - ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00 Compatibility with 9.8.1 as boot compiler This fixes several compatability issues when using 9.8.1 as the boot compiler. * An incorrect version guard on the stack decoding logic in ghc-heap * Some ghc-prim bounds need relaxing * ghc is no longer wired in, so we have to remove the -this-unit-id ghc call. Fixes #24077 - - - - - 6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00 Add NCG support for common 64bit operations to the x86 backend. These used to be implemented via C calls which was obviously quite bad for performance for operations like simple addition. Co-authored-by: Andreas Klebinger - - - - - 0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00 T2T in Expressions (#23738) This patch implements the T2T (term-to-type) transformation in expressions. Given a function with a required type argument vfun :: forall a -> ... the user can now call it as vfun (Maybe Int) instead of vfun (type (Maybe Int)) The Maybe Int argument is parsed and renamed as a term (HsExpr), but then undergoes a conversion to a type (HsType). See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs and Note [RequiredTypeArguments and the T2T mapping] Left as future work: checking for puns. - - - - - cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00 Add a test for I/O managers It tries to cover the cases of multiple threads waiting on the same fd for reading and multiple threads waiting for writing, including wait cancellation by async exceptions. It should work for any I/O manager, in-RTS or in-Haskell. Unfortunately it will not currently work for Windows because it relies on anonymous unix sockets. It could in principle be ported to use Windows named pipes. - - - - - 2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00 Skip the IOManager test on wasm32 arch. The test relies on the sockets API which are not (yet) available. - - - - - fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00 compiler: fix eager blackhole symbol in wasm32 NCG - - - - - af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00 testsuite: fix optasm tests for wasm32 - - - - - 1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00 testsuite: Add wasm32 to testsuite arches with NCG The compiler --info reports that wasm32 compilers have a NCG, so we should agree with that here. - - - - - db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00 EPA: make locA a function, not a field name And use it to generalise reLoc The following for the windows pipeline one. 5.5% Metric Increase: T5205 - - - - - 833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00 Update the unification count in wrapUnifierX Omitting this caused type inference to fail in #24146. This was an accidental omision in my refactoring of the equality solver. - - - - - e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00 Remove an accidental git conflict marker from a comment. - - - - - 30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00 Add laws relating between Foldable/Traversable with their Bi- superclasses See https://github.com/haskell/core-libraries-committee/issues/205 for discussion. This commit also documents that the tuple instances only satisfy the laws up to lazyness, similar to the documentation added in !9512. - - - - - df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00 Elaborate on the quantified superclass of Bifunctor This was requested in the comment https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700 for when Traversable becomes a superclass of Bitraversable, but similarly applies to Functor/Bifunctor, which already are in a superclass relationship. - - - - - 8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00 EPA: get rid of l2l and friends Replace them with l2l to convert the location la2la to convert a GenLocated thing Updates haddock submodule - - - - - dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00 JS: remove broken newIdents from JStg Monad GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate identifiers being generated in h$c1, h$c2, ... . This change removes the broken newIdents. - - - - - 455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00 Create specially-solved DataToTag class Closes #20532. This implements CLC proposal 104: https://github.com/haskell/core-libraries-committee/issues/104 The design is explained in Note [DataToTag overview] in GHC.Tc.Instance.Class. This replaces the existing `dataToTag#` primop. These metric changes are not "real"; they represent Unique-related flukes triggering on a different set of jobs than they did previously. See also #19414. Metric Decrease: T13386 T8095 Metric Increase: T13386 T8095 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00 EPA: get rid of glRR and friends in GHC/Parser.y With the HasLoc and HasAnnotation classes, we can replace a number of type-specific helper functions in the parser with polymorphic ones instead Metric Decrease: MultiLayerModulesTH_Make - - - - - 18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00 ci: bump ci-images for wasi-sdk upgrade - - - - - 52c0fc69 by PHO at 2023-11-09T19:16:22-05:00 Don't assume the current locale is *.UTF-8, set the encoding explicitly primops.txt contains Unicode characters: > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226) Hadrian must also avoid using readFile' to read primops.txt because it tries to decode the file with a locale-specific encoding. - - - - - 7233b3b1 by PHO at 2023-11-09T19:17:01-05:00 Use '[' instead of '[[' because the latter is a Bash-ism It doesn't work on platforms where /bin/sh is something other than Bash. - - - - - 6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00 Add an extra check in kcCheckDeclHeader_sig Fix #24083 by checking for a implicitly-scoped type variable that is not actually bound. See Note [Disconnected type variables] in GHC.Tc.Gen.HsType For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures. Metric Decrease: MultiLayerModulesTH_Make - - - - - 22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00 AArch64: Delete unused LDATA pseudo-instruction Though there were consuming functions for LDATA, there were no producers. Thus, the removed code was "dead". - - - - - 2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00 EPA: harmonise acsa and acsA in GHC/Parser.y With the HasLoc class, we can remove the acsa helper function, using acsA instead. - - - - - 7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00 nofib: bump submodule This includes changes that: - fix building a benchmark with HEAD - remove a Makefile-ism that causes errors in bash scripts Resolves #24178 - - - - - 3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00 EPA: Replace Anchor with EpaLocation An Anchor has a location and an operation, which is either that it is unchanged or that it has moved with a DeltaPos data Anchor = Anchor { anchor :: RealSrcSpan , anchor_op :: AnchorOperation } An EpaLocation also has either a location or a DeltaPos data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] Now that we do not care about always having a location in the anchor, we remove Anchor and replace it with EpaLocation We do this with a type alias initially, to ease the transition. The alias will be removed in time. We also have helpers to reconstruct the AnchorOperation from an EpaLocation. This is also temporary. Updates Haddock submodule - - - - - a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00 EPA: get rid of AnchorOperation Now that the Anchor type is an alias for EpaLocation, remove AnchorOperation. Updates haddock submodule - - - - - 0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00 Add since annotation for showHFloat - - - - - e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 Suppress duplicate librares linker warning of new macOS linker Fixes #24167 XCode 15 introduced a new linker which warns on duplicate libraries being linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as suggested by Brad King in CMake issue #25297. This flag isn't necessarily available to other linkers on darwin, so we must only configure it into the CC linker arguments if valid. - - - - - c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Encoding test witnesses recent iconv bug is fragile A regression in the new iconv() distributed with XCode 15 and MacOS Sonoma causes the test 'encoding004' to fail in the CP936 roundrip. We mark this test as fragile until this is fixed upstream (rather than broken, since previous versions of iconv pass the test) See #24161 - - - - - ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Update to LC_ALL=C no longer being ignored in darwin MacOS seems to have fixed an issue where it used to ignore the variable `LC_ALL` in program invocations and default to using Unicode. Since the behaviour seems to be fixed to account for the locale variable, we mark tests that were previously broken in spite of it as fragile (since they now pass in recent macOS distributions) See #24161 - - - - - e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 darwin: Fix single_module is obsolete warning In XCode 15's linker, -single_module is the default and otherwise passing it as a flag results in a warning being raised: ld: warning: -single_module is obsolete This patch fixes this warning by, at configure time, determining whether the linker supports -single_module (which is likely false for all non-darwin linkers, and true for darwin linkers in previous versions of macOS), and using that information at runtime to decide to pass or not the flag in the invocation. Fixes #24168 - - - - - 929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 testsuite: Skip MultiLayerModulesTH_Make on darwin The recent toolchain upgrade on darwin machines resulted in the MultiLayerModulesTH_Make test metrics varying too much from the baseline, ultimately blocking the CI pipelines. This commit skips the test on darwin to temporarily avoid failures due to the environment change in the runners. However, the metrics divergence is being investigated still (tracked in #24177) - - - - - af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00 configure: check target (not build) understands -no_compact_unwind Previously, we were branching on whether the build system was darwin to shortcut this check, but we really want to branch on whether the target system (which is what we are configuring ld_prog for) is darwin. - - - - - 2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00 JS: Fix missing variable declarations The JStg IR update was missing some local variable declarations that were present earlier, causing global variables to be used implicitly (or an error in JavaScript strict mode). This adds the local variable declarations again. - - - - - 99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00 Remove loopy superclass solve mechanism Programs with a -Wloopy-superclass-solve warning will now fail with an error. Fixes #23017 - - - - - 2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00 users-guide: Fix links to libraries from the users-guide. The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the package name, so we don't need to explicitly add it to the links. Fixes #24151 - - - - - 27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00 EPA: splitLHsForAllTyInvis does not return ann We did not use the annotations returned from splitLHsForAllTyInvis, so do not return them. - - - - - a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00 Document defaulting of RuntimeReps Fixes #24099 - - - - - 2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00 Second fix to #24083 My earlier fix turns out to be too aggressive for data/type families See wrinkle (DTV1) in Note [Disconnected type variables] - - - - - cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00 Fix unusable units and module reexport interaction (#21097) This commit fixes an issue with ModUnusable introduced in df0f148feae. In mkUnusableModuleNameProvidersMap we traverse the list of unusable units and generate ModUnusable origin for all the modules they contain: exposed modules, hidden modules, and also re-exported modules. To do this we have a two-level map: ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin So for each module name "M" in broken unit "u" we have: "M" -> u:M -> ModUnusable reason However in the case of module reexports we were using the *target* module as a key. E.g. if "u:M" is a reexport for "X" from unit "o": "M" -> o:X -> ModUnusable reason Case 1: suppose a reexport without module renaming (u:M -> o:M) from unusable unit u: "M" -> o:M -> ModUnusable reason Here it's claiming that the import of M is unusable because a reexport from u is unusable. But if unit o isn't unusable we could also have in the map: "M" -> o:M -> ModOrigin ... Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModOrigin) Case 2: similarly we could have 2 unusable units reexporting the same module without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v unusable. It gives: "M" -> o:M -> ModUnusable ... (for u) "M" -> o:M -> ModUnusable ... (for v) Issue: the Semigroup instance of ModuleOrigin doesn't handle the case (ModUnusable <> ModUnusable). This led to #21097, #16996, #11050. To fix this, in this commit we make ModUnusable track whether the module used as key is a reexport or not (for better error messages) and we use the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u is unusable, we now record: "M" -> u:M -> ModUnusable reason reexported=True So now, we have two cases for a reexport u:M -> o:X: - u unusable: "M" -> u:M -> ModUnusable ... reexported=True - u usable: "M" -> o:X -> ModOrigin ... reexportedFrom=u:M The second case is indexed with o:X because in this case the Semigroup instance of ModOrigin is used to combine valid expositions of a module (directly or via reexports). Note that module lookup functions select usable modules first (those who have a ModOrigin value), so it doesn't matter if we add new ModUnusable entries in the map like this: "M" -> { u:M -> ModUnusable ... reexported=True o:M -> ModOrigin ... } The ModOrigin one will be used. Only if there is no ModOrigin or ModHidden entry will the ModUnusable error be printed. See T21097 for an example printing several reasons why an import is unusable. - - - - - 3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00 Fix IPE test A helper function was defined in a different module than used. To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe - - - - - 49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00 Properly compute unpacked sizes for -funpack-small-strict-fields. Use rep size rather than rep count to compute the size. Fixes #22309 - - - - - b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00 Explicit methods for Alternative Compose Explicitly define some and many in Alternative instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/181 - - - - - 9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00 Add permutations for non-empty lists. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00 Update changelog and since annotations for Data.List.NonEmpty.permutations Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837 - - - - - 94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00 Update doc string for traceShow Updated doc string for traceShow. - - - - - faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00 JS: clean up some foreign imports - - - - - 856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00 AArch64: Remove unused instructions As these aren't ever emitted, we don't even know if they work or will ever be used. If one of them is needed in future, we may easily re-add it. Deleted instructions are: - CMN - ANDS - BIC - BICS - EON - ORN - ROR - TST - STP - LDP - DMBSY - - - - - 615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00 EPA: Replace Monoid with NoAnn Remove the final Monoid instances in the exact print infrastructure. For Windows CI Metric Decrease: T5205 - - - - - 5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00 Speed up stimes in instance Semigroup Endo As discussed at https://github.com/haskell/core-libraries-committee/issues/4 - - - - - cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00 base: reflect latest changes in the changelog - - - - - 48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00 EPA: Use SrcSpan in EpaSpan This is more natural, since we already need to deal with invalid RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for. Updates haddock submodule. - - - - - 97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00 Add regression test for #6070 Fixes #6070. - - - - - e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 470352b5 by Andreas Klebinger at 2023-11-22T15:46:12+00:00 Tidy: Expose unfoldings if they take dictionary arguments by default. - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/toolchain.nix - − .gitlab/gen-ci.cabal - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - .gitlab/hie.yaml → .gitlab/generate-ci/hie.yaml - − .gitlab/generate_job_metadata - − .gitlab/generate_jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f506a732016df27728770065099125f4d523d42a...470352b54184511dec8259399b44a1acb9b528c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f506a732016df27728770065099125f4d523d42a...470352b54184511dec8259399b44a1acb9b528c7 You're receiving 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 Nov 22 16:48:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 11:48:56 -0500 Subject: [Git][ghc/ghc][master] fix: Change type signatures in NonEmpty export comments to reflect reality Message-ID: <655e30f8b5e4a_28b34f136632448556@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 1 changed file: - libraries/base/src/Data/List/NonEmpty.hs Changes: ===================================== libraries/base/src/Data/List/NonEmpty.hs ===================================== @@ -44,11 +44,11 @@ module Data.List.NonEmpty ( , (<|), cons -- :: a -> NonEmpty a -> NonEmpty a , uncons -- :: NonEmpty a -> (a, Maybe (NonEmpty a)) , unfoldr -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b - , sort -- :: NonEmpty a -> NonEmpty a + , sort -- :: Ord a => NonEmpty a -> NonEmpty a , reverse -- :: NonEmpty a -> NonEmpty a - , inits -- :: Foldable f => f a -> NonEmpty a + , inits -- :: Foldable f => f a -> NonEmpty [a] , inits1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) - , tails -- :: Foldable f => f a -> NonEmpty a + , tails -- :: Foldable f => f a -> NonEmpty [a] , tails1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) , append -- :: NonEmpty a -> NonEmpty a -> NonEmpty a , appendList -- :: NonEmpty a -> [a] -> NonEmpty a @@ -57,31 +57,31 @@ module Data.List.NonEmpty ( , iterate -- :: (a -> a) -> a -> NonEmpty a , repeat -- :: a -> NonEmpty a , cycle -- :: NonEmpty a -> NonEmpty a - , unfold -- :: (a -> (b, Maybe a) -> a -> NonEmpty b + , unfold -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b , insert -- :: (Foldable f, Ord a) => a -> f a -> NonEmpty a , some1 -- :: Alternative f => f a -> f (NonEmpty a) -- * Extracting sublists , take -- :: Int -> NonEmpty a -> [a] , drop -- :: Int -> NonEmpty a -> [a] , splitAt -- :: Int -> NonEmpty a -> ([a], [a]) - , takeWhile -- :: Int -> NonEmpty a -> [a] - , dropWhile -- :: Int -> NonEmpty a -> [a] - , span -- :: Int -> NonEmpty a -> ([a],[a]) - , break -- :: Int -> NonEmpty a -> ([a],[a]) + , takeWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , dropWhile -- :: (a -> Bool) -> NonEmpty a -> [a] + , span -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) + , break -- :: (a -> Bool) -> NonEmpty a -> ([a], [a]) , filter -- :: (a -> Bool) -> NonEmpty a -> [a] , partition -- :: (a -> Bool) -> NonEmpty a -> ([a],[a]) - , group -- :: Foldable f => Eq a => f a -> [NonEmpty a] + , group -- :: (Foldable f, Eq a) => f a -> [NonEmpty a] , groupBy -- :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] , groupWith -- :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] - , groupAllWith -- :: (Foldable f, Ord b) => (a -> b) -> f a -> [NonEmpty a] + , groupAllWith -- :: Ord b => (a -> b) -> [a] -> [NonEmpty a] , group1 -- :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) , groupBy1 -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) - , groupWith1 -- :: (Foldable f, Eq b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , groupAllWith1 -- :: (Foldable f, Ord b) => (a -> b) -> f a -> NonEmpty (NonEmpty a) - , permutations - , permutations1 + , groupWith1 -- :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , groupAllWith1 -- :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) + , permutations -- :: [a] -> NonEmpty [a] + , permutations1 -- :: NonEmpty a -> NonEmpty (NonEmpty a) -- * Sublist predicates - , isPrefixOf -- :: Foldable f => f a -> NonEmpty a -> Bool + , isPrefixOf -- :: Eq a => [a] -> NonEmpty a -> Bool -- * \"Set\" operations , nub -- :: Eq a => NonEmpty a -> NonEmpty a , nubBy -- :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a @@ -90,12 +90,12 @@ module Data.List.NonEmpty ( -- * Zipping and unzipping streams , zip -- :: NonEmpty a -> NonEmpty b -> NonEmpty (a,b) , zipWith -- :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c - , unzip -- :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) + , unzip -- :: Functor f => f (a,b) -> (f a, f b) -- * Converting to and from a list , fromList -- :: [a] -> NonEmpty a , toList -- :: NonEmpty a -> [a] , nonEmpty -- :: [a] -> Maybe (NonEmpty a) - , xor -- :: NonEmpty a -> Bool + , xor -- :: NonEmpty Bool -> Bool ) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17ec3e97e9862ed2331aa08f54911143db9ad04a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17ec3e97e9862ed2331aa08f54911143db9ad04a You're receiving 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 Nov 22 16:49:40 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 11:49:40 -0500 Subject: [Git][ghc/ghc][master] Fix the platform string for GNU/Hurd Message-ID: <655e31249dd75_28b34f1366324534d5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - 1 changed file: - hadrian/src/Hadrian/Haskell/Cabal.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal.hs ===================================== @@ -75,5 +75,6 @@ cabalOsString :: String -> String cabalOsString "mingw32" = "windows" cabalOsString "darwin" = "osx" cabalOsString "solaris2" = "solaris" +cabalOsString "gnu" = "hurd" cabalOsString other = other View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fd78f9fcafeda26cbb0222b41484d44aa9945a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fd78f9fcafeda26cbb0222b41484d44aa9945a8 You're receiving 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 Nov 22 16:50:33 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 11:50:33 -0500 Subject: [Git][ghc/ghc][master] EPA: Tuple Present no longer has annotation Message-ID: <655e3159139bf_28b34f265013857382@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 6 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -416,7 +416,7 @@ type instance XXPragE (GhcPass _) = DataConCantHappen type instance XCDotFieldOcc (GhcPass _) = EpAnn AnnFieldLabel type instance XXDotFieldOcc (GhcPass _) = DataConCantHappen -type instance XPresent (GhcPass _) = EpAnn [AddEpAnn] +type instance XPresent (GhcPass _) = NoExtField type instance XMissing GhcPs = EpAnn EpaLocation type instance XMissing GhcRn = NoExtField ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -666,7 +666,7 @@ mkLHsTupleExpr :: [LHsExpr (GhcPass p)] -> XExplicitTuple (GhcPass p) -- Makes a pre-typechecker boxed tuple, deals with 1 case mkLHsTupleExpr [e] _ = e mkLHsTupleExpr es ext - = noLocA $ ExplicitTuple ext (map (Present noAnn) es) Boxed + = noLocA $ ExplicitTuple ext (map (Present noExtField) es) Boxed mkLHsVarTuple :: IsSrcSpanAnn p a => [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p) ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3151,7 +3151,7 @@ mkSumOrTupleExpr l boxity (Tuple es) anns = do where toTupArg :: Either (EpAnn EpaLocation) (LHsExpr GhcPs) -> HsTupArg GhcPs toTupArg (Left ann) = missingTupArg ann - toTupArg (Right a) = Present noAnn a + toTupArg (Right a) = Present noExtField a -- Sum -- mkSumOrTupleExpr l Unboxed (Sum alt arity e) = ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -1037,7 +1037,7 @@ tcPatToExpr args pat = go pat ; return $ ExplicitList noExtField exprs } go1 (TuplePat _ pats box) = do { exprs <- mapM go pats ; return $ ExplicitTuple noExtField - (map (Present noAnn) exprs) box } + (map (Present noExtField) exprs) box } go1 (SumPat _ pat alt arity) = do { expr <- go1 (unLoc pat) ; return $ ExplicitSum noExtField alt arity (noLocA expr) ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1218,7 +1218,7 @@ cvtDD (FromThenToR x y z) = do { x' <- cvtl x; y' <- cvtl y; z' <- cvtl z; retur cvt_tup :: [Maybe Exp] -> Boxity -> CvtM (HsExpr GhcPs) cvt_tup es boxity = do { let cvtl_maybe Nothing = return (missingTupArg noAnn) - cvtl_maybe (Just e) = fmap (Present noAnn) (cvtl e) + cvtl_maybe (Just e) = fmap (Present noExtField) (cvtl e) ; es' <- mapM cvtl_maybe es ; return $ ExplicitTuple noAnn ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3431,10 +3431,10 @@ instance ExactPrint (DotFieldOcc GhcPs) where -- --------------------------------------------------------------------- instance ExactPrint (HsTupArg GhcPs) where - getAnnotationEntry (Present an _) = fromAnn an + getAnnotationEntry (Present _ _) = NoEntryVal getAnnotationEntry (Missing an) = fromAnn an - setAnnotationAnchor (Present an a) anc ts cs = Present (setAnchorEpa an anc ts cs) a + setAnnotationAnchor (Present a b) _ _ _ = Present a b setAnnotationAnchor (Missing an) anc ts cs = Missing (setAnchorEpa an anc ts cs) exact (Present a e) = Present a <$> markAnnotated e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a79960fec0d65574015aae56f42f26b501a48f07 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a79960fec0d65574015aae56f42f26b501a48f07 You're receiving 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 Nov 22 17:48:27 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 22 Nov 2023 12:48:27 -0500 Subject: [Git][ghc/ghc][wip/spj-unf-size] Adjust back Message-ID: <655e3eeb53a24_28b34f4316bf064289@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 1d10a893 by Simon Peyton Jones at 2023-11-22T17:48:11+00:00 Adjust back - - - - - 1 changed file: - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -206,7 +206,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- inline into Csg.calc (The unfolding for sqr never makes it -- into the interface file.) - , unfoldingUseThreshold = 80 + , unfoldingUseThreshold = 75 -- Adjusted 90 -> 80 when adding discounts for free variables which -- generally make things more likely to inline. Reducing the threshold -- eliminates some undesirable compile-time regressions (e.g. T10412a) @@ -214,7 +214,7 @@ defaultUnfoldingOpts = UnfoldingOpts -- Previously: adjusted upwards in #18282, when I reduced -- the result discount for constructors. - , unfoldingFunAppDiscount = 30 + , unfoldingFunAppDiscount = 45 -- Be fairly keen to inline a function if that means -- we'll be able to pick the right method from a dictionary View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d10a893039d73de1ef520f6d67185b3fd2bd743 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d10a893039d73de1ef520f6d67185b3fd2bd743 You're receiving 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 Nov 22 19:08:35 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 22 Nov 2023 14:08:35 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-tup-tail-bool Message-ID: <655e51b349617_28b34f67cef4c6743e@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-tup-tail-bool at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-tup-tail-bool You're receiving 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 Nov 22 22:52:27 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 17:52:27 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Fix the platform string for GNU/Hurd Message-ID: <655e862b3395b_28b34fbd9f2b486860@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 91150a3a by David Binder at 2023-11-22T17:52:22-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d4e26b60 by Alan Zimmerman at 2023-11-22T17:52:23-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 30 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/Types.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - hadrian/src/Hadrian/Haskell/Cabal.hs - libraries/hpc - + testsuite/tests/hpc/.gitignore - + testsuite/tests/hpc/fork/Makefile - + testsuite/tests/hpc/fork/hpc_fork.hs - + testsuite/tests/hpc/fork/hpc_fork.stdout - + testsuite/tests/hpc/fork/test.T - + testsuite/tests/hpc/function/Makefile - + testsuite/tests/hpc/function/test.T - + testsuite/tests/hpc/function/tough.hs - + testsuite/tests/hpc/function/tough.stdout - + testsuite/tests/hpc/function2/Makefile - + testsuite/tests/hpc/function2/subdir/tough2.lhs - + testsuite/tests/hpc/function2/test.T - + testsuite/tests/hpc/function2/tough2.stdout - + testsuite/tests/hpc/ghc_ghci/A.hs - + testsuite/tests/hpc/ghc_ghci/B.hs - + testsuite/tests/hpc/ghc_ghci/Makefile - + testsuite/tests/hpc/ghc_ghci/hpc_ghc_ghci.stdout - + testsuite/tests/hpc/ghc_ghci/test.T - + testsuite/tests/hpc/hpc.ovr - + testsuite/tests/hpc/hpcrun.pl The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff21810cf3e509587cbdb78718e44eaee285b854...d4e26b605af4f74e7e3980e20139430c20083c99 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff21810cf3e509587cbdb78718e44eaee285b854...d4e26b605af4f74e7e3980e20139430c20083c99 You're receiving 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 Nov 23 02:12:55 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 21:12:55 -0500 Subject: [Git][ghc/ghc][master] Unify the hpc testsuites Message-ID: <655eb5277665d_28b34f10b3a30c9603d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - 30 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - libraries/hpc - + testsuite/tests/hpc/.gitignore - + testsuite/tests/hpc/fork/Makefile - + testsuite/tests/hpc/fork/hpc_fork.hs - + testsuite/tests/hpc/fork/hpc_fork.stdout - + testsuite/tests/hpc/fork/test.T - + testsuite/tests/hpc/function/Makefile - + testsuite/tests/hpc/function/test.T - + testsuite/tests/hpc/function/tough.hs - + testsuite/tests/hpc/function/tough.stdout - + testsuite/tests/hpc/function2/Makefile - + testsuite/tests/hpc/function2/subdir/tough2.lhs - + testsuite/tests/hpc/function2/test.T - + testsuite/tests/hpc/function2/tough2.stdout - + testsuite/tests/hpc/ghc_ghci/A.hs - + testsuite/tests/hpc/ghc_ghci/B.hs - + testsuite/tests/hpc/ghc_ghci/Makefile - + testsuite/tests/hpc/ghc_ghci/hpc_ghc_ghci.stdout - + testsuite/tests/hpc/ghc_ghci/test.T - + testsuite/tests/hpc/hpc.ovr - + testsuite/tests/hpc/hpcrun.pl - + testsuite/tests/hpc/raytrace/CSG.hs - + testsuite/tests/hpc/raytrace/Construct.hs - + testsuite/tests/hpc/raytrace/Data.hs - + testsuite/tests/hpc/raytrace/Eval.hs - + testsuite/tests/hpc/raytrace/Geometry.hs - + testsuite/tests/hpc/raytrace/Illumination.hs - + testsuite/tests/hpc/raytrace/Intersections.hs - + testsuite/tests/hpc/raytrace/Interval.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/121c9ab76cf8dccd07b03e2add519d6eb10dcefa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/121c9ab76cf8dccd07b03e2add519d6eb10dcefa You're receiving 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 Nov 23 02:13:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 22 Nov 2023 21:13:32 -0500 Subject: [Git][ghc/ghc][master] EPA: empty tup_tail has noAnn Message-ID: <655eb54c30f80_28b34f10b2eee49994@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 7 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/Types.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Orphans.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -418,7 +418,7 @@ type instance XXDotFieldOcc (GhcPass _) = DataConCantHappen type instance XPresent (GhcPass _) = NoExtField -type instance XMissing GhcPs = EpAnn EpaLocation +type instance XMissing GhcPs = EpAnn Bool -- True for empty last comma type instance XMissing GhcRn = NoExtField type instance XMissing GhcTc = Scaled Type ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -676,7 +676,7 @@ mkLHsVarTuple ids ext = mkLHsTupleExpr (map nlHsVar ids) ext nlTuplePat :: [LPat GhcPs] -> Boxity -> LPat GhcPs nlTuplePat pats box = noLocA (TuplePat noAnn pats box) -missingTupArg :: EpAnn EpaLocation -> HsTupArg GhcPs +missingTupArg :: EpAnn Bool -> HsTupArg GhcPs missingTupArg ann = Missing ann mkLHsPatTup :: [LPat GhcRn] -> LPat GhcRn ===================================== compiler/GHC/Parser.y ===================================== @@ -3119,7 +3119,7 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } ; return (Tuple (Right t : snd $2)) } } | commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (srcSpan2e ll) emptyComments))) (fst $1) } + do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) True emptyComments))) (fst $1) } ; return (Tuple (cos ++ $2)) } } | texp bars { unECP $1 >>= \ $1 -> return $ @@ -3132,14 +3132,14 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } (map srcSpan2e $ fst $3)) } -- Always starts with commas; always follows an expr -commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn EpaLocation) (LocatedA b)]) } +commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn Bool) (LocatedA b)]) } commas_tup_tail : commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (srcSpan2e l) emptyComments))) (tail $ fst $1) } + do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) True emptyComments))) (tail $ fst $1) } ; return ((head $ fst $1, cos ++ $2)) } } -- Always follows a comma -tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn EpaLocation) (LocatedA b)] } +tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn Bool) (LocatedA b)] } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3149,7 +3149,7 @@ mkSumOrTupleExpr l boxity (Tuple es) anns = do cs <- getCommentsFor (locA l) return $ L l (ExplicitTuple (EpAnn (spanAsAnchor $ locA l) anns cs) (map toTupArg es) boxity) where - toTupArg :: Either (EpAnn EpaLocation) (LHsExpr GhcPs) -> HsTupArg GhcPs + toTupArg :: Either (EpAnn Bool) (LHsExpr GhcPs) -> HsTupArg GhcPs toTupArg (Left ann) = missingTupArg ann toTupArg (Right a) = Present noExtField a @@ -3176,7 +3176,7 @@ mkSumOrTuplePat l boxity (Tuple ps) anns = do cs <- getCommentsFor (locA l) return $ L l (PatBuilderPat (TuplePat (EpAnn (spanAsAnchor $ locA l) anns cs) ps' boxity)) where - toTupPat :: Either (EpAnn EpaLocation) (LocatedA (PatBuilder GhcPs)) -> PV (LPat GhcPs) + toTupPat :: Either (EpAnn Bool) (LocatedA (PatBuilder GhcPs)) -> PV (LPat GhcPs) -- Ignore the element location so that the error message refers to the -- entire tuple. See #19504 (and the discussion) for details. toTupPat p = case p of ===================================== compiler/GHC/Parser/Types.hs ===================================== @@ -29,7 +29,7 @@ import Language.Haskell.Syntax data SumOrTuple b = Sum ConTag Arity (LocatedA b) [EpaLocation] [EpaLocation] -- ^ Last two are the locations of the '|' before and after the payload - | Tuple [Either (EpAnn EpaLocation) (LocatedA b)] + | Tuple [Either (EpAnn Bool) (LocatedA b)] pprSumOrTuple :: Outputable b => Boxity -> SumOrTuple b -> SDoc pprSumOrTuple boxity = \case ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -380,6 +380,10 @@ instance HasTrailing NameAnn where trailing a = nann_trailing a setTrailing a ts = a { nann_trailing = ts } +instance HasTrailing Bool where + trailing _ = [] + setTrailing a _ = a + -- --------------------------------------------------------------------- fromAnn' :: (HasEntry a) => a -> Entry ===================================== utils/check-exact/Orphans.hs ===================================== @@ -63,3 +63,6 @@ instance NoAnn EpAnnImportDecl where instance NoAnn AnnsModule where noAnn = AnnsModule [] [] Nothing + +instance NoAnn Bool where + noAnn = False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2733a055584964eb4a1d3a4764de4d678ffa313 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2733a055584964eb4a1d3a4764de4d678ffa313 You're receiving 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 Nov 23 05:07:18 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 23 Nov 2023 00:07:18 -0500 Subject: [Git][ghc/ghc][wip/expand-do] 11 commits: chore: Correct typo in the gitlab MR template Message-ID: <655ede0671292_28b34f151e5d8810093b@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00 chore: Correct typo in the gitlab MR template [skip ci] - - - - - f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00 Improve error message when reading invalid `.target` files A `.target` file generated by ghc-toolchain or by configure can become invalid if the target representation (`Toolchain.Target`) is changed while the files are not re-generated by calling `./configure` or `ghc-toolchain` again. There is also the issue of hadrian caching the dependencies on `.target` files, which makes parsing fail when reading reading the cached value if the representation has been updated. This patch provides a better error message in both situations, moving away from a terrible `Prelude.read: no parse` error that you would get otherwise. Fixes #24199 - - - - - 955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00 users guide: Note that QuantifiedConstraints implies ExplicitForAll Fixes #24025. - - - - - 17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00 fix: Change type signatures in NonEmpty export comments to reflect reality This fixes several typos in the comments of Data.List.NonEmpty export list items. - - - - - 2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00 Fix the platform string for GNU/Hurd As commited in Cargo https://github.com/haskell/cabal/pull/9434 there is confusion between "gnu" and "hurd". This got fixed in Cargo, we need the converse in Hadrian. Fixes #24180 - - - - - a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00 EPA: Tuple Present no longer has annotation The Present constructor for a Tuple argument will never have an exact print annotation. So make this impossible. - - - - - 121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00 Unify the hpc testsuites The hpc testsuite was split between testsuite/tests/hpc and the submodule libraries/hpc/test. This commit unifies the two testsuites in the GHC repository in the directory testsuite/tests/hpc. - - - - - d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00 EPA: empty tup_tail has noAnn In Parser.y, the tup_tail rule had the following option | {- empty -} %shift { return [Left noAnn] } Once this works through PostProcess.hs, it means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - a3f4eb18 by Apoorv Ingle at 2023-11-22T23:05:24-06:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker` - Make records Expand and not desugar before typechecking. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 42b888f3 by Apoorv Ingle at 2023-11-22T23:05:24-06:00 - Renaming `GHC.Types.Basic.{Origin -> MatchOrigin}` - - - - - 4c3d3724 by Apoorv Ingle at 2023-11-22T23:05:24-06:00 - hpc ticks, Do not count pattern match failures - - - - - 30 changed files: - .gitlab/merge_request_templates/Default.md - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/Types.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - + compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/039d28f342a574f6c15204c8467d1e6da5554e11...4c3d3724e5b9a06767cf9e29326600be03cccd67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/039d28f342a574f6c15204c8467d1e6da5554e11...4c3d3724e5b9a06767cf9e29326600be03cccd67 You're receiving 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 Nov 23 10:16:47 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 23 Nov 2023 05:16:47 -0500 Subject: [Git][ghc/ghc][wip/document_rts_-I] 2 commits: Simplify default Message-ID: <655f268f27d75_28b34f1c1dfdc81230e2@gitlab.mail> Bryan R pushed to branch wip/document_rts_-I at Glasgow Haskell Compiler / GHC Commits: b14b2af8 by Bryan Richter at 2023-11-23T12:15:09+02:00 Simplify default If the setting has no effect in the non-threaded runtime, the distinction is irrelevant. - - - - - 7853fc71 by Bryan Richter at 2023-11-23T12:16:30+02:00 Mention non-moving collector and reword other GC types - - - - - 1 changed file: - docs/users_guide/runtime_control.rst Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -723,7 +723,7 @@ performance. .. rts-flag:: -I ⟨seconds⟩ - :default: 0.3 seconds in the threaded runtime, 0 in the non-threaded runtime + :default: 0.3 seconds .. index:: single: idle GC @@ -731,17 +731,16 @@ performance. Set the amount of idle time which must pass before an idle GC is performed. Setting ``-I0`` disables the idle GC. - The idle GC is one of three ways to trigger a major GC. The other two are - heap overflow—where GHC will perform a GC if necessary—and manually by the - programmer via the interface in System.Mem (FIXME: link) + The idle GC only affects the threaded version of the RTS (see + :ghc-flag:`-threaded`). - The idle GC only affects the threaded and SMP versions of the RTS (see - :ghc-flag:`-threaded`, :ref:`options-linker`). When the idle GC is enabled, - a major GC is automatically performed if the runtime has been idle for the - specified period of time. + When the idle GC is enabled, a major GC is automatically performed when the + runtime has been idle for the specified period of time. - If idle GC is disabled, GCs will only happen via the other two mechanisms - mentioned. + When idle GC is not enabled, GCs will only happen via the other two + available mechanisms: a heap overflow—where GHC will perform a GC if + necessary—and manually by the programmer via the interface in + :base-ref:`System.Mem`. For an interactive application, it is probably a good idea to use the idle GC, because it will allow GCs to run in the idle time when no Haskell @@ -751,12 +750,17 @@ performance. frequent GCs, the program will also be prompter to run finalizers and detect deadlocked threads. - Idle GCs are not a free lunch, however. They may trigger at precisely the - wrong time and interrupt new work unnecessarily. Setting ``-I`` to a low - value makes this more likely. Plus, setting it to a low value means the idle - GC could fire *too* often, resulting in GCs that don't even free much - memory. Thus you may need to find the sweet spot for your application to - maximize the value the idle GC can bring. + With the advent of the non-moving collector (see + :rts-flag:`--nonmoving-gc`), the responsiveness gains of the idle GC became + less important. But prompter finalization and deadlock detection are still + valuable. + + Idle GCs are not a free lunch. They may trigger at precisely the wrong time + and interrupt new work unnecessarily. Setting ``-I`` to a low value makes + this more likely. Plus, setting it to a low value means the idle GC could + fire *too* often, resulting in GCs that don't even free much memory. Thus + you may need to find the sweet spot for your application to maximize the + value the idle GC can bring. The idle period timer only resets after some activity by a Haskell thread. Therefore, once an idle GC is triggered, another one won't be scheduled View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/216241a7004118c5ed56f362b919a2d3269eef77...7853fc719d68eb3720217f059f1e21a6a20f0352 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/216241a7004118c5ed56f362b919a2d3269eef77...7853fc719d68eb3720217f059f1e21a6a20f0352 You're receiving 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 Nov 23 12:38:49 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Thu, 23 Nov 2023 07:38:49 -0500 Subject: [Git][ghc/ghc][wip/int-index/deprecated-type-abstractions] Add name for -Wdeprecated-type-abstractions (#24154) Message-ID: <655f47d977e4b_18a39031f559c10418a@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/deprecated-type-abstractions at Glasgow Haskell Compiler / GHC Commits: 8b934c7e by Vladislav Zavialov at 2023-11-23T15:38:32+03:00 Add name for -Wdeprecated-type-abstractions (#24154) This warning had no name or flag and was triggered unconditionally. Now it is part of -Wcompat. - - - - - 8 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/using-warnings.rst - testsuite/tests/typecheck/should_fail/T23776.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -697,6 +697,7 @@ data WarningFlag = | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 | Opt_WarnDataKindsTC -- Since 9.10 + | Opt_WarnDeprecatedTypeAbstractions -- Since 9.10 deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag @@ -811,6 +812,7 @@ warnFlagNames wflag = case wflag of Opt_WarnBadlyStagedTypes -> "badly-staged-types" :| [] Opt_WarnInconsistentFlags -> "inconsistent-flags" :| [] Opt_WarnDataKindsTC -> "data-kinds-tc" :| [] + Opt_WarnDeprecatedTypeAbstractions -> "deprecated-type-abstractions" :| [] -- ----------------------------------------------------------------------------- -- Standard sets of warning options @@ -1007,6 +1009,7 @@ minusWcompatOpts , Opt_WarnCompatUnqualifiedImports , Opt_WarnTypeEqualityOutOfScope , Opt_WarnImplicitRhsQuantification + , Opt_WarnDeprecatedTypeAbstractions ] -- | Things you get with -Wunused-binds ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2285,6 +2285,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of Opt_WarnIncompleteExportWarnings -> warnSpec x Opt_WarnIncompleteRecordSelectors -> warnSpec x Opt_WarnDataKindsTC -> warnSpec x + Opt_WarnDeprecatedTypeAbstractions -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -663,21 +663,10 @@ rnConPatAndThen mk con (PrefixCon tyargs pats) do { type_abs <- xoptM LangExt.TypeAbstractions ; type_app <- xoptM LangExt.TypeApplications ; scoped_tvs <- xoptM LangExt.ScopedTypeVariables - ; if | type_abs - -> return () - - -- As per [GHC Proposal 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/), - -- we allow type applications in constructor patterns when -XTypeApplications and - -- -XScopedTypeVariables are both enabled, but we emit a warning when doing so. - -- - -- This warning is scheduled to become an error in GHC 9.12, in - -- which case we will get the usual error (below), - -- which suggests enabling -XTypeAbstractions. - | type_app && scoped_tvs - -> addDiagnostic TcRnDeprecatedInvisTyArgInConPat - - | otherwise - -> addErrTc $ TcRnTypeApplicationsDisabled (TypeApplicationInPattern arg) + -- See Note [Deprecated type abstractions in constructor patterns] + ; if | type_abs -> return () + | type_app && scoped_tvs -> addDiagnostic TcRnDeprecatedInvisTyArgInConPat + | otherwise -> addErrTc $ TcRnTypeApplicationsDisabled (TypeApplicationInPattern arg) } rnConPatTyArg (HsConPatTyArg at t) = do @@ -701,6 +690,29 @@ rnConPatAndThen mk con (RecCon rpats) } } +{- Note [Deprecated type abstractions in constructor patterns] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Type abstractions in constructor patterns allow the user to bind +existential type variables: + + import Type.Reflection (Typeable, typeRep) + data Ex = forall e. (Typeable e, Show e) => MkEx e + showEx (MkEx @e a) = show a ++ " :: " ++ show (typeRep @e) + +Note the pattern `MkEx @e a`, and specifically the `@e` binder. + +For historical reasons, using this feature only required TypeApplications +and ScopedTypeVariables to be enabled. As per GHC Proposal #448 (and especially +its amendment #604) we are now transitioning towards guarding this feature +behind TypeAbstractions instead. + +As a compatibility measure, we continue to support old programs that use +TypeApplications with ScopedTypeVariables instead of TypeAbstractions, +but emit the appropriate compatibility warning, -Wdeprecated-type-abstractions. +This warning is scheduled to become an error in GHC 9.14, at which point +we can simply require TypeAbstractions. +-} + checkUnusedRecordWildcardCps :: SrcSpan -> Maybe [ImplicitFieldBinders] -> CpsRn () ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1877,7 +1877,7 @@ instance Diagnostic TcRnMessage where TcRnDeprecatedInvisTyArgInConPat -> mkSimpleDecorated $ cat [ text "Type applications in constructor patterns will require" - , text "the TypeAbstractions extension starting from GHC 9.12." ] + , text "the TypeAbstractions extension starting from GHC 9.14." ] TcRnInvisBndrWithoutSig _ hs_bndr -> mkSimpleDecorated $ @@ -2516,7 +2516,7 @@ instance Diagnostic TcRnMessage where TcRnIllegalInvisTyVarBndr{} -> ErrorWithoutFlag TcRnDeprecatedInvisTyArgInConPat {} - -> WarningWithoutFlag + -> WarningWithFlag Opt_WarnDeprecatedTypeAbstractions TcRnInvalidInvisTyVarBndr{} -> ErrorWithoutFlag TcRnInvisBndrWithoutSig{} ===================================== docs/users_guide/9.10.1-notes.rst ===================================== @@ -73,6 +73,10 @@ Compiler - Defaulting plugins can now propose solutions to entangled sets of type variables. This allows defaulting of multi-parameter type classes. See :ghc-ticket:`23832`. +- Type abstractions in constructor patterns that were previously admitted without enabling the :extension:`TypeAbstractions` + extension now trigger a warning, :ghc-flag:`-Wdeprecated-type-abstractions`. + This new warning is part of the :ghc-flag:`-Wcompat` warning group and will become an error in a future GHC release. + GHCi ~~~~ ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -171,6 +171,7 @@ as ``-Wno-...`` for every individual warning in the group. * :ghc-flag:`-Wcompat-unqualified-imports` * :ghc-flag:`-Wtype-equality-out-of-scope` * :ghc-flag:`-Wimplicit-rhs-quantification` + * :ghc-flag:`-Wdeprecated-type-abstractions` .. ghc-flag:: -w :shortdesc: disable all warnings @@ -2504,6 +2505,36 @@ of ``-W(no-)*``. This warning detects code that will be affected by this breaking change. +.. ghc-flag:: -Wdeprecated-type-abstractions + :shortdesc: warn when type abstractions in constructor patterns are used without enabling :extension:`TypeApplications` + :type: dynamic + :reverse: -Wno-deprecated-type-abstractions + :category: + + :since: 9.10.1 + :default: off + + Type abstractions in constructor patterns allow binding existential type variables: :: + + import Type.Reflection (Typeable, typeRep) + data Ex = forall e. (Typeable e, Show e) => MkEx e + showEx (MkEx @e a) = show a ++ " :: " ++ show (typeRep @e) + + Note the pattern ``MkEx @e a``, and specifically the ``@e`` binder. + + Support for this feature was added to GHC in version 9.2, but instead of getting + its own language extension the feature was enabled by a combination of + :extension:`TypeApplications` and :extension:`ScopedTypeVariables`. + As per `GHC Proposal #448 + `__ + and its amendment `#604 `__ + we are now transitioning towards guarding this feature behind :extension:`TypeAbstractions` instead. + + As a compatibility measure, GHC continues to support old programs that use type abstractions + in constructor patterns without enabling the appropriate extension :extension:`TypeAbstractions`, + but it will stop doing so in a future release. + + This warning detects code that will be affected by this breaking change. .. ghc-flag:: -Wincomplete-export-warnings :shortdesc: warn when some but not all of exports for a name are warned about ===================================== testsuite/tests/typecheck/should_fail/T23776.stderr ===================================== @@ -1,5 +1,5 @@ -T23776.hs:8:6: warning: [GHC-69797] +T23776.hs:8:6: error: [GHC-69797] [-Wdeprecated-type-abstractions (in -Wcompat), Werror=deprecated-type-abstractions] Type applications in constructor patterns will require - the TypeAbstractions extension starting from GHC 9.12. + the TypeAbstractions extension starting from GHC 9.14. Suggested fix: Perhaps you intended to use TypeAbstractions ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -703,7 +703,7 @@ test('VisFlag5', normal, compile_fail, ['']) test('T22684', normal, compile_fail, ['']) test('T23514a', normal, compile_fail, ['']) test('T22478c', normal, compile_fail, ['']) -test('T23776', normal, compile, ['']) # to become an error in GHC 9.12 +test('T23776', normal, compile_fail, ['']) # error due to -Werror=compat, scheduled to become an actual error in GHC 9.14 test('T17940', normal, compile_fail, ['']) test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always']) test('T24064', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b934c7eff9b5e4dbd7abbb42e7a5d89ab21f721 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b934c7eff9b5e4dbd7abbb42e7a5d89ab21f721 You're receiving 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 Nov 23 13:36:46 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Thu, 23 Nov 2023 08:36:46 -0500 Subject: [Git][ghc/ghc][wip/int-index/term-capture] Update Note Message-ID: <655f556e24888_18a390478d69811214c@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/term-capture at Glasgow Haskell Compiler / GHC Commits: 31a4bc49 by Vladislav Zavialov at 2023-11-23T16:36:22+03:00 Update Note - - - - - 1 changed file: - compiler/GHC/Rename/Env.hs Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1157,11 +1157,28 @@ that up instead. If that succeeds, use it. A side effect of demotion is that the renamer also allows actual term variables to occur at the type level: - t = True - x = Proxy @t -- Not good! - - GHC doesn't promote arbitrary terms to types. This is rejected in the type - checker via tcAddTermVarPlaceholders. + t = True -- Ordinary term-level binding + x = Proxy @t -- (1) Bad usage in a HsExpr + type T = t -- (2) Bad usage in a TyClDecl + f :: t -> t -- (3) Bad usage in a SigDecl + + GHC doesn't promote arbitrary terms to types, so the type checker has to + reject the uses of `t` shown above. This is achieved as follows: + + * In the HsExpr example (1) the type checker looks up `t` in the environment, + finds `ATcId`, and generates a `TermVariablePE` promotion error. + See the following clause in `tcTyVar`: + ATcId{} -> promotionErr name TermVariablePE + + * In the TyClDecl example (2) and SigDecl example (3), we don't have `ATcId` + in the environment just yet, because type declarations and signatures are + type-checked /before/ term-level bindings. + + To report a proper user-facing error message instead of a GHC panic, + we proactively populate the environment with the `TermVariablePE` promotion + error, one for each term variable in the current HsGroup (at the top level) + or in the current HsValBinds (at the level of local let/where bindings). + This is done with tactically placed calls to `tcAddTermVarPlaceholders`. (W2) Wrinkle 2 Only unqualified variable names are demoted, e.g. `f` but not `M.f`. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a4bc49f1d27bc34af613256838ffc8e3f7e20b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a4bc49f1d27bc34af613256838ffc8e3f7e20b You're receiving 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 Nov 23 16:04:00 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 23 Nov 2023 11:04:00 -0500 Subject: [Git][ghc/ghc][wip/andreask/expose-overloaded-unfoldings] Tidy: Expose unfoldings if they take dictionary arguments by default. Message-ID: <655f77f0208b2_18a3907c01f3c1228cb@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/expose-overloaded-unfoldings at Glasgow Haskell Compiler / GHC Commits: 86ef0161 by Andreas Klebinger at 2023-11-23T16:51:43+01:00 Tidy: Expose unfoldings if they take dictionary arguments by default. Add the flag `-fexpose-overloaded-unfoldings` to be able to control this behaviour. - - - - - 6 changed files: - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Tidy.hs - docs/users_guide/hints.rst - docs/users_guide/using-optimisation.rst Changes: ===================================== compiler/GHC/Driver/Config/Tidy.hs ===================================== @@ -36,6 +36,7 @@ initTidyOpts hsc_env = do , opt_unfolding_opts = unfoldingOpts dflags , opt_expose_unfoldings = if | gopt Opt_OmitInterfacePragmas dflags -> ExposeNone | gopt Opt_ExposeAllUnfoldings dflags -> ExposeAll + | gopt Opt_ExposeOverloadedUnfoldings dflags -> ExposeOverloaded | otherwise -> ExposeSome , opt_expose_rules = not (gopt Opt_OmitInterfacePragmas dflags) , opt_trim_ids = gopt Opt_OmitInterfacePragmas dflags ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -323,6 +323,7 @@ data GeneralFlag | Opt_IgnoreInterfacePragmas | Opt_OmitInterfacePragmas | Opt_ExposeAllUnfoldings + | Opt_ExposeOverloadedUnfoldings | Opt_KeepAutoRules -- ^Keep auto-generated rules even if they seem to have become useless | Opt_WriteInterface -- forces .hi files to be written even with -fno-code | Opt_WriteHie -- generate .hie files @@ -573,6 +574,7 @@ codeGenFlags = EnumSet.fromList -- Flags that affect generated code , Opt_ExposeAllUnfoldings + , Opt_ExposeOverloadedUnfoldings , Opt_NoTypeableBinds , Opt_Haddock ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2370,6 +2370,7 @@ fFlagsDeps = [ flagSpec "error-spans" Opt_ErrorSpans, flagSpec "excess-precision" Opt_ExcessPrecision, flagSpec "expose-all-unfoldings" Opt_ExposeAllUnfoldings, + flagSpec "expose-overloaded-unfoldings" Opt_ExposeOverloadedUnfoldings, flagSpec "keep-auto-rules" Opt_KeepAutoRules, flagSpec "expose-internal-symbols" Opt_ExposeInternalSymbols, flagSpec "external-dynamic-refs" Opt_ExternalDynamicRefs, ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -57,7 +57,7 @@ import GHC.Core.Tidy import GHC.Core.Seq ( seqBinds ) import GHC.Core.Opt.Arity ( exprArity, typeArity, exprBotStrictness_maybe ) import GHC.Core.InstEnv -import GHC.Core.Type ( Type, tidyTopType ) +import GHC.Core.Type import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Core.Class @@ -87,6 +87,8 @@ import GHC.Types.Name.Cache import GHC.Types.Avail import GHC.Types.Tickish import GHC.Types.TypeEnv +import GHC.Tc.Utils.TcType (tcSplitNestedSigmaTys) + import GHC.Unit.Module import GHC.Unit.Module.ModGuts @@ -100,6 +102,7 @@ import Data.Function import Data.List ( sortBy, mapAccumL ) import qualified Data.Set as S import GHC.Types.CostCentre +import GHC.Core.Predicate {- Constructing the TypeEnv, Instances, Rules from which the @@ -367,7 +370,9 @@ three places this is actioned: data UnfoldingExposure = ExposeNone -- ^ Don't expose unfoldings - | ExposeSome -- ^ Only expose required unfoldings + | ExposeSome -- ^ Expose based on regular inlining thresholds. + | ExposeOverloaded -- ^ Expose unfoldings useful for inlinings and those which + -- which might be specialised. | ExposeAll -- ^ Expose all unfoldings deriving (Show,Eq,Ord) @@ -805,6 +810,8 @@ addExternal opts id -- source is an inline rule || not dont_inline + + || isOverloaded id where dont_inline | never_active = True -- Will never inline @@ -821,6 +828,50 @@ addExternal opts id show_unfolding (DFunUnfolding {}) = True show_unfolding _ = False +isOverloaded :: Id -> Bool +isOverloaded fn = + let fun_type = idType fn + -- TODO: The specialiser currently doesn't handle newtypes of the + -- form `newtype T x = T (C x => x)` well. So we don't bother + -- looking through newtypes for constraints. + (_ty_vars, constraints, _ty) = tcSplitNestedSigmaTys fun_type + + in any (not . (\x -> isEqPred x || isEqPrimPred x)) constraints + +{- Note [Exposing overloaded functions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +See also #13090 and #22942. + +The basic idea is that exposing only overloaded function is reasonably cheap +but allows the specializer to fire more often as unfoldings for overloaded +functions will generally be available. So we make the unfoldings of overloaded +functions available by default. + +We use `tcSplitNestedSigmaTys` to see the constraints deep withing in types like: + f :: Int -> forall a. Eq a => blah + +We can't simply use isClassPred to check if any of the constraints responds to +a class dictionary because of programs like the one below: + + type family C a where + C Int = Eq Int + C Bool = Ord Bool + + + bar :: C a => a -> a -> Bool + bar = undefined + {-# SPECIALIZE bar :: Int -> Int -> Bool #-} + +GHC will specialize `bar` properly. However `C a =>` isn't recognized as class +predicate since it's a type family in the definition. To ensure it's exposed +anyway we allow for some false positives and merely try to rule out constraints +which we know to be useless to the specializer. Rather than looking for all useful +ones. + +This means we might expose a few unhelpful unfoldings. But it seems like the better +choice. +-} + {- ************************************************************************ * * ===================================== docs/users_guide/hints.rst ===================================== @@ -390,8 +390,9 @@ GHC requires the functions unfolding. The following flags can be used to control unfolding creation. Making their creation more or less likely: -* :ghc-flag:`-fexpose-all-unfoldings` * :ghc-flag:`-funfolding-creation-threshold=⟨n⟩` +* :ghc-flag:`-fexpose-overloaded-unfoldings` +* :ghc-flag:`-fexpose-all-unfoldings` Inlining decisions ~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -519,10 +519,38 @@ as such you shouldn't need to set any of them explicitly. A flag :default: off - An experimental flag to expose all unfoldings, even for very large + An flag to expose all unfoldings, even for very large or recursive functions. This allows for all functions to be inlined while usually GHC would avoid inlining larger functions. +.. ghc-flag:: -fexpose-overloaded-unfoldings + :shortdesc: Expose unfoldings which might be specialised, even for very large or recursive functions. + :type: dynamic + :reverse: -fno-expose-overloaded-unfoldings + :category: + + :default: off but enabled by :ghc-flag:`-O`. + + An experimental flag to expose overloaded unfoldings, even for very large + or recursive functions. This allows for these functions to be specialised + or inlined while usually GHC would avoid inlining or specialising larger functions. + + This is intended to be used for cases where specialization is considered + crucial but :ghc-flag:`-fexpose-all-unfoldings` imposes too much compile + time cost. + + Currently this won't expose unfoldings where a type class is hidden under a + newtype. That is for cases like: :: + + newtype NT a = NT (Integral a => a) + + foo :: NT a -> T1 -> TR + + GHC won't recognise `foo` as specialisable and won't expose the unfolding + even with the flag enabled. + + + .. ghc-flag:: -ffloat-in :shortdesc: Turn on the float-in transformation. Implied by :ghc-flag:`-O`. :type: dynamic @@ -1125,7 +1153,8 @@ as such you shouldn't need to set any of them explicitly. A flag regardless of size if its unfolding is available. This flag is not included in any optimisation level as it can massively increase code size. It can be used in conjunction with :ghc-flag:`-fexpose-all-unfoldings` - if you want to ensure all calls are specialised. + or :ghc-flag:`-fexpose-overloaded-unfoldings` if you want to ensure all calls + are specialised. .. ghc-flag:: -fcross-module-specialise View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86ef0161bd036977efb10f53789faf1cf482dcd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86ef0161bd036977efb10f53789faf1cf482dcd3 You're receiving 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 Nov 23 16:51:42 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 23 Nov 2023 11:51:42 -0500 Subject: [Git][ghc/ghc][wip/expand-do] - hpc ticks, Do not count pattern match failures, update hpc tests Message-ID: <655f831df0c36_18a3908f93258126759@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: dbd68512 by Apoorv Ingle at 2023-11-23T10:51:00-06:00 - hpc ticks, Do not count pattern match failures, update hpc tests - - - - - 5 changed files: - compiler/GHC/HsToCore/Ticks.hs - testsuite/tests/hpc/fork/hpc_fork.stdout - testsuite/tests/hpc/function/tough.stdout - testsuite/tests/hpc/function2/tough2.stdout - testsuite/tests/hpc/simple/hpc001.stdout Changes: ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -375,7 +375,7 @@ addTickLHsExpr e@(L pos e0) = do d <- getDensity case d of TickForBreakPoints | isGoodBreakExpr e0 -> tick_it - TickForCoverage -> tick_it + TickForCoverage | isGoodCoverageExpr e0 -> tick_it TickCallSites | isCallSite e0 -> tick_it _other -> dont_tick_it where @@ -393,7 +393,7 @@ addTickLHsExprRHS e@(L pos e0) = do case d of TickForBreakPoints | HsLet{} <- e0 -> dont_tick_it | otherwise -> tick_it - TickForCoverage -> tick_it + TickForCoverage | isGoodCoverageExpr e0 -> tick_it TickCallSites | isCallSite e0 -> tick_it _other -> dont_tick_it where @@ -409,7 +409,8 @@ addTickLHsExprEvalInner :: LHsExpr GhcTc -> TM (LHsExpr GhcTc) addTickLHsExprEvalInner e = do d <- getDensity case d of - TickForCoverage -> addTickLHsExprNever e + TickForCoverage | isGoodCoverageExpr (unLoc e) -> addTickLHsExpr e + | otherwise -> addTickLHsExprNever e _otherwise -> addTickLHsExpr e -- | A let body is treated differently from addTickLHsExprEvalInner @@ -440,29 +441,50 @@ addTickLHsExprNever (L pos e0) = do -- General heuristic: expressions which are calls (do not denote -- values) are good break points. isGoodBreakExpr :: HsExpr GhcTc -> Bool +isGoodBreakExpr (XExpr (ExpandedThingTc thing e)) + | OrigStmt (L _ BodyStmt{}) <- thing + = False + | OrigStmt (L _ BindStmt{}) <- thing + = False + | OrigStmt (L _ LastStmt{}) <- thing + = True + | otherwise + = isCallSite e isGoodBreakExpr e = isCallSite e +-- Should we add coverage ticks to this expr? +-- The general heuristic: Expanded `do`-stmts do not get +-- the coverage ticks as they are accounted for in the expansions +isGoodCoverageExpr :: HsExpr GhcTc -> Bool +isGoodCoverageExpr (XExpr (ExpandedThingTc thing _)) + | OrigStmt (L _ BodyStmt{}) <- thing + = False + | OrigStmt (L _ BindStmt{}) <- thing + = False + | OrigStmt (L _ LetStmt{}) <- thing + = False +isGoodCoverageExpr _ = True + + isCallSite :: HsExpr GhcTc -> Bool isCallSite HsApp{} = True isCallSite HsAppType{} = True isCallSite HsCase{} = True -isCallSite (XExpr (ExpandedThingTc thing e)) - | OrigStmt (L _ BodyStmt{}) <- thing - = False - | OrigStmt (L _ LastStmt{}) <- thing - = True - | otherwise +isCallSite (XExpr (ExpandedThingTc _ e)) = isCallSite e -- NB: OpApp, SectionL, SectionR are all expanded out isCallSite _ = False -addTickLHsExprOptAlt :: Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc) -addTickLHsExprOptAlt oneOfMany (L pos e0) - = ifDensity TickForCoverage +addTickLHsExprOptAlt :: Bool -> Bool {- is do expansion -} + -> LHsExpr GhcTc -> TM (LHsExpr GhcTc) +addTickLHsExprOptAlt oneOfMany isExpansion e@(L pos e0) + = if not (isExpansion) + then ifDensity TickForCoverage (allocTickBox (ExpBox oneOfMany) False False (locA pos) $ addTickHsExpr e0) - (addTickLHsExpr (L pos e0)) + (addTickLHsExpr e) + else (addTickLHsExprNever e) addBinTickLHsExpr :: (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc) addBinTickLHsExpr boxLabel (L pos e0) @@ -530,8 +552,8 @@ addTickHsExpr (HsCase x e mgs) = addTickHsExpr (HsIf x e1 e2 e3) = liftM3 (HsIf x) (addBinTickLHsExpr (BinBox CondBinBox) e1) - (addTickLHsExprOptAlt True e2) - (addTickLHsExprOptAlt True e3) + (addTickLHsExprOptAlt True False e2) + (addTickLHsExprOptAlt True False e3) addTickHsExpr (HsMultiIf ty alts) = do { let isOneOfMany = case alts of [_] -> False; _ -> True ; alts' <- mapM (traverse $ addTickGRHS isOneOfMany False False) alts @@ -661,7 +683,7 @@ addTickGRHSBody isOneOfMany isLambda isDoExp expr@(L pos e0) = do | XExpr (ExpandedThingTc thing _) <- e0 , OrigStmt (L _ LastStmt{}) <- thing -> addTickLHsExprRHS expr | isDoExp -> addTickLHsExprNever expr - TickForCoverage -> addTickLHsExprOptAlt isOneOfMany expr + TickForCoverage -> addTickLHsExprOptAlt isOneOfMany isDoExp expr TickAllFunctions | isLambda -> addPathEntry "\\" $ allocTickBox (ExpBox False) True{-count-} False{-not top-} (locA pos) $ ===================================== testsuite/tests/hpc/fork/hpc_fork.stdout ===================================== @@ -1,7 +1,7 @@ () - 53% expressions used (7/13) + 60% expressions used (6/10) 100% boolean coverage (0/0) 100% guards (0/0) 100% 'if' conditions (0/0) @@ -12,7 +12,7 @@ ---------- - 53% expressions used (7/13) + 60% expressions used (6/10) 100% boolean coverage (0/0) 100% guards (0/0) 100% 'if' conditions (0/0) @@ -67,10 +67,10 @@ table.dashboard { border-collapse: collapse ; border: solid 1px black }
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
- + - +
moduleTop Level DefinitionsAlternativesExpressions
%covered / total%covered / total%covered / total
  module Main100%1/1
0/0 53%7/13
100%1/1
0/0 60%6/10
  Program Coverage Total100%1/1
0/0 53%7/13
100%1/1
0/0 60%6/10
Writing: hpc_index_fun.html