Simon Jakobi pushed to branch wip/sjakobi/T27804-findsplice-order at Glasgow Haskell Compiler / GHC Commits: ed6b480a by Simon Jakobi at 2026-10-08T23:12:37+02:00 Rename: Build every HsGroup list in source order in findSplice Since 24e89c40b77 replaced the Bag of bindings with a list, add_bind appended each top-level binding with `bs ++ [VbBind b]`. For a module with n top-level bindings that is O(n^2) allocation, and the n-deep chain of thunks needs O(n) stack to force (#27804). findSplice now walks the declarations once, accumulating the group's prefix in reverse, and then conses each declaration onto its list with a strict fold. Every list in the HsGroup ends up in source order with O(1) work per declaration and constant stack. Previously the bindings were in source order and all other lists reversed. The order of the bindings matters: the specialiser, CSE and error recovery all follow it, and tests such as T21848, T9441a and T26098_local change behaviour when it is reversed. The order of the other lists only decides which of several duplicate declarations an error points at, the order of dumps and splices, and unique numbering, which is what the updated expected outputs reflect. One real difference: reify now lists a class's instances in a different order, because the instance environment is keyed by insertion order. T11629 hard-coded the old order and now checks membership instead. On my machine, with a quick-flavour build, bytes allocated for the ticket's 16000-binding reproducer go from about 68 GB to 46 GB, the same 22 GB saving the ticket attributes to the append. Fixes #27804. Assisted-by: Claude Fable 5.1 - - - - - 38 changed files: - compiler/GHC/Rename/Module.hs - testsuite/tests/module/mod27.stderr - testsuite/tests/module/mod58.stderr - testsuite/tests/module/mod68.stderr - testsuite/tests/rename/should_fail/RnMultipleFixityFail.stderr - testsuite/tests/rename/should_fail/T14032c.stderr - testsuite/tests/rename/should_fail/T5589.stderr - testsuite/tests/rename/should_fail/T7338.stderr - testsuite/tests/rename/should_fail/T7338a.stderr - testsuite/tests/rename/should_fail/rn_dup.stderr - testsuite/tests/rename/should_fail/rnfail048.stderr - testsuite/tests/rename/should_fail/rnfail058.stderr - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles13.stderr - testsuite/tests/roles/should_compile/Roles2.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/roles/should_fail/Roles8.stderr - testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr - testsuite/tests/simplCore/should_compile/T22309.stderr - testsuite/tests/simplCore/should_compile/T8274.stdout - testsuite/tests/th/T11629.hs - testsuite/tests/th/T13776.stderr - testsuite/tests/th/T15360b.stderr - testsuite/tests/th/T15365.stderr - testsuite/tests/th/T16183.stderr - testsuite/tests/th/T17296.stderr - testsuite/tests/th/T17394.stderr - testsuite/tests/th/T17608.stderr - testsuite/tests/th/T1835.stdout - testsuite/tests/th/T24299.stderr - testsuite/tests/th/T24911.stderr - testsuite/tests/th/T6018th.stderr - testsuite/tests/th/T8953.stderr - testsuite/tests/th/TH_reifyDecl1.stderr - testsuite/tests/typecheck/should_fail/T11356.stderr - testsuite/tests/typecheck/should_fail/T6018fail.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed6b480aafed791a6d042f64d37403c1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed6b480aafed791a6d042f64d37403c1... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help