[Git][ghc/ghc][wip/T17917] 19 commits: Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie

Simon Peyton Jones gitlab at gitlab.haskell.org
Wed Apr 8 09:34:06 UTC 2020



Simon Peyton Jones pushed to branch wip/T17917 at Glasgow Haskell Compiler / GHC


Commits:
ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00
Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie
flag to dump pretty printed contents of the .hie file

Metric Increase:
   hie002

Because of the regression on i386:

compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10:
    Expected    hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10%
    Lower bound hie002 (normal) compile_time/bytes allocated:   524713399
    Upper bound hie002 (normal) compile_time/bytes allocated:   641316377
    Actual      hie002 (normal) compile_time/bytes allocated:   877986292
    Deviation   hie002 (normal) compile_time/bytes allocated:        50.6 %
*** unexpected stat test failure for hie002(normal)

- - - - -
9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00
Improve and refactor StgToCmm codegen for DataCons.

We now differentiate three cases of constructor bindings:

1)Bindings which we can "replace" with a reference to
  an existing closure. Reference the replacement closure
  when accessing the binding.
2)Bindings which we can "replace" as above. But we still
  generate a closure which will be referenced by modules
  importing this binding.
3)For any other binding generate a closure. Then reference
  it.

Before this patch 1) did only apply to local bindings and we
didn't do 2) at all.

- - - - -
a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00
Add singleton to NonEmpty in libraries/base

This adds a definition to construct a singleton non-empty list
(Data.List.NonEmpty) according to issue #17851.

- - - - -
f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Testsuite: measure compiler stats for T16190

We were mistakenly measuring program stats

- - - - -
a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Move blob handling into StgToCmm

