[Git][ghc/ghc][wip/expand-do] 63 commits: testsuite: Add mechanism to collect generic metrics

Apoorv Ingle (@ani) gitlab at gitlab.haskell.org
Thu Dec 14 04:38:00 UTC 2023



Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC


Commits:
b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00
testsuite: Add mechanism to collect generic metrics

* Generalise the metric logic by adding an additional field which
  allows you to specify how to query for the actual value. Previously
  the method of querying the baseline value was abstracted (but always
  set to the same thing).

* This requires rejigging how the stat collection works slightly but now
  it's more uniform and hopefully simpler.

* Introduce some new "generic" helper functions for writing generic
  stats tests.

  - collect_size ( deviation, path )
    Record the size of the file as a metric

  - stat_from_file ( metric, deviation, path )
    Read a value from the given path, and store that as a metric

  - collect_generic_stat ( metric, deviation, get_stat)
    Provide your own `get_stat` function, `lambda way: <Int>`, which
    can be used to establish the current value of the metric.

  - collect_generic_stats ( metric_info ):
    Like collect_generic_stat but provide the whole dictionary of metric
    definitions.

    { metric: {
        deviation: <Int>
        current: lambda way: <Int>
        } }

* Introduce two new "size" metrics for keeping track of build products.
    - `size_hello_obj` - The size of `hello.o` from compiling hello.hs
    - `libdir` - The total size of the `libdir` folder.

* Track the number of modules in the AST tests
   - CountDepsAst
   - CountDepsParser

This lays the infrastructure for #24191 #22256 #17129

- - - - -
7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00
x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives

Fixes #24222

- - - - -
4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00
EPA: Remove SrcSpanAnn

Now that we only have a single constructor for EpAnn, And it uses a
SrcSpan for its location, we can do away with SrcSpanAnn completely.
It only existed to wrap the original SrcSpan in a location, and
provide a place for the exact print annotation.

For darwin only:
Metric Increase:
    MultiLayerModulesTH_OneShot

Updates haddock submodule

- - - - -
e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00
testsuite: don't initialize testdir to '.'

The test directory is removed during cleanup, if there's an interrupt
that could remove the entire repository.

Fixes #24219

- - - - -
af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00
EPA: Clean up mkScope in Ast.hs

Now that we have HasLoc we can get rid of all the custom variants of
mkScope

For deb10-numa

Metric Increase:
    libdir

- - - - -
292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00
distrib: Rediscover otool and install_name_tool on Darwin

In the bindist configure script we must rediscover the `otool` and
`install_name_tool`s since they may be different from the build
environment.

Fixes #24211.

- - - - -
dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00
llvmGen: Align objects in the data section

Objects in the data section may be referenced via tagged pointers.
Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit
platforms, respectively.  Note, this may need to be reconsidered if
objects with a greater natural alignment requirement are emitted as e.g.
128-bit atomics.

Fixes #24163.

- - - - -
f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00
metrics: Widen libdir and size_hello_obj acceptance window

af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can
fluctuate quite significantly even when the change is quite small.
Therefore we widen the acceptance window to 10%.

- - - - -
99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00
EPA: Clean up TC Monad Utils

We no longer need the alternative variant of addLocM (addLocMA)
nor wrapLocAM, wrapLocSndMA.

aarch64-darwin
Metric Increase:
    MultiLayerModulesTH_OneShot

deb10-numa-slow
Metric Decrease:
    libdir

- - - - -
cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00
perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414)

And additionally to T12545, link from T8095, T13386 to this new Note.

- - - - -
c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00
EPA: EpaDelta for comment has no comments

EpaLocation is used to position things. It has two constructors,
EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a
possible list of comments.  The comment list is needed because the
location in EpaDelta has no absolute information to decide which
comments should be emitted before them when printing.

But it is also used for specifying the position of a comment.  To
prevent the absurdity of a comment position having a list of comments
in it, we make EpaLocation parameterisable, using comments for the
normal case and a constant for within comments.

