[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Document etymology of "bind" as the name for `>>=`
by Marge Bot (@marge-bot) 25 Sep '25
by Marge Bot (@marge-bot) 25 Sep '25
25 Sep '25
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
7b5b200e by Irene Knapp at 2025-09-25T04:47:16-04:00
Document etymology of "bind" as the name for `>>=`
It took me twenty years of contemplation to realize why it's called that.
I therefore feel that it may not be obvious to beginners.
- - - - -
7763cc60 by Brandon Chinn at 2025-09-25T04:47:18-04:00
Fix tabs in string gaps (#26415)
Tabs in string gaps were broken in bb030d0d because previously, string gaps were manually parsed, but now it's lexed by the usual Alex grammar and post-processed after successful lexing.
It broke because of a discrepancy between GHC's lexer grammar and the Haskell Report. The Haskell Report includes tabs in whitechar:
whitechar → newline | vertab | space | tab | uniWhite
$whitechar used to include tabs until 18 years ago, when it was removed in order to exclude tabs from $white_no_nl in order to warn on tabs: 6e202120. In this MR, I'm adding \t back into $whitechar, and explicitly excluding \t from the $white_no_nl+ rule ignoring all whitespace in source code, which more accurately colocates the "ignore all whitespace except tabs, which is handled in the next line" logic.
As a side effect of this MR, tabs are now allowed in pragmas; currently, a pragma written as {-# \t LANGUAGE ... #-} is interpreted as the tab character being the pragma name, and GHC warns "Unrecognized pragma". With this change, tabs are ignored as whitespace, which more closely matches the Report anyway.
- - - - -
893a94de by Cheng Shao at 2025-09-25T04:47:18-04:00
wasm: remove the --no-turbo-fast-api-calls hack from dynamic linker shebang
This patch removes the `--no-turbo-fast-api-calls` hack from the dyld
script shebang; it was used to workaround v8 fast call coredumps in
nodejs and no longer needed, and comes with a performance penalty,
hence the removal.
- - - - -
7 changed files:
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/Lexer/String.x
- libraries/ghc-internal/src/GHC/Internal/Base.hs
- + testsuite/tests/parser/should_run/T26415.hs
- + testsuite/tests/parser/should_run/T26415.stdout
- testsuite/tests/parser/should_run/all.T
- utils/jsffi/dyld.mjs
Changes:
=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -145,7 +145,7 @@ import GHC.Parser.String
$unispace = \x05 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$nl = [\n\r\f]
$space = [\ $unispace]
-$whitechar = [$nl \v $space]
+$whitechar = [$nl \t \v $space]
$white_no_nl = $whitechar # \n -- TODO #8424
$tab = \t
@@ -248,7 +248,7 @@ haskell :-
-- Alex "Rules"
-- everywhere: skip whitespace
-$white_no_nl+ ;
+($white_no_nl # \t)+ ;
$tab { warnTab }
-- Everywhere: deal with nested comments. We explicitly rule out
=====================================
compiler/GHC/Parser/Lexer/String.x
=====================================
@@ -25,7 +25,7 @@ import GHC.Utils.Panic (panic)
$unispace = \x05 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$nl = [\n\r\f]
$space = [\ $unispace]
-$whitechar = [$nl \v $space]
+$whitechar = [$nl \t \v $space]
$tab = \t
$ascdigit = 0-9
=====================================
libraries/ghc-internal/src/GHC/Internal/Base.hs
=====================================
@@ -1353,9 +1353,9 @@ class Applicative m => Monad m where
-- bs a
-- @
--
- -- An alternative name for this function is \'bind\', but some people
- -- may refer to it as \'flatMap\', which results from it being equivalent
- -- to
+ -- An alternative name for this function is \'bind\', because it
+ -- is used to introduce bindings in monadic contexts, but some people may
+ -- refer to it as \'flatMap\', which results from it being equivalent to
--
-- @\\x f -> 'join' ('fmap' f x) :: Monad m => m a -> (a -> m b) -> m b@
--
=====================================
testsuite/tests/parser/should_run/T26415.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE MultilineStrings #-}
+
+main :: IO ()
+main = do
+ -- The below strings contain the characters ['\\', '\t', '\\']
+ print "\ \"
+ print """\ \"""
=====================================
testsuite/tests/parser/should_run/T26415.stdout
=====================================
@@ -0,0 +1,2 @@
+""
+""
=====================================
testsuite/tests/parser/should_run/all.T
=====================================
@@ -27,6 +27,7 @@ test('RecordDotSyntax4', [extra_files(['RecordDotSyntaxA.hs'])], multimod_compil
test('RecordDotSyntax5', normal, compile_and_run, [''])
test('ListTuplePunsConstraints', extra_files(['ListTuplePunsConstraints.hs']), ghci_script, ['ListTuplePunsConstraints.script'])
test('T25937', normal, compile_and_run, [''])
+test('T26415', normal, compile_and_run, [''])
# Multiline strings
test('MultilineStrings', normal, compile_and_run, [''])
=====================================
utils/jsffi/dyld.mjs
=====================================
@@ -1,4 +1,4 @@
-#!/usr/bin/env -S node --disable-warning=ExperimentalWarning --max-old-space-size=65536 --no-turbo-fast-api-calls --wasm-lazy-validation
+#!/usr/bin/env -S node --disable-warning=ExperimentalWarning --max-old-space-size=65536 --wasm-lazy-validation
// Note [The Wasm Dynamic Linker]
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3348ba4031ae28ed49a85cefcd5199…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3348ba4031ae28ed49a85cefcd5199…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Allow disabling builtin rules (#20298)
by Marge Bot (@marge-bot) 25 Sep '25
by Marge Bot (@marge-bot) 25 Sep '25
25 Sep '25
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
5ae89054 by Sylvain Henry at 2025-09-24T17:07:00-04:00
Allow disabling builtin rules (#20298)
Add a way to disable built-in rules programmatically and with a debug flag.
I also took the opportunity to add a debug flag to disable bignum rules,
which was only possible programmatically (e.g. in a plugin).
- - - - -
135242ca by Rodrigo Mesquita at 2025-09-24T17:07:44-04:00
Don't use build CFLAGS and friends as target settings
In the GHC in tree configure, `CFLAGS`, `CXXFLAGS`, and similar tool
configuration flags apply to the BUILD phase of the compiler, i.e. to
the tools run to compile GHC itself.
Notably, they should /not/ be carried over to the Target settings, i.e.
these flags should /not/ apply to the tool which GHC invokes at runtime.
Fixes #25637
- - - - -
575cdf21 by Brandon Chinn at 2025-09-24T20:14:01-04:00
Fix tabs in string gaps (#26415)
Tabs in string gaps were broken in bb030d0d because previously, string gaps were manually parsed, but now it's lexed by the usual Alex grammar and post-processed after successful lexing.
It broke because of a discrepancy between GHC's lexer grammar and the Haskell Report. The Haskell Report includes tabs in whitechar:
whitechar → newline | vertab | space | tab | uniWhite
$whitechar used to include tabs until 18 years ago, when it was removed in order to exclude tabs from $white_no_nl in order to warn on tabs: 6e202120. In this MR, I'm adding \t back into $whitechar, and explicitly excluding \t from the $white_no_nl+ rule ignoring all whitespace in source code, which more accurately colocates the "ignore all whitespace except tabs, which is handled in the next line" logic.
As a side effect of this MR, tabs are now allowed in pragmas; currently, a pragma written as {-# \t LANGUAGE ... #-} is interpreted as the tab character being the pragma name, and GHC warns "Unrecognized pragma". With this change, tabs are ignored as whitespace, which more closely matches the Report anyway.
- - - - -
3348ba40 by Cheng Shao at 2025-09-24T20:14:02-04:00
wasm: remove the --no-turbo-fast-api-calls hack from dynamic linker shebang
This patch removes the `--no-turbo-fast-api-calls` hack from the dyld
script shebang; it was used to workaround v8 fast call coredumps in
nodejs and no longer needed, and comes with a performance penalty,
hence the removal.
- - - - -
23 changed files:
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Rules/Config.hs
- compiler/GHC/Driver/Config/Core/Rules.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/Lexer/String.x
- configure.ac
- docs/users_guide/debugging.rst
- m4/fp_setup_windows_toolchain.m4
- m4/ghc_toolchain.m4
- + testsuite/tests/codeGen/should_compile/T20298a.hs
- + testsuite/tests/codeGen/should_compile/T20298a.stderr
- + testsuite/tests/codeGen/should_compile/T20298b.hs
- + testsuite/tests/codeGen/should_compile/T20298b.stderr
- + testsuite/tests/codeGen/should_compile/T20298c.hs
- + testsuite/tests/codeGen/should_compile/T20298c.stderr
- testsuite/tests/codeGen/should_compile/all.T
- + testsuite/tests/parser/should_run/T26415.hs
- + testsuite/tests/parser/should_run/T26415.stdout
- testsuite/tests/parser/should_run/all.T
- utils/jsffi/dyld.mjs
Changes:
=====================================
compiler/GHC/Core/Opt/ConstantFold.hs
=====================================
@@ -2173,6 +2173,43 @@ builtinRules
-- there is no benefit to inlining these yet, despite this, GHC produces
-- unfoldings for this regardless since the floated list entries look small.
+
+
+{- Note [Built-in bignum rules]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+We have some built-in rules for operations on bignum types (Integer, Natural,
+BigNat). These rules implement the same kind of constant folding as we have for
+Int#/Word#/etc. primops. See builtinBignumRules.
+
+These rules are built-in because they can't be expressed as regular rules for
+now. The reason is that due to the let-can-float invariant (see Note [Core
+let-can-float invariant] in GHC.Core), GHC is too conservative with some bignum
+operations and they don't match rules. For example:
+
+ case integerAdd 1 x of r { _ -> integerAdd 1 r }
+
+doesn't constant-fold into `integerAdd 2 x` with a regular rule. That's because
+GHC never floats in `integerAdd 1 x` to form `integerAdd 1 (integerAdd 1 x)`
+because of the let-can-float invariant (it doesn't know if `integerAdd`
+terminates).
+
+In the built-in rule for `integerAdd` we can access the unfolding of `r` and we
+can perform the appropriate substitution.
+
+To support constant-folding, Bignum operations are not allowed to inline. As a
+consequence, some codes that would benefit from inlining of bignum operations
+don't. An idea to fix this was to only have built-in rules for BigNat#
+operations and to allow Integer and Natural operations to inline. However these
+operations are often too big to inline and we end up with broken
+constant-folding and still no inlining. This issue is tracked in #20361
+
+Bignum built-in rules can be disabled independently of other built-in rules by
+passing the -dno-bignum-rules flag or programmatically with the `roBignumRules` field of
+RuleOpts.
+
+-}
+
+-- | Built-in bignum rules (see Note [Built-in bignum rules])
builtinBignumRules :: [CoreRule]
builtinBignumRules =
[ -- conversions
=====================================
compiler/GHC/Core/Rules.hs
=====================================
@@ -65,6 +65,7 @@ import GHC.Core.Map.Expr ( eqCoreExpr )
import GHC.Core.Opt.Arity( etaExpandToJoinPointRule )
import GHC.Core.Make ( mkCoreLams )
import GHC.Core.Opt.OccurAnal( occurAnalyseExpr )
+import GHC.Core.Rules.Config (roBuiltinRules)
import GHC.Tc.Utils.TcType ( tcSplitTyConApp_maybe )
import GHC.Builtin.Types ( anyTypeOfKind )
@@ -708,10 +709,8 @@ matchRule :: HasDebugCallStack
matchRule opts rule_env _is_active fn args _rough_args
(BuiltinRule { ru_try = match_fn })
--- Built-in rules can't be switched off, it seems
- = case match_fn opts rule_env fn args of
- Nothing -> Nothing
- Just expr -> Just expr
+ | not (roBuiltinRules opts) = Nothing
+ | otherwise = match_fn opts rule_env fn args
matchRule _ rule_env is_active _ args rough_args
(Rule { ru_name = rule_name, ru_act = act, ru_rough = tpl_tops
=====================================
compiler/GHC/Core/Rules/Config.hs
=====================================
@@ -14,6 +14,10 @@ data RuleOpts = RuleOpts
, roExcessRationalPrecision :: !Bool
-- ^ Cut down precision of Rational values to that of Float/Double if disabled
, roBignumRules :: !Bool
- -- ^ Enable rules for bignums
+ -- ^ Enable built-in bignum rules (requires roBuiltinRules to be True too)
+ --
+ -- See Note [Built-in bignum rules] in GHC.Core.Opt.ConstantFold
+ , roBuiltinRules :: !Bool
+ -- ^ Enable or disable all builtin rules (including bignum rules)
}
=====================================
compiler/GHC/Driver/Config/Core/Rules.hs
=====================================
@@ -15,5 +15,6 @@ initRuleOpts dflags = RuleOpts
{ roPlatform = targetPlatform dflags
, roNumConstantFolding = gopt Opt_NumConstantFolding dflags
, roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags
- , roBignumRules = True
+ , roBignumRules = not (gopt Opt_NoBignumRules dflags)
+ , roBuiltinRules = not (gopt Opt_NoBuiltinRules dflags)
}
=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -592,6 +592,8 @@ data GeneralFlag
| Opt_NoLlvmMangler -- hidden flag
| Opt_FastLlvm -- hidden flag
| Opt_NoTypeableBinds
+ | Opt_NoBuiltinRules
+ | Opt_NoBignumRules
| Opt_DistinctConstructorTables
| Opt_InfoTableMap
@@ -973,6 +975,8 @@ codeGenFlags = EnumSet.fromList
, Opt_ExposeAllUnfoldings
, Opt_ExposeOverloadedUnfoldings
, Opt_NoTypeableBinds
+ , Opt_NoBuiltinRules
+ , Opt_NoBignumRules
, Opt_ObjectDeterminism
, Opt_Haddock
=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -1660,6 +1660,10 @@ dynamic_flags_deps = [
(NoArg (setGeneralFlag Opt_NoLlvmMangler)) -- hidden flag
, make_ord_flag defGhcFlag "dno-typeable-binds"
(NoArg (setGeneralFlag Opt_NoTypeableBinds))
+ , make_ord_flag defGhcFlag "dno-builtin-rules"
+ (NoArg (setGeneralFlag Opt_NoBuiltinRules))
+ , make_ord_flag defGhcFlag "dno-bignum-rules"
+ (NoArg (setGeneralFlag Opt_NoBignumRules))
, make_ord_flag defGhcFlag "ddump-debug"
(setDumpFlag Opt_D_dump_debug)
, make_dep_flag defGhcFlag "ddump-json"
=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -145,7 +145,7 @@ import GHC.Parser.String
$unispace = \x05 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$nl = [\n\r\f]
$space = [\ $unispace]
-$whitechar = [$nl \v $space]
+$whitechar = [$nl \t \v $space]
$white_no_nl = $whitechar # \n -- TODO #8424
$tab = \t
@@ -248,7 +248,7 @@ haskell :-
-- Alex "Rules"
-- everywhere: skip whitespace
-$white_no_nl+ ;
+($white_no_nl # \t)+ ;
$tab { warnTab }
-- Everywhere: deal with nested comments. We explicitly rule out
=====================================
compiler/GHC/Parser/Lexer/String.x
=====================================
@@ -25,7 +25,7 @@ import GHC.Utils.Panic (panic)
$unispace = \x05 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$nl = [\n\r\f]
$space = [\ $unispace]
-$whitechar = [$nl \v $space]
+$whitechar = [$nl \t \v $space]
$tab = \t
$ascdigit = 0-9
=====================================
configure.ac
=====================================
@@ -43,12 +43,6 @@ dnl interprets build/host/target and how this interacts with $CC tests
test -n "$target_alias" && ac_tool_prefix=$target_alias-
dnl ----------------------------------------------------------
-dnl ** Store USER specified environment variables to pass them on to
-dnl ** ghc-toolchain (in m4/ghc-toolchain.m4)
-USER_CFLAGS="$CFLAGS"
-USER_LDFLAGS="$LDFLAGS"
-USER_LIBS="$LIBS"
-USER_CXXFLAGS="$CXXFLAGS"
dnl The lower-level/not user-facing environment variables that may still be set
dnl by developers such as in ghc-wasm-meta
USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
=====================================
docs/users_guide/debugging.rst
=====================================
@@ -1225,6 +1225,18 @@ Other
compiler will panic if you try to use Typeable instances of things that you
built with this flag.
+.. ghc-flag:: -dno-builtin-rules
+ :shortdesc: Disable all built-in rewrite rules
+ :type: dynamic
+
+ This disables all the built-in rewrite rules. Mostly useful for debugging.
+
+.. ghc-flag:: -dno-bignum-rules
+ :shortdesc: Disable bignum built-in rewrite rules
+ :type: dynamic
+
+ This disables bignum built-in rewrite rules. Mostly useful for debugging.
+
.. ghc-flag:: -dtag-inference-checks
:shortdesc: Affirm tag inference results are correct at runtime.
:type: dynamic
=====================================
m4/fp_setup_windows_toolchain.m4
=====================================
@@ -146,11 +146,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
dnl We override the USER_* flags here since the user delegated
dnl configuration to the bundled windows toolchain, and these are the
dnl options required by the bundled windows toolchain.
- USER_CFLAGS="$CFLAGS"
USER_CPP_ARGS="$CONF_CPP_OPTS_STAGE2"
- USER_CXXFLAGS="$CXXFLAGS"
USER_HS_CPP_ARGS="$HaskellCPPArgs"
- USER_LDFLAGS="$CONF_GCC_LINKER_OPTS_STAGE2"
+ USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
+ USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2"
+ USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2"
USER_JS_CPP_ARGS="$JavaScriptCPPArgs"
USER_CMM_CPP_ARGS="$CmmCPPArgs"
])
=====================================
m4/ghc_toolchain.m4
=====================================
@@ -8,18 +8,6 @@ AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG],
done
])
-dnl $1 argument name
-dnl $2 first variable to try
-dnl $3 variable to add if the first variable is empty
-AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG_CHOOSE],
-[
- if test -z "$2"; then
- ADD_GHC_TOOLCHAIN_ARG([$1],[$3])
- else
- ADD_GHC_TOOLCHAIN_ARG([$1],[$2])
- fi
-])
-
AC_DEFUN([ENABLE_GHC_TOOLCHAIN_ARG],
[
if test "$2" = "YES"; then
@@ -123,10 +111,9 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
ENABLE_GHC_TOOLCHAIN_ARG([dwarf-unwind], [$enable_dwarf_unwind])
dnl We store USER_* variants of all user-specified flags to pass them over to ghc-toolchain.
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-opt], [$USER_CONF_CC_OPTS_STAGE2], [$USER_CFLAGS])
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2], [$USER_LDFLAGS])
- ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_LIBS])
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2], [$USER_CXXFLAGS])
+ ADD_GHC_TOOLCHAIN_ARG([cc-opt], [$USER_CONF_CC_OPTS_STAGE2])
+ ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2])
+ ADD_GHC_TOOLCHAIN_ARG([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2])
ADD_GHC_TOOLCHAIN_ARG([cpp-opt], [$USER_CPP_ARGS])
ADD_GHC_TOOLCHAIN_ARG([hs-cpp-opt], [$USER_HS_CPP_ARGS])
ADD_GHC_TOOLCHAIN_ARG([js-cpp-opt], [$USER_JS_CPP_ARGS])
=====================================
testsuite/tests/codeGen/should_compile/T20298a.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298a where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298a.stderr
=====================================
@@ -0,0 +1,9 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 3, types: 1, coercions: 0, joins: 0/0}
+
+foo = IS 30#
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/T20298b.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298b where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298b.stderr
=====================================
@@ -0,0 +1,13 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 10, types: 3, coercions: 0, joins: 0/0}
+
+foo2 = IS 10#
+
+foo1 = IS 20#
+
+foo = integerAdd foo2 foo1
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/T20298c.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298c where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298c.stderr
=====================================
@@ -0,0 +1,13 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 11, types: 4, coercions: 0, joins: 0/0}
+
+foo2 = IS 10#
+
+foo1 = IS 20#
+
+foo = + $fNumInteger foo2 foo1
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/all.T
=====================================
@@ -145,3 +145,7 @@ test('T25166', [req_cmm], makefile_test, [])
test('T25177', normal, compile, ['-O2 -dno-typeable-binds -ddump-simpl -dsuppress-all -dsuppress-uniques -v0'])
test('T16351', normal, compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+
+test('T20298a', normal, compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+test('T20298b', normal, compile, ['-O2 -dno-bignum-rules -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+test('T20298c', normal, compile, ['-O2 -dno-builtin-rules -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
=====================================
testsuite/tests/parser/should_run/T26415.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE MultilineStrings #-}
+
+main :: IO ()
+main = do
+ -- The below strings contain the characters ['\\', '\t', '\\']
+ print "\ \"
+ print """\ \"""
=====================================
testsuite/tests/parser/should_run/T26415.stdout
=====================================
@@ -0,0 +1,2 @@
+""
+""
=====================================
testsuite/tests/parser/should_run/all.T
=====================================
@@ -27,6 +27,7 @@ test('RecordDotSyntax4', [extra_files(['RecordDotSyntaxA.hs'])], multimod_compil
test('RecordDotSyntax5', normal, compile_and_run, [''])
test('ListTuplePunsConstraints', extra_files(['ListTuplePunsConstraints.hs']), ghci_script, ['ListTuplePunsConstraints.script'])
test('T25937', normal, compile_and_run, [''])
+test('T26415', normal, compile_and_run, [''])
# Multiline strings
test('MultilineStrings', normal, compile_and_run, [''])
=====================================
utils/jsffi/dyld.mjs
=====================================
@@ -1,4 +1,4 @@
-#!/usr/bin/env -S node --disable-warning=ExperimentalWarning --max-old-space-size=65536 --no-turbo-fast-api-calls --wasm-lazy-validation
+#!/usr/bin/env -S node --disable-warning=ExperimentalWarning --max-old-space-size=65536 --wasm-lazy-validation
// Note [The Wasm Dynamic Linker]
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/807f5c863ecdcafa4335523cf3600a…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/807f5c863ecdcafa4335523cf3600a…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T23162-spj] 69 commits: Use mkVirtHeapOffsets for reconstructing terms in RTTI
by Simon Peyton Jones (@simonpj) 24 Sep '25
by Simon Peyton Jones (@simonpj) 24 Sep '25
24 Sep '25
Simon Peyton Jones pushed to branch wip/T23162-spj at Glasgow Haskell Compiler / GHC
Commits:
8f3d80ff by Luite Stegeman at 2025-09-13T08:43:09+02:00
Use mkVirtHeapOffsets for reconstructing terms in RTTI
This makes mkVirtHeapOffsets the single source of truth for
finding field offsets in closures.
- - - - -
eb389338 by Luite Stegeman at 2025-09-13T08:43:09+02:00
Sort non-pointer fields by size for more efficient packing
This sorts non-pointer fields in mkVirtHeapOffsets, always
storing the largest field first. The relative order of
equally sized fields remains unchanged.
This reduces wasted padding/alignment space in closures with
differently sized fields.
- - - - -
99b233f4 by Alison at 2025-09-13T16:51:04-04:00
ghc-heap: Fix race condition with profiling builds
Apply the same fix from Closures.hs (64fd0fac83) to Heap.hs by adding
empty imports to make way-dependent dependencies visible to `ghc -M`.
Fixes #15197, #26407
- - - - -
77deaa7a by Cheng Shao at 2025-09-14T21:29:45-04:00
hadrian: build in-tree gmp with -fvisibility=hidden
When hadrian builds in-tree gmp, it should build the shared objects
with -fvisibility=hidden. The gmp symbols are only used by bignum
logic in ghc-internal and shouldn't be exported by the ghc-internal
shared library. We should always strive to keep shared library symbol
table lean, which benefits platforms with slow dynamic linker or even
hard limits about how many symbols can be exported (e.g. macos dyld,
win32 dll and wasm dyld).
- - - - -
42a18960 by Cheng Shao at 2025-09-14T21:30:26-04:00
Revert "wasm: add brotli compression for ghci browser mode"
This reverts commit 731217ce68a1093b5f9e26a07d5bd2cdade2b352.
Benchmarks show non-negligible overhead when browser runs on the same
host, which is the majority of actual use cases.
- - - - -
e6755b9f by Cheng Shao at 2025-09-14T21:30:26-04:00
wasm: remove etag logic in ghci browser mode web server
This commit removes the etag logic in dyld script's ghci browser mode
web server. It was meant to support caching logic of wasm shared
libraries, but even if the port is manually specified to make caching
even relevant, for localhost the extra overhead around etag logic is
simply not worth it according to benchmarks.
- - - - -
ac5859b9 by sheaf at 2025-09-16T14:58:38-04:00
Add 'Outputable Natural' instance
This commit adds an Outputable instance for the Natural natural-number type,
as well as a "natural :: Natural -> SDoc" function that mirrors the existing
"integer" function.
- - - - -
d48ebc23 by Cheng Shao at 2025-09-16T14:59:18-04:00
autoconf: emit warning instead of error for FIND_PYTHON logic
This patch makes FIND_PYTHON logic emit warning instead of error, so
when the user doesn't expect to run the testsuite driver (especially
when installing a bindist), python would not be mandatory. Fixes #26347.
- - - - -
54b5950e by Sylvain Henry at 2025-09-17T04:45:18-04:00
Print fully qualified unit names in name mismatch
It's more user-friendly to directly print the right thing instead of
requiring the user to retry with the additional `-dppr-debug` flag.
- - - - -
403cb665 by Ben Gamari at 2025-09-17T04:46:00-04:00
configure: Fix consistency between distrib and source CC check
Previously distrib/configure.ac did not
include `cc`.
Closes #26394.
- - - - -
2dcd4cb9 by Oleg Grenrus at 2025-09-17T04:46:41-04:00
Use isPrint in showUnique
The comment say
```
-- Avoid emitting non-printable characters in pretty uniques. See #25989.
```
so let the code do exactly that.
There are tags (at least : and 0 .. 9) which weren't in A .. z range.
- - - - -
e5dd754b by Oleg Grenrus at 2025-09-17T04:46:42-04:00
Shorten in-module links in hyperlinked source
Instead of href="This.Module#ident" to just "#ident"
- - - - -
63189b2c by Oleg Grenrus at 2025-09-17T04:46:42-04:00
Use showUnique in internalAnchorIdent
Showing the key of Unique as a number is generally not a great idea.
GHC Unique has a tag in high bits, so the raw number is unnecessarily
big.
So now we have
```html
<a href="#l-rvgK"><span class="hs-identifier hs-var hs-var">bar</span></a>
```
instead of
```html
<a href="#local-6989586621679015689"><span class="hs-identifier hs-var hs-var">bar</span></a>
```
Together with previous changes of shorter intra-module links the effect
on compressed files is not huge, that is expected as we simply remove
repetitive contents which pack well.
```
12_694_206 Agda-2.9.0-docs-orig.tar.gz
12_566_065 Agda-2.9.0-docs.tar.gz
```
However when unpacked, the difference can be significant,
e.g. Agda's largest module source got 5% reduction:
```
14_230_117 Agda.Syntax.Parser.Parser.html
13_422_109 Agda.Syntax.Parser.Parser.html
```
The whole hyperlinked source code directory got similar reduction
```
121M Agda-2.9.0-docs-orig/src
114M Agda-2.9.0-docs/src
```
For the reference, sources are about 2/3 of the generated haddocks
```
178M Agda-2.9.0-docs-old
172M Agda-2.9.0-docs
```
so we get around 3.5% size reduction overall. Not bad for a small local
changes.
- - - - -
6f63f57b by Stefan Schulze Frielinghaus at 2025-09-17T04:47:22-04:00
rts: Fix alignment for gen_workspace #26334
After a0fa4941903272c48b050d24e93eec819eff51bd bootstrap is broken on
s390x and errors out with
rts/sm/GCThread.h:207:5: error:
error: alignment of array elements is greater than element size
207 | gen_workspace gens[];
| ^~~~~~~~~~~~~
The alignment constraint is applied via the attribute to the type
gen_workspace and leaves the underlying type struct gen_workspace_
untouched. On Aarch64, x86, and s390x the struct has a size of 128
bytes. On Aarch64 and x86 the alignments of 128 and 64 are divisors of
the size, respectively, which is why the type is a viable member type
for an array. However, on s390x, the alignment is 256 and therefore is
not a divisor of the size and hence cannot be used for arrays.
Basically I see two fixes here. Either decrease the alignment
requirement on s390x, or by applying the alignment constraint on the
struct itself. The former might affect performance as noted in
a0fa4941903272c48b050d24e93eec819eff51bd. The latter introduces padding
bits whenever necessary in order to ensure that
sizeof(gen_workspace[N])==N*sizeof(gen_workspace) holds which is done by
this patch.
- - - - -
06d25623 by Cheng Shao at 2025-09-17T19:32:27-04:00
ghci: add :shell command
This patch adds a new :shell command to ghci which works similarly to
:!, except it guarantees to run the command via sh -c. On POSIX hosts
the behavior is identical to :!, but on Windows it uses the msys2
shell instead of system cmd.exe shell. This is convenient when writing
simple ghci scripts that run simple POSIX commands, and the behavior
can be expected to be coherent on both Windows and POSIX.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
186054f7 by Cheng Shao at 2025-09-17T19:32:27-04:00
testsuite: remove legacy :shell trick
This commit makes use of the built-in :shell functionality in ghci in
the test cases, and remove the legacy :shell trick.
- - - - -
0a3a4aa3 by Cheng Shao at 2025-09-17T19:32:27-04:00
docs: document :shell in ghci
This commit documents the :shell command in ghci.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
a4ff12bb by Cheng Shao at 2025-09-17T19:33:09-04:00
ghc-internal: fix codepages program
codepages was not properly updated during the base -> ghc-internal
migration, this commit fixes it.
- - - - -
7e094def by Cheng Shao at 2025-09-17T19:33:09-04:00
ghc-internal: relax ucd2haskell cabal upper bounds
This commit relaxes ucd2haskell cabal upper bounds to make it runnable
via ghc 9.12/9.14.
- - - - -
7077c9f7 by Cheng Shao at 2025-09-17T19:33:09-04:00
ghc-internal: update to unicode 17.0.0
This commit updates the generated code in ghc-internal to match
unicode 17.0.0.
- - - - -
cef8938f by sheaf at 2025-09-17T19:34:09-04:00
Bad record update msg: allow out-of-scope datacons
This commit ensures that, when we encounter an invalid record update
(because no constructor exists which contains all of the record fields
mentioned in the record update), we graciously handle the situation in
which the constructors themselves are not in scope. In that case,
instead of looking up the constructors in the GlobalRdrEnv, directly
look up their GREInfo using the lookupGREInfo function.
Fixes #26391
- - - - -
a2d9d7c2 by sheaf at 2025-09-17T19:34:09-04:00
Improve Notes about disambiguating record updates
This commit updates the notes [Disambiguating record updates] and
[Type-directed record disambiguation], in particular adding more
information about the deprecation status of type-directed disambiguation
of record updates.
- - - - -
de44e69e by sheaf at 2025-09-19T05:16:51-04:00
Enable TcM plugins in initTc
This commit ensures that we run typechecker plugins and defaulting
plugins whenever we call initTc.
In particular, this ensures that the pattern-match checker, which calls
'initTcDsForSolver' which calls 'initTc', runs with typechecker plugins
enabled. This matters for situations like:
merge :: Vec n a -> Vec n a -> Vec (2 * n) a
merge Nil Nil = Nil
merge (a <: as) (b <: bs) = a :< (b <: merge as bs)
in which we need the typechecker plugin to run in order to tell us that
the Givens would be inconsistent in the additional equation
merge (_ <: _) Nil
and thus that the equation is not needed.
Fixes #26395
- - - - -
2c378ad2 by Cheng Shao at 2025-09-19T05:17:33-04:00
rel-eng: update fedora image to 42
This patch is a part of #25876 and updates fedora image to 42.
- - - - -
0a9d9ffc by Sylvain Henry at 2025-09-19T13:12:14-04:00
Fix output of T14999 (#23685)
Fix output of T14999 to:
- take into account the +1 offset to DW_AT_low_pc (see Note [Info Offset])
- always use Intel's syntax to force consistency: it was reported that
sometimes GDB prints `jmpq` instead of `jmp` with the AT&T syntax
- - - - -
1480872a by Vladislav Zavialov at 2025-09-19T13:12:54-04:00
Fix PREP_MAYBE_LIBRARY in prep_target_file.m4
This change fixes a configure error introduced in:
commit 8235dd8c4945db9cb03e3be3c388d729d576ed1e
ghc-toolchain: Move UseLibdw to per-Target file
Now the build no longer fails with:
acghc-toolchain: Failed to read a valid Target value from hadrian/cfg/default.target
- - - - -
d1d9e39e by Ben Gamari at 2025-09-19T18:24:52-04:00
StgToByteCode: Don't assume that data con workers are nullary
Previously StgToByteCode assumed that all data-con workers were of a
nullary representation. This is not a valid assumption, as seen
in #23210, where an unsaturated application of a unary data
constructor's worker resulted in invalid bytecode. Sadly, I have not yet
been able to reduce a minimal testcase for this.
Fixes #23210.
- - - - -
3eeecd50 by Ben Gamari at 2025-09-19T18:24:53-04:00
testsuite: Mark T23146* as unbroken
- - - - -
2e73f342 by sheaf at 2025-09-19T18:24:53-04:00
Add test for #26216
- - - - -
c2efb912 by Sven Tennie at 2025-09-19T18:25:36-04:00
Generate correct test header
This increases convenience when copying & pasting...
- - - - -
d2fb811e by Sven Tennie at 2025-09-19T18:25:36-04:00
foundation test: Fix shift amount (#26248)
Shift primops' results are only defined for shift amounts of 0 to word
size - 1. The approach is similar to testing div-like operations (which
have a constraint regarding zero operands.)
This was partly vibe coded (https://github.com/supersven/ghc/pull/1) but
then heavily refactored.
- - - - -
a62ce115 by Andreas Klebinger at 2025-09-19T18:26:18-04:00
Tweak jspace test
I've given it a longer timeout, and tweaked the test file generation
to speed it up a bit. Hopefully that is enough to make it constentily pass.
Last but not least it now also always uses three threads.
- - - - -
0f034942 by Cheng Shao at 2025-09-19T18:26:59-04:00
rts: remove obsolete CC_SUPPORTS_TLS logic
This patch removes obsolete CC_SUPPORTS_TLS logic throughout the rts,
given __thread is now uniformly supported by C toolchains of all
platforms we currently support.
- - - - -
ef705655 by Cheng Shao at 2025-09-19T18:27:41-04:00
rts: remove obsolete HAS_VISIBILITY_HIDDEN logic
This patch removes obsolete HAS_VISIBILITY_HIDDEN logic throughout the
rts, given __attribute__((visibility("hidden"))) is uniformly
supported by C toolchains of all platforms we currently support.
- - - - -
9fdc1f7d by Cheng Shao at 2025-09-19T18:28:21-04:00
rts: remove -O3 pragma hack in Hash.c
This patch removes an obsolete gcc pragma to specify -O3 in Hash.c.
Hadrian already passes the right flag.
- - - - -
b8cfa8f7 by Cheng Shao at 2025-09-19T18:29:01-04:00
rts: remove obsolete COMPILING_WINDOWS_DLL logic
This patch removes obsolete COMPILING_WINDOWS_DLL logic throughout the
rts. They were once used for compiling to win32 DLLs, but we haven't
been able to compile Haskell units to win32 DLLs for many years now,
due to PE format's restriction of no more than 65536 exported symbols
in a single DLL.
- - - - -
bb760611 by Cheng Shao at 2025-09-19T18:29:42-04:00
wasm: bump browser_wasi_shim to 0.4.2
This patch bumps the browser_wasi_shim dependency of wasm dyld script
to 0.4.2.
- - - - -
8b0940db by Cheng Shao at 2025-09-20T06:48:05-04:00
compiler: move Binary instance of Map to GHC.Utils.Binary
This patch moves `Binary` instance of `Map` from `haddock-api` to
`GHC.Utils.Binary`. This also allows us to remove a redundant instance
defined for `NameEntityInfo`, which is a type synonym for `Map`.
- - - - -
4a8fed75 by Vladislav Zavialov at 2025-09-20T06:48:47-04:00
Fix keyword in ExplicitNamespaces error message (#26418)
Consider this module header and the resulting error:
{-# LANGUAGE NoExplicitNamespaces #-}
module T26418 (data HeadC) where
-- error: [GHC-47007]
-- Illegal keyword 'type'
Previously, the error message would mention 'type' (as shown above),
even though the user wrote 'data'. This has now been fixed.
The error location has also been corrected: it is now reported at the
keyword position rather than at the position of the associated
import/export item.
- - - - -
867c2675 by Cheng Shao at 2025-09-20T06:49:28-04:00
wasm: fix dyld handling for forward declared GOT.func items
This patch fixes wasm shared linker's handling of forward declared
GOT.func items, see linked issue for details. Also adds T26430 test to
witness the fix. Fixes #26430.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
e7df6cc0 by Simon Peyton Jones at 2025-09-23T14:34:39-04:00
Improve pretty printer for HsExpr
Given a very deeply-nested application, it just kept printing
deeper and deeper. This small change makes it cut off.
Test is in #26330, but we also get a dramatic decrease in compile
time for perf/compiler/InstanceMatching:
InstanceMatching 4,086,884,584 1,181,767,232 -71.1% GOOD
Why? Because before we got a GIGANTIC error message that took
ages to pretty-print; now we get this much more civilised message
(I have removed some whitespace.)
Match.hs:1007:1: error:
• No instance for ‘Show (F001 a)’ arising from a use of ‘showsPrec’
• In the second argument of ‘showString’, namely
‘(showsPrec
11 b1
(GHC.Internal.Show.showSpace
(showsPrec
11 b2
(GHC.Internal.Show.showSpace
(showsPrec
11 b3
(GHC.Internal.Show.showSpace
(showsPrec
11 b4
(GHC.Internal.Show.showSpace
(showsPrec
11 b5
(GHC.Internal.Show.showSpace
(showsPrec
11 b6
(GHC.Internal.Show.showSpace (showsPrec ...)))))))))))))’
-----------------------
The main payload is
* At the start of `pprExpr`
* In the defn of `pprApp`
A little bit of refactoring:
* It turned out that we were setting the default cut-off depth to a
fixed value in two places, so changing one didn't change the other.
See defaultSDocDepth and defaultSDocCols
* I refactored `pprDeeperList` a bit so I could understand it better.
Because the depth calculation has changed, there are lots of small
error message wibbles.
Metric Decrease:
InstanceMatching
- - - - -
209f0158 by Simon Peyton Jones at 2025-09-23T14:34:39-04:00
Use Outputable.ellipsis rather than text "..."
- - - - -
64bb0e37 by Sylvain Henry at 2025-09-23T14:35:56-04:00
deriveConstants: automatically pass -fcommon CC flag (#26393)
By mistake we tried to use deriveConstants without passing
`--gcc-flag -fcommon` (which Hadrian does) and it failed.
This patch:
1. adds parsing support for constants stored in the .bss section (i.e.
when -fcommon isn't passed)
2. enables passing `-fcommon` automatically to the C compiler because
Windows requires this for subtle reasons
3. Documents the subtle reasons
(1) isn't strictly necessary because we always do (2) but it does no
harm and it is still useful if the CC flags ever contain -fno-common
- - - - -
afcdf92f by Oleg Grenrus at 2025-09-23T14:36:41-04:00
Don't wrap spaces in <span>s
Doing similar comparison as in 63189b2ceca07edf4e179f4180ca60d470c62cb3
With this change the gzipped documentation is now 2% smaller (previously 1%)
12_694_206 Agda-2.9.0-docs-orig.tar.gz
12_436_829 Agda-2.9.0-docs.tar.gz
Unzipped docs are 5% smaller (previously 3%)
178M Agda-2.9.0-docs-orig
169M Agda-2.9.0-docs
Individual hyperlinked sources are around 7-10% smaller (previously 5%)
(`Parser` module is generated by happy and has relatively little whitespace)
14_230_117 Agda.Syntax.Parser.Parser.html
13_220_758 Agda.Syntax.Parser.Parser.html
Agda's hyperlinked sources are 9% smaller now:
121M Agda-2.9.0-docs-orig/src
110M Agda-2.9.0-docs/src
- - - - -
67de53a6 by Cheng Shao at 2025-09-23T14:37:31-04:00
rts: remove obsolete __GNUC__ related logic
This patch removes obsolete `__GNUC__` related logic, given on any
currently supported platform and toolchain, `__GNUC__ >= 4` is
universally true. Also pulls some other weeds and most notably, use
`__builtin___clear_cache` for clang as well, since clang has supported
this gcc intrinsic since 2014, see
https://github.com/llvm/llvm-project/commit/c491a8d4577052bc6b3b4c72a7db6a7….
- - - - -
c4d32493 by Sven Tennie at 2025-09-23T20:40:57-04:00
RV64: Fix: Add missing truncation to MO_S_Shr (#26248)
Sub-double word (<W64) registers need to be truncated after the
operation.
- - - - -
41dce477 by Sven Tennie at 2025-09-23T20:40:57-04:00
RV64: Cleanup shift emitting cases/code
Remove overlapping cases to make the shift logic easier to understand.
- - - - -
0a601c30 by Alex Washburn at 2025-09-23T20:41:41-04:00
Correcting LLVM linking of Intel BMI intrinsics pdep{8,16} and pext{8,16}.
This patch fixes #26065.
The LLVM interface does not expose bindings to:
- llvm.x86.bmi.pdep.8
- llvm.x86.bmi.pdep.16
- llvm.x86.bmi.pext.8
- llvm.x86.bmi.pext.16
So calls are instead made to llvm.x86.bmi.{pdep,pext}.32 in these cases,
with pre/post-operation truncation to constrain the logical value range.
- - - - -
89e8ff3d by Peng Fan at 2025-09-23T20:42:37-04:00
NCG/LA64: Implement MO_BSwap and MO_BRev with bit-manipulation Instructions
- - - - -
50f6be09 by Sylvain Henry at 2025-09-23T20:43:29-04:00
Allow Core plugins to access unoptimized Core (#23337)
Make the first simple optimization pass after desugaring a real CoreToDo
pass. This allows CorePlugins to decide whether they want to be executed
before or after this pass.
- - - - -
30ef0aac by Simon Hengel at 2025-09-23T20:44:12-04:00
docs: Fix typo in scoped_type_variables.rst
- - - - -
f8919262 by Cheng Shao at 2025-09-23T20:44:54-04:00
ghci: fix bootstrapping with 9.12.3-rc1 and above
This patch fixes bootstrapping GHC with 9.12.3-rc1 and above. ghci
defines `Binary` instance for `HalfWord` in `ghc-heap`, which is a
proper `newtype` in 9.14 and starting from 9.12.3. Given we don't
build `ghc-heap` in stage0, we need to fix this predicate so that it
corresponds to the boot ghc versions that contain the right version of
`ghc-heap`.
- - - - -
a7f15858 by sheaf at 2025-09-24T09:49:53-04:00
User's guide: clarify optimisation of INLINABLE unfoldings
This updates the user's guide section on INLINABLE pragmas to explain how
the unfoldings of inlineable functions are optimised. The user's guide incorrectly
stated that the RHS was not optimised at all, but this is not true. Instead, GHC
is careful about phase control to optmise the RHS while retaining the guarantee
that GHC behaves as if the original RHS had been written.
- - - - -
495886d9 by Rodrigo Mesquita at 2025-09-24T09:50:35-04:00
cleanup: Delete historical artifact of COMPILING_WINDOWS_DLL
Namely, drop the obsolete
- DLL_IMPORT_RTS
- DLL_IMPORT_DATA_VAR
- DLL_IMPORT_DATA_VARNAME
- DLL_IMPORT_DATA_REF
These macros were not doing anything and placed inconsistently
Looking at the git logs reveal these macros were used to support
dynamic libraries on Win32, a feature that was dropped
in b8cfa8f741729ef123569fb321c4b2ab4a1a941c
This allows us to get rid of the rts/DLL.h file too.
- - - - -
c6c29361 by Richard Eisenberg at 2025-09-24T18:08:53+01:00
Move some fundep solving to new spot
Work in progress...[skip ci]
This completes moving dict fundeps to the main loop
We need wanted/wanted fundeps too
...and some other refactors
Wibbles
Make FunDeps into a new module
Solve new_eqs rather than adding them to WantedConstraints
Wibble
Import wibbles
Comments only [skip ci]
WIP on FunDeps [skip ci]
Work in progress [skip ci]
More WIP
Wibbles to fundeps [skip ci]
Kill off kickOutAfterUnification
More wibbles
Need to remove the unification-count stuff entirely
and do more tidying up -- this commit is mainly for CI
Wibbles solver
Iterate the simples more often than plugins
Start to extend to equalities
Whitespace only
Small improvements
Wibbles
- - - - -
59ab6a43 by Simon Peyton Jones at 2025-09-24T18:09:54+01:00
Improved error messages from fundep changes
- - - - -
cbdfa6a0 by Simon Peyton Jones at 2025-09-24T18:09:57+01:00
Wibbles
- - - - -
b7e357c9 by Simon Peyton Jones at 2025-09-24T18:09:57+01:00
Fix typo
- - - - -
196fdf50 by Simon Peyton Jones at 2025-09-24T18:10:18+01:00
Wibbles
- - - - -
5f39e077 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Nuke FunDepOrigin1 and 2
- - - - -
e8f50546 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Wibble
- - - - -
119b483a by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
More refactoring
- - - - -
5b5d48a4 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
More tidying up
- - - - -
18f61f7c by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Yet more
- - - - -
101960c2 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Wibbles
- - - - -
15f52839 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Wibbles [skip ci]
- - - - -
8e2972c0 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Naming and comments only [skip ci]
- - - - -
01a4c8d4 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Progress [skip ci]x
- - - - -
8b719207 by Simon Peyton Jones at 2025-09-24T18:10:21+01:00
Make it compile
.. with now story on WhatUnifications
- - - - -
288 changed files:
- .gitlab-ci.yml
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/LA64/Instr.hs
- compiler/GHC/CmmToAsm/LA64/Ppr.hs
- compiler/GHC/CmmToAsm/RV64/CodeGen.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Pipeline/Types.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Errors/Ppr.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Ppr.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Llvm/Ppr.hs
- compiler/GHC/Llvm/Types.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/Types.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/Layout.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- + compiler/GHC/Tc/Solver/FunDeps.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Unique.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Ppr.hs
- compiler/ghc.cabal.in
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/9.16.1-notes.rst
- docs/users_guide/exts/pragmas.rst
- docs/users_guide/exts/scoped_type_variables.rst
- docs/users_guide/ghci.rst
- ghc/GHCi/UI.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- libraries/base/tests/unicode002.stdout
- libraries/base/tests/unicode003.stdout
- libraries/ghc-heap/GHC/Exts/Heap.hs
- libraries/ghc-internal/cbits/atomic.c
- libraries/ghc-internal/cbits/ctz.c
- libraries/ghc-internal/codepages/MakeTable.hs
- libraries/ghc-internal/codepages/Makefile
- libraries/ghc-internal/src/GHC/Internal/Unicode/Char/DerivedCoreProperties.hs
- libraries/ghc-internal/src/GHC/Internal/Unicode/Char/UnicodeData/GeneralCategory.hs
- libraries/ghc-internal/src/GHC/Internal/Unicode/Char/UnicodeData/SimpleLowerCaseMapping.hs
- libraries/ghc-internal/src/GHC/Internal/Unicode/Char/UnicodeData/SimpleTitleCaseMapping.hs
- libraries/ghc-internal/src/GHC/Internal/Unicode/Char/UnicodeData/SimpleUpperCaseMapping.hs
- libraries/ghc-internal/src/GHC/Internal/Unicode/Version.hs
- libraries/ghc-internal/tools/ucd2haskell/ucd.sh
- libraries/ghc-internal/tools/ucd2haskell/ucd2haskell.cabal
- libraries/ghc-internal/tools/ucd2haskell/unicode_version
- libraries/ghci/GHCi/Message.hs
- m4/find_python.m4
- − m4/fp_visibility_hidden.m4
- m4/prep_target_file.m4
- rts/BeginPrivate.h
- rts/CloneStack.h
- rts/EndPrivate.h
- rts/Hash.c
- rts/Interpreter.c
- rts/Prelude.h
- − rts/RtsDllMain.c
- − rts/RtsDllMain.h
- rts/RtsStartup.c
- rts/RtsSymbols.c
- rts/StgMiscClosures.cmm
- rts/Task.c
- rts/Task.h
- rts/configure.ac
- rts/include/Rts.h
- rts/include/RtsAPI.h
- rts/include/Stg.h
- rts/include/rts/Flags.h
- rts/include/rts/NonMoving.h
- rts/include/rts/OSThreads.h
- rts/include/rts/StableName.h
- rts/include/rts/StablePtr.h
- rts/include/rts/Types.h
- − rts/include/stg/DLL.h
- rts/include/stg/MiscClosures.h
- rts/posix/OSThreads.c
- rts/rts.cabal
- rts/sm/BlockAlloc.c
- rts/sm/Evac.c
- rts/sm/Evac.h
- rts/sm/GCTDecl.h
- rts/sm/GCThread.h
- rts/sm/Storage.c
- rts/win32/OSThreads.c
- testsuite/tests/arrows/gadt/T17423.stderr
- + testsuite/tests/bytecode/T26216.hs
- + testsuite/tests/bytecode/T26216.script
- + testsuite/tests/bytecode/T26216.stdout
- + testsuite/tests/bytecode/T26216_aux.hs
- testsuite/tests/bytecode/all.T
- testsuite/tests/codeGen/should_compile/Makefile
- testsuite/tests/codeGen/should_compile/T14999.stdout
- testsuite/tests/codeGen/should_run/T13825-unit.hs
- testsuite/tests/codeGen/should_run/T23146/all.T
- testsuite/tests/dependent/should_fail/T13135_simple.stderr
- testsuite/tests/deriving/should_fail/T3621.stderr
- testsuite/tests/driver/j-space/Makefile
- testsuite/tests/driver/j-space/all.T
- testsuite/tests/driver/j-space/genJspace
- testsuite/tests/driver/multipleHomeUnits/all.T
- + testsuite/tests/ghci-wasm/Makefile
- + testsuite/tests/ghci-wasm/T26430.hs
- + testsuite/tests/ghci-wasm/T26430A.c
- + testsuite/tests/ghci-wasm/T26430B.c
- + testsuite/tests/ghci-wasm/all.T
- testsuite/tests/ghci.debugger/scripts/break022/all.T
- testsuite/tests/ghci.debugger/scripts/break022/break022.script
- testsuite/tests/ghci.debugger/scripts/break023/all.T
- testsuite/tests/ghci.debugger/scripts/break023/break023.script
- testsuite/tests/ghci/prog001/prog001.T
- testsuite/tests/ghci/prog001/prog001.script
- testsuite/tests/ghci/prog002/prog002.T
- testsuite/tests/ghci/prog002/prog002.script
- testsuite/tests/ghci/prog003/prog003.T
- testsuite/tests/ghci/prog003/prog003.script
- testsuite/tests/ghci/prog005/prog005.T
- testsuite/tests/ghci/prog005/prog005.script
- testsuite/tests/ghci/prog010/all.T
- testsuite/tests/ghci/prog010/ghci.prog010.script
- testsuite/tests/ghci/prog012/all.T
- testsuite/tests/ghci/prog012/prog012.script
- testsuite/tests/ghci/recompTHghci/all.T
- testsuite/tests/ghci/recompTHghci/recompTHghci.script
- testsuite/tests/ghci/scripts/T18330.script
- testsuite/tests/ghci/scripts/T18330.stdout
- testsuite/tests/ghci/scripts/T1914.script
- testsuite/tests/ghci/scripts/T20587.script
- testsuite/tests/ghci/scripts/T6106.script
- testsuite/tests/ghci/scripts/T8353.script
- testsuite/tests/ghci/scripts/all.T
- testsuite/tests/ghci/scripts/ghci038.script
- testsuite/tests/ghci/scripts/ghci058.script
- testsuite/tests/ghci/scripts/ghci063.script
- − testsuite/tests/ghci/shell.hs
- testsuite/tests/indexed-types/should_compile/PushedInAsGivens.stderr
- testsuite/tests/indexed-types/should_fail/T14369.stderr
- testsuite/tests/indexed-types/should_fail/T26176.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T4093b.stderr
- testsuite/tests/indexed-types/should_fail/T8518.stderr
- testsuite/tests/indexed-types/should_fail/T9662.stderr
- testsuite/tests/linear/should_fail/Linear17.stderr
- testsuite/tests/linear/should_fail/LinearLet7.stderr
- + testsuite/tests/llvm/should_run/T26065.hs
- + testsuite/tests/llvm/should_run/T26065.stdout
- testsuite/tests/llvm/should_run/all.T
- testsuite/tests/numeric/should_run/foundation.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26391.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26391.stderr
- testsuite/tests/overloadedrecflds/should_fail/all.T
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- testsuite/tests/parser/should_fail/T16270h.stderr
- testsuite/tests/parser/should_fail/T20654a.stderr
- + testsuite/tests/parser/should_fail/T26418.hs
- + testsuite/tests/parser/should_fail/T26418.stderr
- testsuite/tests/parser/should_fail/all.T
- testsuite/tests/partial-sigs/should_compile/T21719.stderr
- testsuite/tests/partial-sigs/should_fail/T14040a.stderr
- testsuite/tests/perf/compiler/MultiLayerModulesDefsGhci.script
- testsuite/tests/perf/compiler/all.T
- testsuite/tests/plugins/annotation-plugin/SayAnnNames.hs
- testsuite/tests/plugins/late-plugin/LatePlugin.hs
- testsuite/tests/plugins/simple-plugin/Simple/ReplacePlugin.hs
- testsuite/tests/polykinds/T13393.stderr
- testsuite/tests/polykinds/T6068.stdout
- testsuite/tests/rep-poly/T12709.stderr
- testsuite/tests/simplCore/should_compile/simpl017.stderr
- + testsuite/tests/tcplugins/T26395.hs
- + testsuite/tests/tcplugins/T26395.stderr
- + testsuite/tests/tcplugins/T26395_Plugin.hs
- testsuite/tests/tcplugins/all.T
- testsuite/tests/th/T10945.stderr
- testsuite/tests/th/TH_StaticPointers02.stderr
- testsuite/tests/typecheck/no_skolem_info/T14040.stderr
- testsuite/tests/typecheck/should_compile/T11339.stderr
- testsuite/tests/typecheck/should_compile/T13651.hs
- + testsuite/tests/typecheck/should_compile/T14745.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/tc126.hs
- testsuite/tests/typecheck/should_fail/AmbigFDs.hs
- − testsuite/tests/typecheck/should_fail/AmbigFDs.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion3.stderr
- testsuite/tests/typecheck/should_fail/FD3.stderr
- testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr
- testsuite/tests/typecheck/should_fail/T12177.stderr
- testsuite/tests/typecheck/should_fail/T13506.stderr
- testsuite/tests/typecheck/should_fail/T16512a.stderr
- testsuite/tests/typecheck/should_fail/T18851b.hs
- − testsuite/tests/typecheck/should_fail/T18851b.stderr
- testsuite/tests/typecheck/should_fail/T18851c.hs
- − testsuite/tests/typecheck/should_fail/T18851c.stderr
- testsuite/tests/typecheck/should_fail/T19415.stderr
- testsuite/tests/typecheck/should_fail/T19415b.stderr
- testsuite/tests/typecheck/should_fail/T22707.stderr
- testsuite/tests/typecheck/should_fail/T24064.stderr
- testsuite/tests/typecheck/should_fail/T25325.stderr
- + testsuite/tests/typecheck/should_fail/T26330.hs
- + testsuite/tests/typecheck/should_fail/T26330.stderr
- testsuite/tests/typecheck/should_fail/T5246.stderr
- testsuite/tests/typecheck/should_fail/T5978.stderr
- testsuite/tests/typecheck/should_fail/T8142.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/all.T
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail143.stderr
- testsuite/tests/typecheck/should_fail/tcfail153.stderr
- testsuite/tests/typecheck/should_fail/tcfail168.stderr
- testsuite/tests/typecheck/should_fail/tcfail177.stderr
- testsuite/tests/typecheck/should_fail/tcfail185.stderr
- testsuite/tests/typecheck/should_run/Typeable1.stderr
- testsuite/tests/unboxedsums/UbxSumUnpackedSize.stdout
- testsuite/tests/unboxedsums/UbxSumUnpackedSize.stdout-ws-32
- utils/deriveConstants/Main.hs
- utils/genprimopcode/Main.hs
- utils/genprimopcode/Syntax.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
- utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
- utils/haddock/hypsrc-test/Main.hs
- utils/haddock/hypsrc-test/ref/src/Bug1091.html
- utils/haddock/hypsrc-test/ref/src/CPP.html
- utils/haddock/hypsrc-test/ref/src/Classes.html
- utils/haddock/hypsrc-test/ref/src/Constructors.html
- utils/haddock/hypsrc-test/ref/src/Identifiers.html
- utils/haddock/hypsrc-test/ref/src/LinkingIdentifiers.html
- utils/haddock/hypsrc-test/ref/src/Literals.html
- utils/haddock/hypsrc-test/ref/src/Operators.html
- utils/haddock/hypsrc-test/ref/src/Polymorphism.html
- utils/haddock/hypsrc-test/ref/src/PositionPragmas.html
- utils/haddock/hypsrc-test/ref/src/Quasiquoter.html
- utils/haddock/hypsrc-test/ref/src/Records.html
- utils/haddock/hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html
- utils/haddock/hypsrc-test/ref/src/TemplateHaskellSplices.html
- utils/haddock/hypsrc-test/ref/src/Types.html
- utils/haddock/hypsrc-test/ref/src/UsingQuasiquotes.html
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7121fd7575551a1cc0e5157bd91fda…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7121fd7575551a1cc0e5157bd91fda…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] Don't use build CFLAGS and friends as target settings
by Marge Bot (@marge-bot) 24 Sep '25
by Marge Bot (@marge-bot) 24 Sep '25
24 Sep '25
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
135242ca by Rodrigo Mesquita at 2025-09-24T17:07:44-04:00
Don't use build CFLAGS and friends as target settings
In the GHC in tree configure, `CFLAGS`, `CXXFLAGS`, and similar tool
configuration flags apply to the BUILD phase of the compiler, i.e. to
the tools run to compile GHC itself.
Notably, they should /not/ be carried over to the Target settings, i.e.
these flags should /not/ apply to the tool which GHC invokes at runtime.
Fixes #25637
- - - - -
3 changed files:
- configure.ac
- m4/fp_setup_windows_toolchain.m4
- m4/ghc_toolchain.m4
Changes:
=====================================
configure.ac
=====================================
@@ -43,12 +43,6 @@ dnl interprets build/host/target and how this interacts with $CC tests
test -n "$target_alias" && ac_tool_prefix=$target_alias-
dnl ----------------------------------------------------------
-dnl ** Store USER specified environment variables to pass them on to
-dnl ** ghc-toolchain (in m4/ghc-toolchain.m4)
-USER_CFLAGS="$CFLAGS"
-USER_LDFLAGS="$LDFLAGS"
-USER_LIBS="$LIBS"
-USER_CXXFLAGS="$CXXFLAGS"
dnl The lower-level/not user-facing environment variables that may still be set
dnl by developers such as in ghc-wasm-meta
USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
=====================================
m4/fp_setup_windows_toolchain.m4
=====================================
@@ -146,11 +146,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
dnl We override the USER_* flags here since the user delegated
dnl configuration to the bundled windows toolchain, and these are the
dnl options required by the bundled windows toolchain.
- USER_CFLAGS="$CFLAGS"
USER_CPP_ARGS="$CONF_CPP_OPTS_STAGE2"
- USER_CXXFLAGS="$CXXFLAGS"
USER_HS_CPP_ARGS="$HaskellCPPArgs"
- USER_LDFLAGS="$CONF_GCC_LINKER_OPTS_STAGE2"
+ USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
+ USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2"
+ USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2"
USER_JS_CPP_ARGS="$JavaScriptCPPArgs"
USER_CMM_CPP_ARGS="$CmmCPPArgs"
])
=====================================
m4/ghc_toolchain.m4
=====================================
@@ -8,18 +8,6 @@ AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG],
done
])
-dnl $1 argument name
-dnl $2 first variable to try
-dnl $3 variable to add if the first variable is empty
-AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG_CHOOSE],
-[
- if test -z "$2"; then
- ADD_GHC_TOOLCHAIN_ARG([$1],[$3])
- else
- ADD_GHC_TOOLCHAIN_ARG([$1],[$2])
- fi
-])
-
AC_DEFUN([ENABLE_GHC_TOOLCHAIN_ARG],
[
if test "$2" = "YES"; then
@@ -123,10 +111,9 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
ENABLE_GHC_TOOLCHAIN_ARG([dwarf-unwind], [$enable_dwarf_unwind])
dnl We store USER_* variants of all user-specified flags to pass them over to ghc-toolchain.
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-opt], [$USER_CONF_CC_OPTS_STAGE2], [$USER_CFLAGS])
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2], [$USER_LDFLAGS])
- ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_LIBS])
- ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2], [$USER_CXXFLAGS])
+ ADD_GHC_TOOLCHAIN_ARG([cc-opt], [$USER_CONF_CC_OPTS_STAGE2])
+ ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2])
+ ADD_GHC_TOOLCHAIN_ARG([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2])
ADD_GHC_TOOLCHAIN_ARG([cpp-opt], [$USER_CPP_ARGS])
ADD_GHC_TOOLCHAIN_ARG([hs-cpp-opt], [$USER_HS_CPP_ARGS])
ADD_GHC_TOOLCHAIN_ARG([js-cpp-opt], [$USER_JS_CPP_ARGS])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/135242ca53b0404db6fa44f068c113b…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/135242ca53b0404db6fa44f068c113b…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
24 Sep '25
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
5ae89054 by Sylvain Henry at 2025-09-24T17:07:00-04:00
Allow disabling builtin rules (#20298)
Add a way to disable built-in rules programmatically and with a debug flag.
I also took the opportunity to add a debug flag to disable bignum rules,
which was only possible programmatically (e.g. in a plugin).
- - - - -
14 changed files:
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Rules/Config.hs
- compiler/GHC/Driver/Config/Core/Rules.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- docs/users_guide/debugging.rst
- + testsuite/tests/codeGen/should_compile/T20298a.hs
- + testsuite/tests/codeGen/should_compile/T20298a.stderr
- + testsuite/tests/codeGen/should_compile/T20298b.hs
- + testsuite/tests/codeGen/should_compile/T20298b.stderr
- + testsuite/tests/codeGen/should_compile/T20298c.hs
- + testsuite/tests/codeGen/should_compile/T20298c.stderr
- testsuite/tests/codeGen/should_compile/all.T
Changes:
=====================================
compiler/GHC/Core/Opt/ConstantFold.hs
=====================================
@@ -2173,6 +2173,43 @@ builtinRules
-- there is no benefit to inlining these yet, despite this, GHC produces
-- unfoldings for this regardless since the floated list entries look small.
+
+
+{- Note [Built-in bignum rules]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+We have some built-in rules for operations on bignum types (Integer, Natural,
+BigNat). These rules implement the same kind of constant folding as we have for
+Int#/Word#/etc. primops. See builtinBignumRules.
+
+These rules are built-in because they can't be expressed as regular rules for
+now. The reason is that due to the let-can-float invariant (see Note [Core
+let-can-float invariant] in GHC.Core), GHC is too conservative with some bignum
+operations and they don't match rules. For example:
+
+ case integerAdd 1 x of r { _ -> integerAdd 1 r }
+
+doesn't constant-fold into `integerAdd 2 x` with a regular rule. That's because
+GHC never floats in `integerAdd 1 x` to form `integerAdd 1 (integerAdd 1 x)`
+because of the let-can-float invariant (it doesn't know if `integerAdd`
+terminates).
+
+In the built-in rule for `integerAdd` we can access the unfolding of `r` and we
+can perform the appropriate substitution.
+
+To support constant-folding, Bignum operations are not allowed to inline. As a
+consequence, some codes that would benefit from inlining of bignum operations
+don't. An idea to fix this was to only have built-in rules for BigNat#
+operations and to allow Integer and Natural operations to inline. However these
+operations are often too big to inline and we end up with broken
+constant-folding and still no inlining. This issue is tracked in #20361
+
+Bignum built-in rules can be disabled independently of other built-in rules by
+passing the -dno-bignum-rules flag or programmatically with the `roBignumRules` field of
+RuleOpts.
+
+-}
+
+-- | Built-in bignum rules (see Note [Built-in bignum rules])
builtinBignumRules :: [CoreRule]
builtinBignumRules =
[ -- conversions
=====================================
compiler/GHC/Core/Rules.hs
=====================================
@@ -65,6 +65,7 @@ import GHC.Core.Map.Expr ( eqCoreExpr )
import GHC.Core.Opt.Arity( etaExpandToJoinPointRule )
import GHC.Core.Make ( mkCoreLams )
import GHC.Core.Opt.OccurAnal( occurAnalyseExpr )
+import GHC.Core.Rules.Config (roBuiltinRules)
import GHC.Tc.Utils.TcType ( tcSplitTyConApp_maybe )
import GHC.Builtin.Types ( anyTypeOfKind )
@@ -708,10 +709,8 @@ matchRule :: HasDebugCallStack
matchRule opts rule_env _is_active fn args _rough_args
(BuiltinRule { ru_try = match_fn })
--- Built-in rules can't be switched off, it seems
- = case match_fn opts rule_env fn args of
- Nothing -> Nothing
- Just expr -> Just expr
+ | not (roBuiltinRules opts) = Nothing
+ | otherwise = match_fn opts rule_env fn args
matchRule _ rule_env is_active _ args rough_args
(Rule { ru_name = rule_name, ru_act = act, ru_rough = tpl_tops
=====================================
compiler/GHC/Core/Rules/Config.hs
=====================================
@@ -14,6 +14,10 @@ data RuleOpts = RuleOpts
, roExcessRationalPrecision :: !Bool
-- ^ Cut down precision of Rational values to that of Float/Double if disabled
, roBignumRules :: !Bool
- -- ^ Enable rules for bignums
+ -- ^ Enable built-in bignum rules (requires roBuiltinRules to be True too)
+ --
+ -- See Note [Built-in bignum rules] in GHC.Core.Opt.ConstantFold
+ , roBuiltinRules :: !Bool
+ -- ^ Enable or disable all builtin rules (including bignum rules)
}
=====================================
compiler/GHC/Driver/Config/Core/Rules.hs
=====================================
@@ -15,5 +15,6 @@ initRuleOpts dflags = RuleOpts
{ roPlatform = targetPlatform dflags
, roNumConstantFolding = gopt Opt_NumConstantFolding dflags
, roExcessRationalPrecision = gopt Opt_ExcessPrecision dflags
- , roBignumRules = True
+ , roBignumRules = not (gopt Opt_NoBignumRules dflags)
+ , roBuiltinRules = not (gopt Opt_NoBuiltinRules dflags)
}
=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -592,6 +592,8 @@ data GeneralFlag
| Opt_NoLlvmMangler -- hidden flag
| Opt_FastLlvm -- hidden flag
| Opt_NoTypeableBinds
+ | Opt_NoBuiltinRules
+ | Opt_NoBignumRules
| Opt_DistinctConstructorTables
| Opt_InfoTableMap
@@ -973,6 +975,8 @@ codeGenFlags = EnumSet.fromList
, Opt_ExposeAllUnfoldings
, Opt_ExposeOverloadedUnfoldings
, Opt_NoTypeableBinds
+ , Opt_NoBuiltinRules
+ , Opt_NoBignumRules
, Opt_ObjectDeterminism
, Opt_Haddock
=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -1660,6 +1660,10 @@ dynamic_flags_deps = [
(NoArg (setGeneralFlag Opt_NoLlvmMangler)) -- hidden flag
, make_ord_flag defGhcFlag "dno-typeable-binds"
(NoArg (setGeneralFlag Opt_NoTypeableBinds))
+ , make_ord_flag defGhcFlag "dno-builtin-rules"
+ (NoArg (setGeneralFlag Opt_NoBuiltinRules))
+ , make_ord_flag defGhcFlag "dno-bignum-rules"
+ (NoArg (setGeneralFlag Opt_NoBignumRules))
, make_ord_flag defGhcFlag "ddump-debug"
(setDumpFlag Opt_D_dump_debug)
, make_dep_flag defGhcFlag "ddump-json"
=====================================
docs/users_guide/debugging.rst
=====================================
@@ -1225,6 +1225,18 @@ Other
compiler will panic if you try to use Typeable instances of things that you
built with this flag.
+.. ghc-flag:: -dno-builtin-rules
+ :shortdesc: Disable all built-in rewrite rules
+ :type: dynamic
+
+ This disables all the built-in rewrite rules. Mostly useful for debugging.
+
+.. ghc-flag:: -dno-bignum-rules
+ :shortdesc: Disable bignum built-in rewrite rules
+ :type: dynamic
+
+ This disables bignum built-in rewrite rules. Mostly useful for debugging.
+
.. ghc-flag:: -dtag-inference-checks
:shortdesc: Affirm tag inference results are correct at runtime.
:type: dynamic
=====================================
testsuite/tests/codeGen/should_compile/T20298a.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298a where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298a.stderr
=====================================
@@ -0,0 +1,9 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 3, types: 1, coercions: 0, joins: 0/0}
+
+foo = IS 30#
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/T20298b.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298b where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298b.stderr
=====================================
@@ -0,0 +1,13 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 10, types: 3, coercions: 0, joins: 0/0}
+
+foo2 = IS 10#
+
+foo1 = IS 20#
+
+foo = integerAdd foo2 foo1
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/T20298c.hs
=====================================
@@ -0,0 +1,4 @@
+module T20298c where
+
+foo :: Integer
+foo = 10 + 20
=====================================
testsuite/tests/codeGen/should_compile/T20298c.stderr
=====================================
@@ -0,0 +1,13 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 11, types: 4, coercions: 0, joins: 0/0}
+
+foo2 = IS 10#
+
+foo1 = IS 20#
+
+foo = + $fNumInteger foo2 foo1
+
+
+
=====================================
testsuite/tests/codeGen/should_compile/all.T
=====================================
@@ -145,3 +145,7 @@ test('T25166', [req_cmm], makefile_test, [])
test('T25177', normal, compile, ['-O2 -dno-typeable-binds -ddump-simpl -dsuppress-all -dsuppress-uniques -v0'])
test('T16351', normal, compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+
+test('T20298a', normal, compile, ['-O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+test('T20298b', normal, compile, ['-O2 -dno-bignum-rules -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
+test('T20298c', normal, compile, ['-O2 -dno-builtin-rules -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ae89054d14c5dfd42ab5bc4fff8e50…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ae89054d14c5dfd42ab5bc4fff8e50…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc] Pushed new branch wip/wasm-restore-fast-api-calls
by Cheng Shao (@TerrorJack) 24 Sep '25
by Cheng Shao (@TerrorJack) 24 Sep '25
24 Sep '25
Cheng Shao pushed new branch wip/wasm-restore-fast-api-calls at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/wasm-restore-fast-api-calls
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Andreas Klebinger pushed to branch wip/andreask/bomb_out at Glasgow Haskell Compiler / GHC
Commits:
b90a137c by Andreas Klebinger at 2025-09-24T20:02:56+02:00
blub
- - - - -
1 changed file:
- compiler/GHC/Core/Unfold.hs
Changes:
=====================================
compiler/GHC/Core/Unfold.hs
=====================================
@@ -573,6 +573,9 @@ sizeExpr opts !bOMB_OUT_SIZE top_args expr
= size_up sizeZero expr
where
size_up :: ExprSize -> CoreExpr -> ExprSize
+ size_up (TooBig) !_ = TooBig
+ size_up (SizeIs !s _ _) _
+ | s > bOMB_OUT_SIZE = TooBig
size_up s (Cast e _) = size_up s e
size_up s (Tick _ e) = size_up s e
size_up s (Type _) = s -- Types cost nothing
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b90a137c0b7b5db8baffcb5546d1354…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b90a137c0b7b5db8baffcb5546d1354…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/jeltsch/obtaining-os-handles] 3 commits: Move the new operations to a new module `System.IO.OS`
by Wolfgang Jeltsch (@jeltsch) 24 Sep '25
by Wolfgang Jeltsch (@jeltsch) 24 Sep '25
24 Sep '25
Wolfgang Jeltsch pushed to branch wip/jeltsch/obtaining-os-handles at Glasgow Haskell Compiler / GHC
Commits:
5dcfb400 by Wolfgang Jeltsch at 2025-09-24T20:58:18+03:00
Move the new operations to a new module `System.IO.OS`
- - - - -
40318687 by Wolfgang Jeltsch at 2025-09-24T21:00:40+03:00
Resolve some documentation issues
- - - - -
0a1ccf29 by Wolfgang Jeltsch at 2025-09-24T21:03:38+03:00
Make the documentation clearer
- - - - -
3 changed files:
- libraries/base/base.cabal.in
- libraries/base/src/GHC/IO/Handle.hs
- + libraries/base/src/System/IO/OS.hs
Changes:
=====================================
libraries/base/base.cabal.in
=====================================
@@ -258,6 +258,7 @@ Library
, System.Exit
, System.IO
, System.IO.Error
+ , System.IO.OS
, System.Mem
, System.Mem.StableName
, System.Posix.Internals
=====================================
libraries/base/src/GHC/IO/Handle.hs
=====================================
@@ -1,6 +1,4 @@
{-# LANGUAGE Safe #-}
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE RankNTypes #-}
-- |
--
@@ -16,8 +14,7 @@
--
module GHC.IO.Handle
- (-- * Portable operations
- Handle,
+ (Handle,
BufferMode(..),
mkFileHandle,
mkDuplexHandle,
@@ -73,337 +70,7 @@ module GHC.IO.Handle
hGetBuf,
hGetBufNonBlocking,
hPutBuf,
- hPutBufNonBlocking,
-
- -- * Obtaining file descriptors and Windows handles
- withFileDescriptorReadingBiased,
- withFileDescriptorWritingBiased,
- withWindowsHandleReadingBiased,
- withWindowsHandleWritingBiased,
- withFileDescriptorReadingBiasedRaw,
- withFileDescriptorWritingBiasedRaw,
- withWindowsHandleReadingBiasedRaw,
- withWindowsHandleWritingBiasedRaw
-
- -- ** Caveats
- -- $with-ref-caveats
-) where
+ hPutBufNonBlocking
+ ) where
import GHC.Internal.IO.Handle
-
-import GHC.Internal.Control.Monad (return)
-import GHC.Internal.Control.Concurrent.MVar (MVar)
-import GHC.Internal.Control.Exception (mask)
-import GHC.Internal.Data.Function (const, (.), ($))
-import GHC.Internal.Data.Functor (fmap)
-#if defined(mingw32_HOST_OS)
-import GHC.Internal.Data.Bool (otherwise)
-#endif
-import GHC.Internal.Data.Maybe (Maybe (Nothing), maybe)
-#if defined(mingw32_HOST_OS)
-import GHC.Internal.Data.Maybe (Maybe (Just))
-#endif
-import GHC.Internal.Data.List ((++))
-import GHC.Internal.Data.String (String)
-import GHC.Internal.Data.Typeable (Typeable, cast)
-import GHC.Internal.System.IO (IO)
-import GHC.Internal.IO.FD (fdFD)
-#if defined(mingw32_HOST_OS)
-import GHC.Internal.IO.Windows.Handle
- (
- NativeHandle,
- ConsoleHandle,
- IoHandle,
- toHANDLE
- )
-#endif
-import GHC.Internal.IO.Handle.Types
- (
- Handle (FileHandle, DuplexHandle),
- Handle__ (Handle__, haDevice)
- )
-import GHC.Internal.IO.Handle.Internals (withHandle_', flushBuffer)
-import GHC.Internal.IO.Exception
- (
- IOErrorType (InappropriateType),
- IOException (IOError),
- ioException
- )
-import GHC.Internal.Foreign.Ptr (Ptr)
-import GHC.Internal.Foreign.C.Types (CInt)
-
--- * Obtaining POSIX file descriptors and Windows handles
-
-{-|
- Obtains an operating-system handle that underlies a Haskell handle and
- executes a user-provided action on it. Before the user-provided action is
- run, user-defined perparation based on the handle state that contains the
- operating-system handle is performed. While the user-provided action is
- executed, further operations on the Haskell handle are blocked to a degree
- that interference with this action is prevented.
-
- See [below](#with-ref-caveats) for caveats regarding this operation.
--}
-withOSHandle :: String
- -- ^ The name of the overall operation
- -> (Handle -> MVar Handle__)
- {-^
- Obtaining of the handle state variable that holds the
- operating-system handle
- -}
- -> (forall d. Typeable d => d -> IO a)
- -- ^ Conversion of a device into an operating-system handle
- -> (Handle__ -> IO ())
- -- ^ The preparation
- -> Handle
- -- ^ The Haskell handle to use
- -> (a -> IO r)
- -- ^ The action to execute on the operating-system handle
- -> IO r
-withOSHandle opName handleStateVar getOSHandle prepare handle act
- = mask $ \ withOriginalMaskingState ->
- withHandleState $ \ handleState@Handle__ {haDevice = dev} -> do
- osHandle <- getOSHandle dev
- prepare handleState
- withOriginalMaskingState $ act osHandle
- where
-
- withHandleState = withHandle_' opName handle (handleStateVar handle)
-{-
- The 'withHandle_'' operation, which we use here, already performs masking.
- Still, we have to employ 'mask', in order do obtain the operation that
- restores the original masking state. The user-provided action should be
- executed with this original masking state, as there is no inherent reason to
- generally perform it with masking in place. The masking that 'withHandle_''
- performs is only for safely accessing handle state and thus constitutes an
- implementation detail; it has nothing to do with the user-provided action.
--}
-{-
- The order of actions in 'withOSHandle' is such that any exception from
- 'getOSHandle' is thrown before the flushing of the Haskell-managed buffers.
--}
-
-{-|
- Obtains the handle state variable that underlies a handle or specifically
- the handle state variable for reading if the handle uses different state
- variables for reading and writing.
--}
-handleStateVarReadingBiased :: Handle -> MVar Handle__
-handleStateVarReadingBiased (FileHandle _ var) = var
-handleStateVarReadingBiased (DuplexHandle _ readingVar _) = readingVar
-
-{-|
- Obtains the handle state variable that underlies a handle or specifically
- the handle state variable for writing if the handle uses different state
- variables for reading and writing.
--}
-handleStateVarWritingBiased :: Handle -> MVar Handle__
-handleStateVarWritingBiased (FileHandle _ var) = var
-handleStateVarWritingBiased (DuplexHandle _ _ writingVar) = writingVar
-
-{-|
- Yields the result of another operation if that operation succeeded, and
- otherwise throws an exception that signals that the other operation failed
- because some Haskell handle does not use an operating-system handle of a
- required type.
--}
-requiringOSHandleOfType :: String
- -- ^ The name of the operating-system handle type
- -> Maybe a
- {-^
- The result of the other operation if it succeeded
- -}
- -> IO a
-requiringOSHandleOfType osHandleTypeName
- = maybe (ioException osHandleOfTypeRequired) return
- where
-
- osHandleOfTypeRequired :: IOException
- osHandleOfTypeRequired
- = IOError Nothing
- InappropriateType
- ""
- ("handle does not use " ++ osHandleTypeName ++ "s")
- Nothing
- Nothing
-
-{-|
- Obtains the POSIX file descriptor of a device if the device contains one,
- and throws an exception otherwise.
--}
-getFileDescriptor :: Typeable d => d -> IO CInt
-getFileDescriptor = requiringOSHandleOfType "POSIX file descriptor" .
- fmap fdFD . cast
-
-{-|
- Obtains the Windows handle of a device if the device contains one, and
- throws an exception otherwise.
--}
-getWindowsHandle :: Typeable d => d -> IO (Ptr ())
-getWindowsHandle = requiringOSHandleOfType "Windows handle" .
- toMaybeWindowsHandle
- where
-
- toMaybeWindowsHandle :: Typeable d => d -> Maybe (Ptr ())
-#if defined(mingw32_HOST_OS)
- toMaybeWindowsHandle dev
- | Just nativeHandle <- cast dev :: Maybe (IoHandle NativeHandle)
- = Just (toHANDLE nativeHandle)
- | Just consoleHandle <- cast dev :: Maybe (IoHandle ConsoleHandle)
- = Just (toHANDLE consoleHandle)
- | otherwise
- = Nothing
- {-
- This is inspired by the implementation of
- 'System.Win32.Types.withHandleToHANDLENative'.
- -}
-#else
- toMaybeWindowsHandle _ = Nothing
-#endif
-
-{-|
- Obtains the POSIX file descriptor that underlies a handle or specifically
- the POSIX file descriptor for reading if the handle uses different file
- descriptors for reading and writing and executes a user-provided action on
- it. The Haskell-managed buffers related to the file descriptor are flushed
- before the user-provided action is run. While this action is executed,
- further operations on the handle are blocked to a degree that interference
- with this action is prevented.
-
- If the handle does not use POSIX file descriptors, an exception is thrown.
-
- See [below](#with-ref-caveats) for caveats regarding this operation.
--}
-withFileDescriptorReadingBiased :: Handle -> (CInt -> IO r) -> IO r
-withFileDescriptorReadingBiased = withOSHandle "withFileDescriptorReadingBiased"
- handleStateVarReadingBiased
- getFileDescriptor
- flushBuffer
-
-{-|
- Obtains the POSIX file descriptor that underlies a handle or specifically
- the POSIX file descriptor for writing if the handle uses different file
- descriptors for reading and writing and executes a user-provided action on
- it. The Haskell-managed buffers related to the file descriptor are flushed
- before the user-provided action is run. While this action is executed,
- further operations on the handle are blocked to a degree that interference
- with this action is prevented.
-
- If the handle does not use POSIX file descriptors, an exception is thrown.
-
- See [below](#with-ref-caveats) for caveats regarding this operation.
--}
-withFileDescriptorWritingBiased :: Handle -> (CInt -> IO r) -> IO r
-withFileDescriptorWritingBiased = withOSHandle "withFileDescriptorWritingBiased"
- handleStateVarWritingBiased
- getFileDescriptor
- flushBuffer
-
-{-|
- Obtains the Windows handle that underlies a Haskell handle or specifically
- the Windows handle for reading if the Haskell handle uses different Windows
- handles for reading and writing and executes a user-provided action on it.
- The Haskell-managed buffers related to the Windows handle are flushed before
- the user-provided action is run. While this action is executed, further
- operations on the Haskell handle are blocked to a degree that interference
- with this action is prevented.
-
- If the Haskell handle does not use Windows handles, an exception is thrown.
-
- See [below](#with-ref-caveats) for caveats regarding this operation.
--}
-withWindowsHandleReadingBiased :: Handle -> (Ptr () -> IO r) -> IO r
-withWindowsHandleReadingBiased = withOSHandle "withWindowsHandleReadingBiased"
- handleStateVarReadingBiased
- getWindowsHandle
- flushBuffer
-
-{-|
- Obtains the Windows handle that underlies a Haskell handle or specifically
- the Windows handle for writing if the Haskell handle uses different Windows
- handles for reading and writing and executes a user-provided action on it.
- The Haskell-managed buffers related to the Windows handle are flushed before
- the user-provided action is run. While this action is executed, further
- operations on the Haskell handle are blocked to a degree that interference
- with this action is prevented.
-
- If the Haskell handle does not use Windows handles, an exception is thrown.
-
- See [below](#with-ref-caveats) for caveats regarding this operation.
--}
-withWindowsHandleWritingBiased :: Handle -> (Ptr () -> IO r) -> IO r
-withWindowsHandleWritingBiased = withOSHandle "withWindowsHandleWritingBiased"
- handleStateVarWritingBiased
- getWindowsHandle
- flushBuffer
-
-{-|
- Like 'withFileDescriptorReadingBiased' except that Haskell-managed buffers
- are not flushed.
--}
-withFileDescriptorReadingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
-withFileDescriptorReadingBiasedRaw
- = withOSHandle "withFileDescriptorReadingBiasedRaw"
- handleStateVarReadingBiased
- getFileDescriptor
- (const $ return ())
-
-{-|
- Like 'withFileDescriptorWritingBiased' except that Haskell-managed buffers
- are not flushed.
--}
-withFileDescriptorWritingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
-withFileDescriptorWritingBiasedRaw
- = withOSHandle "withFileDescriptorWritingBiasedRaw"
- handleStateVarWritingBiased
- getFileDescriptor
- (const $ return ())
-
-{-|
- Like 'withWindowsHandleReadingBiased' except that Haskell-managed buffers
- are not flushed.
--}
-withWindowsHandleReadingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
-withWindowsHandleReadingBiasedRaw
- = withOSHandle "withWindowsHandleReadingBiasedRaw"
- handleStateVarReadingBiased
- getWindowsHandle
- (const $ return ())
-
-{-|
- Like 'withWindowsHandleWritingBiased' except that Haskell-managed buffers
- are not flushed.
--}
-withWindowsHandleWritingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
-withWindowsHandleWritingBiasedRaw
- = withOSHandle "withWindowsHandleWritingBiasedRaw"
- handleStateVarWritingBiased
- getWindowsHandle
- (const $ return ())
-
--- ** Caveats
-
-{-$with-ref-caveats
- #with-ref-caveats#There are the following caveats regarding the above
- operations:
-
- * Flushing of buffers can fail if the given handle is readable but not
- seekable.
-
- * If one of these operation is performed as part of an action executed by
- 'unsafePerformIO', 'unsafeInterleaveIO', or one of their “dupable”
- variants and the user-provided action receives an asychnchronous
- exception and does not catch it, then the following happens:
-
- - Before the overall computation is suspended, the blocking of handle
- operations is removed.
-
- - When the computation is later resumed due to another evaluation
- attempt, the blocking of handle operations is reinstantiated, the
- Haskell-managed buffers are flushed again, and the user-provided
- action is run from the beginning.
-
- Repeating the previously executed part of the user-provided action
- cannot be avoided apparently. See the @[async]@ note in the source code
- of "GHC.Internal.IO.Handle.Internals" for further explanation.
--}
=====================================
libraries/base/src/System/IO/OS.hs
=====================================
@@ -0,0 +1,342 @@
+{-# LANGUAGE Safe #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE RankNTypes #-}
+
+{-|
+ This module bridges between Haskell handles and underlying operating-system
+ features.
+-}
+module System.IO.OS
+(
+ -- * Obtaining file descriptors and Windows handles
+ withFileDescriptorReadingBiased,
+ withFileDescriptorWritingBiased,
+ withWindowsHandleReadingBiased,
+ withWindowsHandleWritingBiased,
+ withFileDescriptorReadingBiasedRaw,
+ withFileDescriptorWritingBiasedRaw,
+ withWindowsHandleReadingBiasedRaw,
+ withWindowsHandleWritingBiasedRaw
+
+ -- ** Caveats
+ -- $with-ref-caveats
+)
+where
+
+import GHC.Internal.Control.Monad (return)
+import GHC.Internal.Control.Concurrent.MVar (MVar)
+import GHC.Internal.Control.Exception (mask)
+import GHC.Internal.Data.Function (const, (.), ($))
+import GHC.Internal.Data.Functor (fmap)
+#if defined(mingw32_HOST_OS)
+import GHC.Internal.Data.Bool (otherwise)
+#endif
+import GHC.Internal.Data.Maybe (Maybe (Nothing), maybe)
+#if defined(mingw32_HOST_OS)
+import GHC.Internal.Data.Maybe (Maybe (Just))
+#endif
+import GHC.Internal.Data.List ((++))
+import GHC.Internal.Data.String (String)
+import GHC.Internal.Data.Typeable (Typeable, cast)
+import GHC.Internal.System.IO (IO)
+import GHC.Internal.IO.FD (fdFD)
+#if defined(mingw32_HOST_OS)
+import GHC.Internal.IO.Windows.Handle
+ (
+ NativeHandle,
+ ConsoleHandle,
+ IoHandle,
+ toHANDLE
+ )
+#endif
+import GHC.Internal.IO.Handle.Types
+ (
+ Handle (FileHandle, DuplexHandle),
+ Handle__ (Handle__, haDevice)
+ )
+import GHC.Internal.IO.Handle.Internals (withHandle_', flushBuffer)
+import GHC.Internal.IO.Exception
+ (
+ IOErrorType (InappropriateType),
+ IOException (IOError),
+ ioException
+ )
+import GHC.Internal.Foreign.Ptr (Ptr)
+import GHC.Internal.Foreign.C.Types (CInt)
+
+-- * Obtaining POSIX file descriptors and Windows handles
+
+{-|
+ Executes a user-provided action on an operating-system handle that underlies
+ a Haskell handle. Before the user-provided action is run, user-defined
+ perparation based on the handle state that contains the operating-system
+ handle is performed. While the user-provided action is executed, further
+ operations on the Haskell handle are blocked to a degree that interference
+ with this action is prevented.
+
+ See [below](#with-ref-caveats) for caveats regarding this operation.
+-}
+withOSHandle :: String
+ -- ^ The name of the overall operation
+ -> (Handle -> MVar Handle__)
+ {-^
+ Obtaining of the handle state variable that holds the
+ operating-system handle
+ -}
+ -> (forall d. Typeable d => d -> IO a)
+ -- ^ Conversion of a device into an operating-system handle
+ -> (Handle__ -> IO ())
+ -- ^ The preparation
+ -> Handle
+ -- ^ The Haskell handle to use
+ -> (a -> IO r)
+ -- ^ The action to execute on the operating-system handle
+ -> IO r
+withOSHandle opName handleStateVar getOSHandle prepare handle act
+ = mask $ \ withOriginalMaskingState ->
+ withHandleState $ \ handleState@Handle__ {haDevice = dev} -> do
+ osHandle <- getOSHandle dev
+ prepare handleState
+ withOriginalMaskingState $ act osHandle
+ where
+
+ withHandleState = withHandle_' opName handle (handleStateVar handle)
+{-
+ The 'withHandle_'' operation, which we use here, already performs masking.
+ Still, we have to employ 'mask', in order do obtain the operation that
+ restores the original masking state. The user-provided action should be
+ executed with this original masking state, as there is no inherent reason to
+ generally perform it with masking in place. The masking that 'withHandle_''
+ performs is only for safely accessing handle state and thus constitutes an
+ implementation detail; it has nothing to do with the user-provided action.
+-}
+{-
+ The order of actions in 'withOSHandle' is such that any exception from
+ 'getOSHandle' is thrown before the flushing of the Haskell-managed buffers.
+-}
+
+{-|
+ Obtains the handle state variable that underlies a handle or specifically
+ the handle state variable for reading if the handle uses different state
+ variables for reading and writing.
+-}
+handleStateVarReadingBiased :: Handle -> MVar Handle__
+handleStateVarReadingBiased (FileHandle _ var) = var
+handleStateVarReadingBiased (DuplexHandle _ readingVar _) = readingVar
+
+{-|
+ Obtains the handle state variable that underlies a handle or specifically
+ the handle state variable for writing if the handle uses different state
+ variables for reading and writing.
+-}
+handleStateVarWritingBiased :: Handle -> MVar Handle__
+handleStateVarWritingBiased (FileHandle _ var) = var
+handleStateVarWritingBiased (DuplexHandle _ _ writingVar) = writingVar
+
+{-|
+ Yields the result of another operation if that operation succeeded, and
+ otherwise throws an exception that signals that the other operation failed
+ because some Haskell handle does not use an operating-system handle of a
+ required type.
+-}
+requiringOSHandleOfType :: String
+ -- ^ The name of the operating-system handle type
+ -> Maybe a
+ {-^
+ The result of the other operation if it succeeded
+ -}
+ -> IO a
+requiringOSHandleOfType osHandleTypeName
+ = maybe (ioException osHandleOfTypeRequired) return
+ where
+
+ osHandleOfTypeRequired :: IOException
+ osHandleOfTypeRequired
+ = IOError Nothing
+ InappropriateType
+ ""
+ ("handle does not use " ++ osHandleTypeName ++ "s")
+ Nothing
+ Nothing
+
+{-|
+ Obtains the POSIX file descriptor of a device if the device contains one,
+ and throws an exception otherwise.
+-}
+getFileDescriptor :: Typeable d => d -> IO CInt
+getFileDescriptor = requiringOSHandleOfType "POSIX file descriptor" .
+ fmap fdFD . cast
+
+{-|
+ Obtains the Windows handle of a device if the device contains one, and
+ throws an exception otherwise.
+-}
+getWindowsHandle :: Typeable d => d -> IO (Ptr ())
+getWindowsHandle = requiringOSHandleOfType "Windows handle" .
+ toMaybeWindowsHandle
+ where
+
+ toMaybeWindowsHandle :: Typeable d => d -> Maybe (Ptr ())
+#if defined(mingw32_HOST_OS)
+ toMaybeWindowsHandle dev
+ | Just nativeHandle <- cast dev :: Maybe (IoHandle NativeHandle)
+ = Just (toHANDLE nativeHandle)
+ | Just consoleHandle <- cast dev :: Maybe (IoHandle ConsoleHandle)
+ = Just (toHANDLE consoleHandle)
+ | otherwise
+ = Nothing
+ {-
+ This is inspired by the implementation of
+ 'System.Win32.Types.withHandleToHANDLENative'.
+ -}
+#else
+ toMaybeWindowsHandle _ = Nothing
+#endif
+
+{-|
+ Executes a user-provided action on the POSIX file descriptor that underlies
+ a handle or specifically on the POSIX file descriptor for reading if the
+ handle uses different file descriptors for reading and writing. The
+ Haskell-managed buffers related to the file descriptor are flushed before
+ the user-provided action is run. While this action is executed, further
+ operations on the handle are blocked to a degree that interference with this
+ action is prevented.
+
+ If the handle does not use POSIX file descriptors, an exception is thrown.
+
+ See [below](#with-ref-caveats) for caveats regarding this operation.
+-}
+withFileDescriptorReadingBiased :: Handle -> (CInt -> IO r) -> IO r
+withFileDescriptorReadingBiased = withOSHandle "withFileDescriptorReadingBiased"
+ handleStateVarReadingBiased
+ getFileDescriptor
+ flushBuffer
+
+{-|
+ Executes a user-provided action on the POSIX file descriptor that underlies
+ a handle or specifically on the POSIX file descriptor for writing if the
+ handle uses different file descriptors for reading and writing. The
+ Haskell-managed buffers related to the file descriptor are flushed before
+ the user-provided action is run. While this action is executed, further
+ operations on the handle are blocked to a degree that interference with this
+ action is prevented.
+
+ If the handle does not use POSIX file descriptors, an exception is thrown.
+
+ See [below](#with-ref-caveats) for caveats regarding this operation.
+-}
+withFileDescriptorWritingBiased :: Handle -> (CInt -> IO r) -> IO r
+withFileDescriptorWritingBiased = withOSHandle "withFileDescriptorWritingBiased"
+ handleStateVarWritingBiased
+ getFileDescriptor
+ flushBuffer
+
+{-|
+ Executes a user-provided action on the Windows handle that underlies a
+ Haskell handle or specifically on the Windows handle for reading if the
+ Haskell handle uses different Windows handles for reading and writing. The
+ Haskell-managed buffers related to the Windows handle are flushed before the
+ user-provided action is run. While this action is executed, further
+ operations on the Haskell handle are blocked to a degree that interference
+ with this action is prevented.
+
+ If the Haskell handle does not use Windows handles, an exception is thrown.
+
+ See [below](#with-ref-caveats) for caveats regarding this operation.
+-}
+withWindowsHandleReadingBiased :: Handle -> (Ptr () -> IO r) -> IO r
+withWindowsHandleReadingBiased = withOSHandle "withWindowsHandleReadingBiased"
+ handleStateVarReadingBiased
+ getWindowsHandle
+ flushBuffer
+
+{-|
+ Executes a user-provided action on the Windows handle that underlies a
+ Haskell handle or specifically on the Windows handle for writing if the
+ Haskell handle uses different Windows handles for reading and writing. The
+ Haskell-managed buffers related to the Windows handle are flushed before the
+ user-provided action is run. While this action is executed, further
+ operations on the Haskell handle are blocked to a degree that interference
+ with this action is prevented.
+
+ If the Haskell handle does not use Windows handles, an exception is thrown.
+
+ See [below](#with-ref-caveats) for caveats regarding this operation.
+-}
+withWindowsHandleWritingBiased :: Handle -> (Ptr () -> IO r) -> IO r
+withWindowsHandleWritingBiased = withOSHandle "withWindowsHandleWritingBiased"
+ handleStateVarWritingBiased
+ getWindowsHandle
+ flushBuffer
+
+{-|
+ Like 'withFileDescriptorReadingBiased' except that Haskell-managed buffers
+ are not flushed.
+-}
+withFileDescriptorReadingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
+withFileDescriptorReadingBiasedRaw
+ = withOSHandle "withFileDescriptorReadingBiasedRaw"
+ handleStateVarReadingBiased
+ getFileDescriptor
+ (const $ return ())
+
+{-|
+ Like 'withFileDescriptorWritingBiased' except that Haskell-managed buffers
+ are not flushed.
+-}
+withFileDescriptorWritingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
+withFileDescriptorWritingBiasedRaw
+ = withOSHandle "withFileDescriptorWritingBiasedRaw"
+ handleStateVarWritingBiased
+ getFileDescriptor
+ (const $ return ())
+
+{-|
+ Like 'withWindowsHandleReadingBiased' except that Haskell-managed buffers
+ are not flushed.
+-}
+withWindowsHandleReadingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
+withWindowsHandleReadingBiasedRaw
+ = withOSHandle "withWindowsHandleReadingBiasedRaw"
+ handleStateVarReadingBiased
+ getWindowsHandle
+ (const $ return ())
+
+{-|
+ Like 'withWindowsHandleWritingBiased' except that Haskell-managed buffers
+ are not flushed.
+-}
+withWindowsHandleWritingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
+withWindowsHandleWritingBiasedRaw
+ = withOSHandle "withWindowsHandleWritingBiasedRaw"
+ handleStateVarWritingBiased
+ getWindowsHandle
+ (const $ return ())
+
+-- ** Caveats
+
+{-$with-ref-caveats
+ #with-ref-caveats#There are the following caveats regarding the above
+ operations:
+
+ * Flushing of buffers can fail if the given handle is readable but not
+ seekable.
+
+ * If one of these operations is performed as part of an action executed by
+ 'System.IO.Unsafe.unsafePerformIO',
+ 'System.IO.Unsafe.unsafeInterleaveIO', or one of their “dupable”
+ variants and the user-provided action receives an asychnchronous
+ exception and does not catch it, then the following happens:
+
+ - Before the overall computation is suspended, the blocking of handle
+ operations is removed.
+
+ - When the computation is later resumed due to another evaluation
+ attempt, the blocking of handle operations is reinstantiated, the
+ Haskell-managed buffers are flushed again, and the user-provided
+ action is run from the beginning.
+
+ Repeating the previously executed part of the user-provided action
+ cannot be avoided apparently. See the @[async]@ note in the source code
+ of "GHC.Internal.IO.Handle.Internals" for further explanation.
+-}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f9dbc836f4cd02906321aa59268fb…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f9dbc836f4cd02906321aa59268fb…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/andreask/bomb_out] exprSize: Accumulate size as we go to allow early bomb out.
by Andreas Klebinger (@AndreasK) 24 Sep '25
by Andreas Klebinger (@AndreasK) 24 Sep '25
24 Sep '25
Andreas Klebinger pushed to branch wip/andreask/bomb_out at Glasgow Haskell Compiler / GHC
Commits:
76d7a6ad by Andreas Klebinger at 2025-09-24T19:54:36+02:00
exprSize: Accumulate size as we go to allow early bomb out.
- - - - -
2 changed files:
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Unfold.hs
Changes:
=====================================
compiler/GHC/Core/Opt/OccurAnal.hs
=====================================
@@ -2,7 +2,9 @@
{-# OPTIONS_GHC -cpp -Wno-incomplete-record-updates #-}
-{-# OPTIONS_GHC -fmax-worker-args=12 #-}
+{-# OPTIONS_GHC -fmax-worker-args=12 -fprof-late #-}
+
+{-# OPTIONS_GHC -dumpdir dumps -ddump-to-file -ddump-simpl #-}
-- The -fmax-worker-args=12 is there because the main functions
-- are strict in the OccEnv, and it turned out that with the default settting
-- some functions would unbox the OccEnv ad some would not, depending on how
=====================================
compiler/GHC/Core/Unfold.hs
=====================================
@@ -1,3 +1,5 @@
+{-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dumpdir dumps #-}
+
{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1994-1998
@@ -335,6 +337,7 @@ isValFun (Lam b e) | isRuntimeVar b = True
| otherwise = isValFun e
isValFun _ = False
+{-# NOINLINE calcUnfoldingGuidance #-}
calcUnfoldingGuidance
:: UnfoldingOpts
-> Bool -- Definitely a top-level, bottoming binding
@@ -567,43 +570,43 @@ sizeExpr :: UnfoldingOpts
-- Forcing bOMB_OUT_SIZE early prevents repeated
-- unboxing of the Int argument.
sizeExpr opts !bOMB_OUT_SIZE top_args expr
- = size_up expr
+ = size_up sizeZero expr
where
- size_up (Cast e _) = size_up e
- size_up (Tick _ e) = size_up e
- size_up (Type _) = sizeZero -- Types cost nothing
- size_up (Coercion _) = sizeZero
- size_up (Lit lit) = sizeN (litSize lit)
- size_up (Var f) | isZeroBitId f = sizeZero
- -- Make sure we get constructor discounts even
- -- on nullary constructors
- | otherwise = size_up_call f [] 0
-
- size_up (App fun arg)
- | isTyCoArg arg = size_up fun
- | otherwise = size_up arg `addSizeNSD`
- size_up_app fun [arg] (if isZeroBitExpr arg then 1 else 0)
-
- size_up (Lam b e)
- | isId b && not (isZeroBitId b) = lamScrutDiscount opts (size_up e `addSizeN` 10)
- | otherwise = size_up e
-
- size_up (Let (NonRec binder rhs) body)
- = size_up_rhs (binder, rhs) `addSizeNSD`
- size_up body `addSizeN`
- size_up_alloc binder
-
- size_up (Let (Rec pairs) body)
- = foldr (addSizeNSD . size_up_rhs)
- (size_up body `addSizeN` sum (map (size_up_alloc . fst) pairs))
- pairs
-
- size_up (Case e _ _ alts) = case nonEmpty alts of
- Nothing -> size_up e -- case e of {} never returns, so take size of scrutinee
+ size_up :: ExprSize -> CoreExpr -> ExprSize
+ size_up s (Cast e _) = size_up s e
+ size_up s (Tick _ e) = size_up s e
+ size_up s (Type _) = s -- Types cost nothing
+ size_up s (Coercion _) = s
+ size_up s (Lit lit) = addSizeNSD (sizeN (litSize lit)) s
+ size_up s (Var f) | isZeroBitId f = s
+ -- Make sure we get constructor discounts even
+ -- on nullary constructors
+ | otherwise = size_up_call s f [] 0
+
+ size_up s (App fun arg)
+ | isTyCoArg arg = size_up s fun
+ | otherwise = size_up_app (stripDiscounts $ size_up s arg)
+ fun [arg] (if isZeroBitExpr arg then 1 else 0)
+
+ size_up s (Lam b e)
+ | isId b && not (isZeroBitId b) = lamScrutDiscount opts (size_up (addSizeN s 10) e)
+ | otherwise = size_up s e
+
+ size_up s (Let (NonRec binder rhs) body)
+ = let rhs_s = size_up_rhs s (binder, rhs)
+ in size_up (stripDiscounts $ rhs_s `addSizeN` size_up_alloc binder) body
+
+
+ size_up s (Let (Rec pairs) body)
+ = size_up (stripDiscounts (foldr (flip size_up_rhs) s pairs))
+ body
+
+ size_up s (Case e _ _ alts) = case nonEmpty alts of
+ Nothing -> size_up s e -- case e of {} never returns, so take size of scrutinee
Just alts
| Just v <- is_top_arg e -> -- We are scrutinising an argument variable
let
- alt_sizes = NE.map size_up_alt alts
+ alt_sizes = NE.map (size_up_alt s) alts
-- alts_size tries to compute a good discount for
-- the case when we are scrutinising an argument variable
@@ -625,18 +628,19 @@ sizeExpr opts !bOMB_OUT_SIZE top_args expr
alts_size tot_size _ = tot_size
in
- alts_size (foldr1 addAltSize alt_sizes) -- alts is non-empty
- (foldr1 maxSize alt_sizes)
+ s `addSizeNSD` alts_size (foldr1 addAltSize alt_sizes) -- alts is non-empty
+ (foldr1 maxSize alt_sizes)
-- Good to inline if an arg is scrutinised, because
-- that may eliminate allocation in the caller
-- And it eliminates the case itself
- | otherwise -> size_up e `addSizeNSD`
- foldr (addAltSize . size_up_alt) case_size alts
+ | otherwise -> let case_s = size_up s e `addSizeNSD` case_size
+ in foldr (addAltSize . size_up_alt case_s) case_s alts
where
is_top_arg (Var v) | v `elem` top_args = Just v
is_top_arg (Cast e _) = is_top_arg e
+ is_top_arg (Tick _t e) = is_top_arg e
is_top_arg _ = Nothing
where
@@ -675,44 +679,52 @@ sizeExpr opts !bOMB_OUT_SIZE top_args expr
| otherwise
= False
- size_up_rhs (bndr, rhs)
+ size_up_rhs :: ExprSize -> (Id, CoreExpr) -> ExprSize
+ size_up_rhs s (bndr, rhs)
| JoinPoint join_arity <- idJoinPointHood bndr
-- Skip arguments to join point
, (_bndrs, body) <- collectNBinders join_arity rhs
- = size_up body
+ = size_up s body
| otherwise
- = size_up rhs
+ = size_up s rhs
------------
-- size_up_app is used when there's ONE OR MORE value args
- size_up_app (App fun arg) args voids
- | isTyCoArg arg = size_up_app fun args voids
- | isZeroBitExpr arg = size_up_app fun (arg:args) (voids + 1)
- | otherwise = size_up arg `addSizeNSD`
- size_up_app fun (arg:args) voids
- size_up_app (Var fun) args voids = size_up_call fun args voids
- size_up_app (Tick _ expr) args voids = size_up_app expr args voids
- size_up_app (Cast expr _) args voids = size_up_app expr args voids
- size_up_app other args voids = size_up other `addSizeN`
- callSize (length args) voids
+ size_up_app :: ExprSize -> CoreExpr -> [CoreExpr] -> Int -> ExprSize
+ size_up_app s (App fun arg) args voids
+ | isTyCoArg arg = size_up_app s fun args voids
+ | isZeroBitExpr arg = size_up_app s fun (arg:args) (voids + 1)
+ | otherwise = let arg_size = stripDiscounts $ size_up s arg
+ in size_up_app arg_size fun (arg:args) voids
+ size_up_app s (Var fun) args voids = size_up_call s fun args voids
+ size_up_app s (Tick _ expr) args voids = size_up_app s expr args voids
+ size_up_app s (Cast expr _) args voids = size_up_app s expr args voids
+ size_up_app s other args voids = size_up (s `addSizeN` callSize (length args) voids) other
+
-- if the lhs is not an App or a Var, or an invisible thing like a
-- Tick or Cast, then we should charge for a complete call plus the
-- size of the lhs itself.
------------
- size_up_call :: Id -> [CoreExpr] -> Int -> ExprSize
- size_up_call fun val_args voids
- = case idDetails fun of
- FCallId _ -> sizeN (callSize (length val_args) voids)
- DataConWorkId dc -> conSize dc (length val_args)
- PrimOpId op _ -> primOpSize op (length val_args)
- ClassOpId cls _ -> classOpSize opts cls top_args val_args
- _ | fun `hasKey` buildIdKey -> buildSize
- | fun `hasKey` augmentIdKey -> augmentSize
- | otherwise -> funSize opts top_args fun (length val_args) voids
+ size_up_call :: ExprSize -> Id -> [CoreExpr] -> Int -> ExprSize
+ size_up_call s fun val_args voids
+ = let call_size = case idDetails fun of
+ FCallId _ -> sizeN (callSize (length val_args) voids)
+ DataConWorkId dc -> conSize dc (length val_args)
+ PrimOpId op _ -> primOpSize op (length val_args)
+ ClassOpId cls _ -> classOpSize opts cls top_args val_args
+ _ | fun `hasKey` buildIdKey -> buildSize
+ | fun `hasKey` augmentIdKey -> augmentSize
+ | otherwise -> funSize opts top_args fun (length val_args) voids
+ in s `addSizeNSD` call_size
------------
- size_up_alt (Alt _con _bndrs rhs) = size_up rhs `addSizeN` 10
+ -- size_up_alt returns on the alternatives size, not including the accumulated size passed in unless we reach TooBig
+ size_up_alt TooBig _ = TooBig
+ size_up_alt (SizeIs {_es_size_is=s}) (Alt _con _bndrs rhs) =
+ size_up (sizeN $ s + 10) rhs
+ `addSizeN` (-s) -- Why add and then subtract s? If the expression is already large we will bomb out early this way.
+
-- Don't charge for args, so that wrappers look cheap
-- (See comments about wrappers with Case)
--
@@ -753,6 +765,9 @@ sizeExpr opts !bOMB_OUT_SIZE top_args expr
(xs `unionBags` ys)
d2 -- Ignore d1
+ stripDiscounts TooBig = TooBig
+ stripDiscounts (SizeIs n xs _) = (SizeIs n xs 0)
+
-- don't count expressions such as State# RealWorld
-- exclude join points, because they can be rep-polymorphic
-- and typePrimRep will crash
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76d7a6adeee40491157a2f90aa70c11…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76d7a6adeee40491157a2f90aa70c11…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
24 Sep '25
Andreas Klebinger pushed new branch wip/andreask/bomb_out at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/bomb_out
You're receiving this email because of your account on gitlab.haskell.org.
1
0