Move handling of big literal strings from CmmToAsm to StgToCmm. It
avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move
this handling even higher in the pipeline in the future (cf #17960):
this patch will make it easier.

- - - - -
cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Refactor CmmStatics

In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils
and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype
(before SRT generation) and `RawCmmStatics` datatype (after SRT
generation).

This patch removes this redundant code by using a single GADT for
(Raw)CmmStatics.

- - - - -
9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00
Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs

- - - - -
1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00
Turn newlines into spaces for hadrian/ghci.

The newlines break the command on windows.

- - - - -
4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00
Major improvements to the specialiser

This patch is joint work of Alexis King and Simon PJ.  It does some
significant refactoring of the type-class specialiser.  Main highlights:

* We can specialise functions with types like
     f :: Eq a => a -> Ord b => b => blah
  where the classes aren't all at the front (#16473).  Here we can
  correctly specialise 'f' based on a call like
     f @Int @Bool dEqInt x dOrdBool
  This change really happened in an earlier patch
     commit 2d0cf6252957b8980d89481ecd0b79891da4b14b
     Author: Sandy Maguire <sandy at sandymaguire.me>
     Date:   Thu May 16 12:12:10 2019 -0400
  work that this new patch builds directly on that work, and refactors
  it a bit.

* We can specialise functions with implicit parameters (#17930)
     g :: (?foo :: Bool, Show a) => a -> String
  Previously we could not, but now they behave just like a non-class
  argument as in 'f' above.

* We can specialise under-saturated calls, where some (but not all of
  the dictionary arguments are provided (#17966).  For example, we can
  specialise the above 'f' based on a call
     map (f @Int dEqInt) xs
  even though we don't (and can't) give Ord dictionary.

  This may sound exotic, but #17966 is a program from the wild, and
  showed significant perf loss for functions like f, if you need
  saturation of all dictionaries.

* We fix a buglet in which a floated dictionary had a bogus demand
  (#17810), by using zapIdDemandInfo in the NonRec case of specBind.

* A tiny side benefit: we can drop dead arguments to specialised
  functions; see Note [Drop dead args from specialisations]

* Fixed a bug in deciding what dictionaries are "interesting"; see
  Note [Keep the old dictionaries interesting]

This is all achieved by by building on Sandy Macguire's work in
defining SpecArg, which mkCallUDs uses to describe the arguments of
the call. Main changes:

* Main work is in specHeader, which marched down the [InBndr] from the
  function definition and the [SpecArg] from the call site, together.

* specCalls no longer has an arity check; the entire mechanism now
  handles unders-saturated calls fine.

* mkCallUDs decides on an argument-by-argument basis whether to
  specialise a particular dictionary argument; this is new.
  See mk_spec_arg in mkCallUDs.

It looks as if there are many more lines of code, but I think that
all the extra lines are comments!

- - - - -
40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00
Revert accidental change in 9462452

[ci skip]

- - - - -
bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00
Enable ImpredicativeTypes internally when typechecking selector bindings

This is necessary for certain record selectors with higher-rank
types, such as the examples in #18005. See
`Note [Impredicative record selectors]` in `TcTyDecls`.

Fixes #18005.

- - - - -
dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00
Don't override proc CafInfos in ticky builds

Fixes #17947

When we have a ticky label for a proc, IdLabels for the ticky counter
and proc entry share the same Name. This caused overriding proc CafInfos
with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis.

We now ignore the ticky labels when building SRTMaps. This makes sense
because:

- When building the current module they don't need to be in SRTMaps as
  they're initialized as non-CAFFY (see mkRednCountsLabel), so they
  don't take part in the dependency analysis and they're never added to
  SRTs.

  (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency,
  non-CAFFY uses are not considered as dependencies for the algorithm)

- They don't appear in the interfaces as they're not exported, so it
  doesn't matter for cross-module concerns whether they're in the SRTMap
  or not.

See also the new Note [Ticky labels in SRT analysis].

- - - - -
cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00
Fix an tricky specialiser loop

Issue #17151 was a very tricky example of a bug in which the
specialiser accidentally constructs a recurive dictionary,
so that everything turns into bottom.

I have fixed variants of this bug at least twice before:
see Note [Avoiding loops].  It was a bit of a struggle
to isolate the problem, greatly aided by the work that
Alexey Kuleshevich did in distilling a test case.

Once I'd understood the problem, it was not difficult to fix,
though it did lead me a bit of refactoring in specImports.

- - - - -
e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00
Refactoring only

This refactors DictBinds into a data type rather than a pair.
No change in behaviour, just better code

- - - - -
f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00
rts: ProfHeap: Fix memory leak when not compiled with profiling

If we're doing heap profiling on an unprofiled executable we keep
allocating new space in initEra via nextEra on each profiler run but we
don't have a corresponding freeEra call.

We do free the last era in endHeapProfiling but previous eras will have
been overwritten by initEra and will never get free()ed.

Metric Decrease:
    space_leak_001

- - - - -
bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00
Re-export GHC.Magic.noinline from base

- - - - -
3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00
simplifier: Kill off ufKeenessFactor

We used to have another factor, ufKeenessFactor, which would scale the
discounts before they were subtracted from the size. This was justified
with the following comment:

  -- We multiple the raw discounts (args_discount and result_discount)
  -- ty opt_UnfoldingKeenessFactor because the former have to do with
  --  *size* whereas the discounts imply that there's some extra
  --  *efficiency* to be gained (e.g. beta reductions, case reductions)
  -- by inlining.

However, this is highly suspect since it means that we subtract a
*scaled* size from an absolute size, resulting in crazy (e.g. negative)
scores in some cases (#15304). We consequently killed off
ufKeenessFactor and bumped up the ufUseThreshold to compensate.

Adjustment of unfolding use threshold
=====================================

Since this removes a discount from our inlining heuristic, I revisited our
default choice of -funfolding-use-threshold to minimize the change in
overall inlining behavior. Specifically, I measured runtime allocations
and executable size of nofib and the testsuite performance tests built
using compilers (and core libraries) built with several values of
-funfolding-use-threshold.

This comes as a result of a quantitative comparison of testsuite
performance and code size as a function of ufUseThreshold, comparing
GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set
consisted of nofib and the testsuite performance tests.
A full summary of these measurements are found in the description of
!2608

Comparing executable sizes (relative to the base commit) across all
nofib tests, we see that sizes are similar to the baseline:

            gmean      min      max   median
thresh
50         -6.36%   -7.04%   -4.82%   -6.46%
60         -5.04%   -5.97%   -3.83%   -5.11%
70         -2.90%   -3.84%   -2.31%   -2.92%
80         -0.75%   -2.16%   -0.42%   -0.73%
90         +0.24%   -0.41%   +0.55%   +0.26%
100        +1.36%   +0.80%   +1.64%   +1.37%
baseline   +0.00%   +0.00%   +0.00%   +0.00%

Likewise, looking at runtime allocations we see that 80 gives slightly
better optimisation than the baseline:

            gmean      min      max   median
thresh
50         +0.16%   -0.16%   +4.43%   +0.00%
60         +0.09%   -0.00%   +3.10%   +0.00%
70         +0.04%   -0.09%   +2.29%   +0.00%
80         +0.02%   -1.17%   +2.29%   +0.00%
90         -0.02%   -2.59%   +1.86%   +0.00%
100        +0.00%   -2.59%   +7.51%   -0.00%
baseline   +0.00%   +0.00%   +0.00%   +0.00%

Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is
worker-wrappered as the test expects. This makes me wonder whether the
inlining heuristic is now too liberal as `upd` is quite a large
function. The same measure was taken in T12600.

             Wall clock time compiling Cabal with -O0
thresh       50     60     70     80     90      100    baseline
build-Cabal  93.88  89.58  92.59  90.09  100.26  94.81  89.13

Also, this change happens to avoid the spurious test output in
`plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308).

Metric Decrease:
    hie002
    T12234
    T13035
    T13719
    T14683
    T4801
    T5631
    T5642
    T9020
    T9872d
    T9961
Metric Increase:
    T12150
    T12425
    T13701
    T14697
    T15426
    T1969
    T3064
    T5837
    T6048
    T9203
    T9872a
    T9872b
    T9872c
    T9872d
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00
Modules: type-checker (#13009)

Update Haddock submodule

- - - - -
6d9fd7cd by Simon Peyton Jones at 2020-04-08T09:22:08+01:00
Avoid useless w/w split

This patch is just a tidy-up for the post-strictness-analysis
worker wrapper split.  Consider

   f x = x

Strictnesss analysis does not lead to a w/w split, so the
obvious thing is to leave it 100% alone.  But actually, because
the RHS is small, we ended up adding a StableUnfolding for it.

There is some reason to do this if we choose /not/ do to w/w
on the grounds that the function is small.  See
Note [Don't w/w inline small non-loop-breaker things]

But there is no reason if we would not have done w/w anyway.

This patch just moves the conditional to later.  Easy.
This does move soem -ddump-simpl printouts around a bit.

I also discovered that the previous code was overwritten an
InlineCompulsory with InlineStable, which is utterly wrong.  That in
turn meant that some default methods (marked InlineCompulsory)
were getting their InlineCompulsory squashed. This patch fixes
that bug --- but of course that does mean a bit more inlining!

- - - - -


30 changed files:

- CODEOWNERS
- compiler/GHC.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Expr.hs
- compiler/GHC/Cmm/Info.hs
- compiler/GHC/Cmm/Info/Build.hs
- compiler/GHC/Cmm/Node.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Ppr/Decl.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
- compiler/GHC/CmmToAsm/PPC/RegInfo.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/SPARC/CodeGen.hs
- compiler/GHC/CmmToAsm/SPARC/CodeGen/Gen32.hs
- compiler/GHC/CmmToAsm/SPARC/Ppr.hs
- compiler/GHC/CmmToAsm/SPARC/ShortcutJump.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm.hs
- compiler/GHC/CmmToLlvm/Data.hs
- compiler/GHC/CmmToLlvm/Ppr.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Arity.hs
- compiler/GHC/Core/Class.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a18e3220ca0ab162a9f1047479f83fb7a327bfa...6d9fd7cd87afa68586da31973fd49036aa566d39

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a18e3220ca0ab162a9f1047479f83fb7a327bfa...6d9fd7cd87afa68586da31973fd49036aa566d39
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/20200408/f6fda4e3/attachment-0001.html>


More information about the ghc-commits mailing list