Updates haddock submodule.

aarch64-darwin
Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -
bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00
Kind-check body of a required forall

We now require that in 'forall a -> ty', ty has kind TYPE r for some r.
Fixes #24176

- - - - -
010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Remove incorrect haddock link quotes in code block

- - - - -
cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Remove cycle from group haddock example

- - - - -
495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Use repl haddock syntax in group docs

- - - - -
d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Use list [] notation in group haddock

- - - - -
dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00
docs(NonEmpty/group): Specify final property of group function in haddock

- - - - -
cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00
fix: Add missing property of List.group

- - - - -
bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00
testsuite: Fix T21097b test with make 4.1 (deb9)

cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which
failed on deb9 because the version of make was emitting the recipe
failure to stdout rather than stderr.

One way to fix this is to be more precise in the test about which part
of the output we care about inspecting.

- - - - -
5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00
testsuite: Track size of libdir in bytes

For consistency it's better if we track all size metrics in bytes.

Metric Increase:
  libdir

- - - - -
f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00
testsuite: Remove rogue trace in testsuite

I accidentally left a trace in the generics metric patch.

- - - - -
d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00
Only exit ghci in -e mode when :add command fails

Previously, when running `ghci -e ':add Sample.hs'` the process would
exit with exit code 1 if the file exists and could be loaded.

Fixes #24115

- - - - -
0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00
T2T in Patterns (#23739)

This patch implements the T2T (term-to-type) transformation in patterns.
Patterns that are checked against a visible forall can now be written
without the `type` keyword:

	  \(type t) (x :: t) -> ...   -- old
	  \t (x :: t) -> ...          -- new

The `t` binder is parsed and renamed as a term pattern (Pat), but
then undergoes a conversion to a type pattern (HsTyPat).
See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs

- - - - -
10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00
Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234)

