[Git][ghc/ghc][wip/T13253] 16 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake
Ben Gamari
gitlab at gitlab.haskell.org
Thu Jun 25 14:59:21 UTC 2020
Ben Gamari pushed to branch wip/T13253 at Glasgow Haskell Compiler / GHC
Commits:
809caedf by John Ericson at 2020-06-23T22:47:37-04:00
Switch from HscSource to IsBootInterface for module lookup in GhcMake
We look up modules by their name, and not their contents. There is no
way to separately reference a signature vs regular module; you get what
you get. Only boot files can be referenced indepenently with `import {-#
SOURCE #-}`.
- - - - -
7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00
Cmm: introduce SAVE_REGS/RESTORE_REGS
We don't want to save both Fn and Dn register sets on x86-64 as they are
aliased to the same arch register (XMMn).
Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]`
which makes a set of Cmm registers alive so that they cover all arch
registers used to pass parameter, we could have Fn, Dn and XMMn alive at
the same time. It made the LLVM code generator choke (see #17920).
Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of
registers.
- - - - -
2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00
CmmToC: don't add extern decl to parsed Cmm data
Previously, if a .cmm file *not in the RTS* contained something like:
```cmm
section "rodata" { msg : bits8[] "Test\n"; }
```
It would get compiled by CmmToC into:
```c
ERW_(msg);
const char msg[] = "Test\012";
```
and fail with:
```
/tmp/ghc32129_0/ghc_4.hc:5:12: error:
error: conflicting types for \u2018msg\u2019
const char msg[] = "Test\012";
^~~
In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error:
/tmp/ghc32129_0/ghc_4.hc:4:6: error:
note: previous declaration of \u2018msg\u2019 was here
ERW_(msg);
^
/builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error:
note: in definition of macro \u2018ERW_\u2019
#define ERW_(X) extern StgWordArray (X)
^
```
See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes
Now we don't generate these extern declarations (ERW_, etc.) for
top-level data. It shouldn't change anything for the RTS (the only place
we use .cmm files) as it is already special cased in
`GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit
extern declarations when needed.
Note that it allows `cgrun069` test to pass with CmmToC (cf #15467).
- - - - -
5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00
LLVM: refactor and comment register padding code (#17920)
- - - - -
cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00
Add tests for #17920
Metric Decrease:
T12150
T12234
- - - - -
a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00
Fix issue #18262 by zonking constraints after solving
Zonk residual constraints in checkForExistence to reveal user type
errors.
Previously when `:instances` was used with instances that have TypeError
constraints the result would look something like:
instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10
whereas after zonking, `:instances` now sees the `TypeError` and
properly eliminates the constraint from the results.
- - - - -
181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00
Fix a buglet in Simplify.simplCast
This bug, revealed by #18347, is just a missing update to
sc_hole_ty in simplCast. I'd missed a code path when I
made the recentchanges in
commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu May 21 12:53:35 2020 +0100
Implement cast worker/wrapper properly
The fix is very easy.
Two other minor changes
* Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an
outright bug, introduced in the fix to #18112: we were simplifying
the same coercion twice *with the same substitution*, which is just
wrong. It'd be a hard bug to trigger, so I just fixed it; less code
too.
* Better debug printing of ApplyToVal
- - - - -
625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00
Two small tweaks to Coercion.simplifyArgsWorker
These tweaks affect the inner loop of simplifyArgsWorker, which
in turn is called from the flattener in Flatten.hs. This is
a key perf bottleneck to T9872{a,b,c,d}.
These two small changes have a modest but useful benefit.
No change in functionality whatsoever.
Relates to #18354
- - - - -
b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00
Don't use timesInt2# with GHC < 8.11 (fix #18358)
- - - - -
7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00
Fix invalid printf format
- - - - -
a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00
Add missing entry to freeNamesItem (#18369)
- - - - -
a0ed9823 by Simon Peyton Jones at 2020-06-25T10:57:21-04:00
Make arityType deal with join points
As Note [Eta-expansion and join points] describes,
this patch makes arityType deal correctly with join points.
What was there before was not wrong, but yielded lower
arities than it could.
Fixes #18328
In base GHC this makes no difference to nofib.
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
n-body -0.1% -0.1% -1.2% -1.1% 0.0%
--------------------------------------------------------------------------------
Min -0.1% -0.1% -55.0% -56.5% 0.0%
Max -0.0% 0.0% +16.1% +13.4% 0.0%
Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0%
But it starts to make real difference when we land the change to the
way mkDupableAlts handles StrictArg, in fixing #13253 and friends.
I think this is because we then get more non-inlined join points.
- - - - -
019bcff5 by Simon Peyton Jones at 2020-06-25T10:57:28-04:00
Improve eta-expansion using ArityType
As #18355 shows, we were failing to preserve one-shot info when
eta-expanding. It's rather easy to fix, by using ArityType more,
rather than just Arity.
This patch is important to suport the one-shot monad trick;
see #18202.
- - - - -
2d8e1ccc by Sebastian Graf at 2020-06-25T10:57:29-04:00
GHC.Core.Unify: Make UM actions one-shot by default
This MR makes the UM monad in GHC.Core.Unify into a one-shot
monad. See the long Note [The one-shot state monad trick].
See also #18202 and !3309, which applies this to all Reader/State-like
monads in GHC for compile-time perf improvements. The pattern used
here enables something similar to the state-hack, but is applicable to
user-defined monads, not just `IO`.
Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'):
haddock.Cabal
- - - - -
3b75cbbd by Simon Peyton Jones at 2020-06-25T10:57:29-04:00
Reduce result discount in conSize
Ticket #18282 showed that the result discount given by conSize
was massively too large. This patch reduces that discount to
a constant 10, which just balances the cost of the constructor
application itself.
Note [Constructor size and result discount] elaborates, as
does the ticket #18282.
Reducing result discount reduces inlining, which affects perf. I
found that I could increase the unfoldingUseThrehold from 80 to 90 in
compensation; in combination with the result discount change I get
these overall nofib numbers:
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
boyer -0.3% +5.4% +0.7% +1.0% 0.0%
cichelli -0.3% +5.9% -9.9% -9.5% 0.0%
compress2 -0.4% +9.6% +7.2% +6.4% 0.0%
constraints -0.3% +0.2% -3.0% -3.4% 0.0%
cryptarithm2 -0.3% -3.9% -2.2% -2.4% 0.0%
gamteb -0.4% +2.5% +2.8% +2.8% 0.0%
life -0.3% -2.2% -4.7% -4.9% 0.0%
lift -0.3% -0.3% -0.8% -0.5% 0.0%
linear -0.3% -0.1% -4.1% -4.5% 0.0%
mate -0.2% +1.4% -2.2% -1.9% -14.3%
parser -0.3% -2.1% -5.4% -4.6% 0.0%
puzzle -0.3% +2.1% -6.6% -6.3% 0.0%
simple -0.4% +2.8% -3.4% -3.3% -2.2%
veritas -0.1% +0.7% -0.6% -1.1% 0.0%
wheel-sieve2 -0.3% -19.2% -24.9% -24.5% -42.9%
--------------------------------------------------------------------------------
Min -0.4% -19.2% -24.9% -24.5% -42.9%
Max +0.1% +9.6% +7.2% +6.4% +33.3%
Geometric Mean -0.3% -0.0% -3.0% -2.9% -0.3%
I'm ok with these numbers, remembering that this change removes
an *exponential* increase in code size in some in-the-wild cases.
I investigated compress2. The difference is entirely caused by this
function no longer inlining
WriteRoutines.$woutputCodes
= \ (w :: [CodeEvent]) ->
let result_s1Sr
= case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of
(# ww1, ww2 #) -> (ww1, ww2)
in (# case result_s1Sr of (x, _) ->
map @Int @Char WriteRoutines.outputCodes1 x
, case result_s1Sr of { (_, y) -> y } #)
It was right on the cusp before, driven by the excessive result
discount. Too bad!
Metric Decrease:
T12227
T12545
T15263
T1969
T5030
T9872a
T9872c
- - - - -
6b9eab2f by Simon Peyton Jones at 2020-06-25T10:57:29-04:00
This patch addresses the exponential blow-up in the simplifier.
Specifically:
#13253 exponential inlining
#10421 ditto
#18140 strict constructors
#18282 another nested-function call case
This patch makes two significant changes:
1. For Ids that are used at most once in each branch of a case,
make the occurrence analyser record the total number of
syntactic occurrences. Then in postInlineUnconditionally
use that info to avoid inling something many many times.
Actual changes:
* See the occ_n_br field of OneOcc.
* postInlineUnconditionally
See Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils
2. Change the way that mkDupableCont handles StrictArg.
The details are explained in GHC.Core.Opt.Simplify
Note [Duplicating StrictArg]
Current nofib run
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
VS -0.3% +115.9% +12.1% +11.2% 0.0%
boyer2 -0.3% +10.0% +3.5% +4.0% 0.0%
cryptarithm2 -0.3% +39.0% +16.6% +16.1% 0.0%
gamteb -0.3% +4.1% -0.0% +0.4% 0.0%
last-piece -0.3% +1.4% -1.1% -0.4% 0.0%
mate -0.4% -11.1% -8.5% -9.0% 0.0%
multiplier -0.3% -2.2% -1.5% -1.5% 0.0%
transform -0.3% +3.4% +0.5% +0.8% 0.0%
--------------------------------------------------------------------------------
Min -0.8% -11.1% -8.5% -9.0% 0.0%
Max -0.3% +115.9% +30.1% +26.4% 0.0%
Geometric Mean -0.3% +1.0% +1.0% +1.0% -0.0%
Should investigate these numbers.
But the tickets are indeed cured, I think.
- - - - -
30 changed files:
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/CmmToLlvm/Base.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/StgToCmm/Prof.hs
- compiler/GHC/StgToCmm/Ticky.hs
- compiler/GHC/StgToCmm/Utils.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Id/Info.hs
- docs/users_guide/ghci.rst
- includes/Cmm.h
- libraries/ghc-bignum/src/GHC/Num/Integer.hs
- rts/StgMiscClosures.cmm
- rts/linker/MachO.c
- testsuite/driver/testlib.py
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6247763a9d3b41b4d62a9701fadcd5891b9e21c...6b9eab2f53b1a1dd220f66ae6360670773f36ea2
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6247763a9d3b41b4d62a9701fadcd5891b9e21c...6b9eab2f53b1a1dd220f66ae6360670773f36ea2
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200625/1ae6014b/attachment-0001.html>
More information about the ghc-commits
mailing list