Before, the source location would point at the surrounding function definition,
causing the confusion in #24234.
I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _`
to make the warning message say "irrefutable pattern" instead of "pattern
binding".

- - - - -
36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00
libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0

Updates filepath submodule
Updates unix submodule

Fixes #24240

- - - - -
91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00
Submodule linter: Allow references to tags

We modify the submodule linter so that if the bumped commit is a
specific tag then the commit is accepted.

Fixes #24241

- - - - -
86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00
hadrian: set -Wno-deprecations for directory and Win32

The filepath bump to 1.4.200.1 introduces a deprecation warning.

See https://gitlab.haskell.org/ghc/ghc/-/issues/24240
    https://github.com/haskell/filepath/pull/206

- - - - -
7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00
Zap OccInfo on case binders during StgCse #14895 #24233

StgCse can revive dead binders:

  case foo of dead { Foo x y -> Foo x y; ... }
  ===>
  case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead

So we must zap occurrence information on case binders.

Fix #14895 and #24233

- - - - -
57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00
Cpr: Turn an assertion into a check to deal with some dead code (#23862)

See the new `Note [Dead code may contain type confusions]`.

Fixes #23862.

- - - - -
c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00
testsuite: add test for #23944

- - - - -
6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00
driver: Only run a dynamic-too pipeline if object files are going to be generated

Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state
when writing simple interface" when dynamic-too is enabled

We could remove the panic and just write the interface even if the state is `DT_Dyn`,
but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already
designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled.

Fixes #23944.

- - - - -
28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00
Improve duplicate elimination in SpecConstr

This partially fixes #24229.

See the new Note [Pattern duplicate elimination] in SpecConstr

- - - - -
fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00
Make SpecConstr deal with casts better

This patch does two things, to fix #23209:

* It improves SpecConstr so that it no longer quantifies over
  coercion variables.  See Note [SpecConstr and casts]

* It improves the rule matcher to deal nicely with the case where
  the rule does not quantify over coercion variables, but the the
  template has a cast in it.  See Note [Casts in the template]

- - - - -
8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00
driver: Don't lose track of nodes when we fail to resolve cycles

The nodes that take part in a cycle should include both hs-boot and hs files,
but when we fail to resolve a cycle, we were only counting the nodes from the
graph without boot files.

Fixes #24196

- - - - -
c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00
testsuite: Skip MultiLayerModulesTH_OneShot on darwin

See #24177

- - - - -
fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00
docs(Data.Char):Add more detailed descriptions for some functions

Related changed function's docs:

-GHC.Unicode.isAlpha
-GHC.Unicode.isPrint
-GHC.Unicode.isAlphaNum

Add more details for what the function will return.

Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com>

- - - - -
ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00
Fix float parsing in GHC Cmm Lexer

Add test case for bug #24224

- - - - -
d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00
Take care when simplifying unfoldings

This MR fixes a very subtle bug exposed by #24242.

See Note [Environment for simplLetUnfolding].

I also updated a bunch of Notes on shadowing

- - - - -
03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in FloatIn

Relevant to #3458

- - - - -
50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in SpecConstr

- - - - -
9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Add test for #22238

- - - - -
d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00
Make forall a keyword (#23719)

Before this change, GHC used to accept `forall` as a term-level
identifier:

	-- from constraints-0.13
	forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p)
	forall d = ...

Now it is a parse error.

The -Wforall-identifier warning has served its purpose and is now
a deprecated no-op.

- - - - -
58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00
driver: Ensure we actually clear the interactive context before reloading

Previously we called discardIC, but immediately after set the session
back to an old HscEnv that still contained the IC

Partially addresses #24107
Fixes #23405

- - - - -
8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00
driver: Ensure we force the lookup of old build artifacts before returning the build plan

This prevents us from retaining all previous build artifacts in memory until a
recompile finishes, instead only retaining the exact artifacts we need.

Fixes #24118

- - - - -
105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00
testsuite: add test for #24118 and #24107

MultiLayerModulesDefsGhci was not able to catch the leak because it uses
:l which discards the previous environment.

Using :r catches both of these leaks

- - - - -
e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00
compiler: Add some strictness annotations to ImportSpec and related constructors
This prevents us from retaining entire HscEnvs.

Force these ImportSpecs when forcing the GlobalRdrEltX

Adds an NFData instance for Bag

Fixes #24107

- - - - -
522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00
compiler: Force IfGlobalRdrEnv in NFData instance.

- - - - -
188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00
LinearTypes => MonoLocalBinds

- - - - -
8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00
Linear let and where bindings

For expediency, the initial implementation of linear types in GHC
made it so that let and where binders would always be considered
unrestricted. This was rather unpleasant, and probably a big obstacle
to adoption. At any rate, this was not how the proposal was designed.

This patch fixes this infelicity. It was surprisingly difficult to
build, which explains, in part, why it took so long to materialise.

As of this patch, let or where bindings marked with %1 will be
linear (respectively %p for an arbitrary multiplicity p). Unmarked let
will infer their multiplicity.

Here is a prototypical example of program that used to be rejected and
is accepted with this patch:

```haskell
f :: A %1 -> B
g :: B %1 -> C

h :: A %1 -> C
h x = g y
  where
    y = f x
```

Exceptions:
- Recursive let are unrestricted, as there isn't a clear semantics of
  what a linear recursive binding would be.
- Destructive lets with lazy bindings are unrestricted, as their
  desugaring isn't linear (see also #23461).
- (Strict) destructive lets with inferred polymorphic type are
  unrestricted. Because the desugaring isn't linear (See #18461
  down-thread).

Closes #18461 and #18739

Co-authored-by: @jackohughes

- - - - -
effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00
Introduce `dataToTagSmall#` primop (closes #21710)

...and use it to generate slightly better code when dataToTag#
is used at a "small data type" where there is no need to mess
with "is_too_big_tag" or potentially look at an info table.

Metric Decrease:
    T18304

- - - - -
35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00
Fix formatting of Note [alg-alt heap check]

- - - - -
7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00
Allow untyped brackets in typed splices and vice versa.

Resolves #24190

Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27),
and while it does catch some mismatches, the type-checker will catch
them too. OTOH, it prevents writing completely reasonable programs.

- - - - -
a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00
Drop hard Xcode dependency

XCODE_VERSION calls out to `xcodebuild`, which is only available
when having `Xcode` installed. The CommandLineTools are not
sufficient. To install Xcode, you must have an apple id to download
the Xcode.xip from apple.

We do not use xcodebuild anywhere in our build explicilty. At best
it appears to be a proxy for checking the linker or the compiler.
These should rather be done with
```
xcrun ld -version
```
or similar, and not by proxy through Xcode. The CLR should be
sufficient for building software on macOS.

- - - - -
1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00
docs: update information on RequiredTypeArguments

Update the User's Guide and Release Notes to account for the recent
progress in the implementation of RequiredTypeArguments.

- - - - -
d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Fix off-by-one in assertion

Previously we failed to account for the NULL terminator `postString`
asserted that there is enough room in the buffer for the string.

- - - - -
a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Honor result of ensureRoomForVariableEvent is

Previously we would keep plugging along, even if isn't enough room for
the event.

- - - - -
0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Avoid truncating event sizes

Previously ensureRoomForVariableEvent would truncate the desired size to
16-bits, resulting in #24197.

Fixes #24197.

- - - - -
64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00
Remove the "Derived Constraint" argument of TcPluginSolver, docs

- - - - -
fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00
EPA: Move tokens into GhcPs extension fields (#23447)

Summary of changes

* Remove Language.Haskell.Syntax.Concrete
* Move all tokens into GhcPs extension fields (LHsToken -> EpToken)
* Create new TTG extension fields as needed
* Drop the MultAnn wrapper

Updates the haddock submodule.

Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com>

- - - - -
8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00
testsuite: use copy_files in T23405

This prevents the tree from being dirtied when the file is modified.

- - - - -
38d2861d by Apoorv Ingle at 2023-12-13T16:56:12-06:00
Expand `do` blocks right before typechecking using the `HsExpansion` philosophy.

- A step towards killing `tcSyntaxOp`

- Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206

- Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail

- Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer

- New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`:
    1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
    2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
- Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`

- `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
  This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`

- Ensures warnings such as
  1. Pattern mach checks
  2. Failable patterns
  3. non-() return in body statements are preserved

- Expansions inside Template haskell also work without issues.

- Kill `HsMatchCtxt` in favor of `TcMatchAltChecker`
- Make records Expand and not desugar before typechecking.

- Testcases:
  * T18324 T20020 T23147 T22788 T15598 T22086
  * T23147b (error message check),
  * DoubleMatch (match inside a match for pmc check)
  * pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
  * Simple-rec (rec statements inside do statment)
  * T22788 (code snippet from #22788)
  * DoExpanion1 (Error messages for body statments)
  * DoExpansion2 (Error messages for bind statements)
  * DoExpansion3 (Error messages for let statements)

- - - - -
3d3affa3 by Apoorv Ingle at 2023-12-13T16:56:18-06:00
- Renaming `GHC.Types.Basic.{Origin -> MatchOrigin}`

- - - - -
c0aa4738 by Apoorv Ingle at 2023-12-13T16:56:18-06:00
- hpc ticks, Do not count pattern match failures, update hpc tests

- - - - -


30 changed files:

- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/CmmToLlvm/Data.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Data/Bag.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05bcf82551f360249839517a804970e0635718b3...c0aa47388a33928fc2fea7926327d31c80303e15

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05bcf82551f360249839517a804970e0635718b3...c0aa47388a33928fc2fea7926327d31c80303e15
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/20231213/8b14700e/attachment-0001.html>


More information about the ghc-commits mailing list