| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
| |
Minor renaming: since 1ed0409010afeaa318676e351b833aea659bf93a rules get
an InScopeEnv arg (containing an IdUnfoldingFun) instead of an
IdUnfoldingFun directly, hence I've renamed the parameter from "id_unf"
to "env" for clarity.
|
| |
|
|
|
|
|
|
| |
Apparently we need some padding as well.
Fixes #20137
|
|
|
|
|
|
|
|
|
|
|
| |
PPC NCG: Implement CAS inline for 32 and 64 bit
testsuite: Add tests for smaller atomic CAS
X86 NCG: Catch calls to CAS C fallback
Primops: Add atomicCasWord[8|16|32|64]Addr#
Add tests for atomicCasWord[8|16|32|64]Addr#
Add changelog entry for new primops
X86 NCG: Fix MO-Cmpxchg W64 on 32-bit arch
ghc-prim: 64-bit CAS C fallback on all archs
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Noticed build failures like
```
ghc-stage1: panic! (the 'impossible' happened)
GHC version 9.3.20210721:
pprCallishMachOp_for_C: MO_x64_Ne not supported!
```
on `--tagget=hppa2.0-unknown-linux-gnu`.
The change does not fix all 32-bit unreg target problems,
but at least allows linking final ghc binaries.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
|
|
|
|
|
| |
Previously `GHC.Types.Id.Make.newLocal` would name all locals `dt`,
making it unnecessarily difficult to determine their origin.
Noticed while looking at #19557.
|
|
|
|
|
|
|
|
| |
Running the test suite with asserts enabled is somewhat tricky at the
moment as running it with a GHC compiled the DEBUG way has some hundred
failures from the start. These seem to be unrelated to assertions
though. So this provides a toggle to make it easier to debug failing
assertions using the test suite.
|
|
|
|
|
| |
On big-endian systems a narrow after a load cannot be replaced with
a narrow load.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order:
* Introduce the `PsErrUnknownOptionsPragma` diagnostic message
This commit changes the diagnostic emitted inside
`GHC.Parser.Header.checkProcessArgsResult` from an (erroneous) and
unstructured `DriverUnknownMessage` to a `PsErrUnknownOPtionsPragma`,
i.e. a new data constructor of a `PsHeaderMessage`.
* Add the `DriverUserDefinedRuleIgnored` diagnostic message
* Add `DriverUserDefinedRuleIgnored` data constructor
This commit adds (and use) a new data constructor to the `DriverMessage`
type, replacing a `DriverUnknownMessage` with it.
* Add and use `DriverCannotLoadInterfaceFile` constructor
This commit introduces the DriverCannotLoadInterfaceFile constructor for
the `DriverMessage` type and it uses it to replace and occurrence of
`DriverUnknownMessage`.
* Add and use the `DriverInferredSafeImport` constructor
This commit adds a new `DriverInferredSafeImport` constructor to the
`DriverMessage` type, and uses it in `GHC.Driver.Main` to replace one
occurrence of `DriverUnknownMessage`.
* Add and use `DriverCannotImportUnsafeModule` constructor
This commit adds the `DriverCannotImportUnsafeModule` constructor
to the `DriverMessage` type, and later using it to replace one usage of
`DriverUnknownMessage` in the `GHC.Driver.Main` module.
* Add and use `DriverMissingSafeHaskellMode` constructor
* Add and use `DriverPackageNotTrusted` constructor
* Introduce and use `DriverInferredSafeModule` constructor
* Add and use `DriverMarkedTrustworthyButInferredSafe` constructor
* Add and use `DriverCannotImportFromUntrustedPackage`
|
|
|
|
| |
Remove trailing spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the call to prepareBinding (in simplLazyBind), I had failed to
extend the in-scope set with the binders from body_floats1. As as
result, when eta-expanding deep inside prepareBinding we made up
an eta-binder that shadowed a variable free in body1. Yikes.
It's hard to trigger this bug. It showed up when I was working
on !5658, and I started using the in-scope set for eta-expansion,
rather than taking free variables afresh. But even then it only
showed up when compiling a module in Haddock
utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
Sadly Haddock is compiled without Core Lint, so we ultimately got
a seg-fault. Lint nailed it fast once I realised that it was off.
There is some other tiny refactoring in this patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Eta expansion was taking ages on T18223. This patch
* Aggressively squash reflexive casts in etaInfoApp.
See Note [Check for reflexive casts in eta expansion]
These changes decreased compile-time allocation by 80%!
* Passes the Simplifier's in-scope set to etaExpandAT, so we
don't need to recompute it. (This alone saved 10% of compile
time.)
Annoyingly several functions in the Simplifier (namely
makeTrivialBinding and friends) need to get SimplEnv, rather
than SimplMode, but that is no big deal.
Lots of small changes in compile-time allocation, less than 1%
and in both directions. A couple of bigger changes, including
the rather delicate T18223
T12425(optasm) ghc/alloc 98448216.0 97121224.0 -1.3% GOOD
T18223(normal) ghc/alloc 5454689676.0 1138238008.0 -79.1% GOOD
Metric Decrease:
T12425
T18223
|
|
|
|
|
|
|
|
|
|
|
| |
Previously the eta-expansion would return lambdas interspersed with
casts; now the cast is just pushed to the outside: #20153.
This actually simplifies the code.
I also improved mkNthCo to account for SymCo, so that
mkNthCo n (SymCo (TyConAppCo tc cos))
would work well.
|
|
|
|
|
|
|
|
|
|
|
|
| |
When eyeballing calls of GHC.Core.Opt.Simplify.Monad.traceSmpl,
I saw that lots of cold-path logging code was getting inlined
into the main Simplifier module.
So in GHC.Utils.Logger I added a NOINLINE on logDumpFile'.
For logging, the "hot" path, up to and including the conditional,
should be inlined, but after that we should inline as little as
possible, to reduce code size in the caller.
|
|
|
|
|
|
|
|
|
|
|
|
| |
occAnalArgs and occAnalApp are very heavily used functions, so it pays
to make them rather strict: fewer thunks constructed. All these
thunks are ultimately evaluated anyway.
This patch gives a welcome reduction compile time allocation of around
0.5% across the board. For T9961 it's a 2.2% reduction.
Metric Decrease:
T9961
|
|
|
|
| |
No change in behaviour
|
|
|
|
|
|
| |
substExpr warns if it finds a LocalId that isn't in the in-scope set.
This patch extends the in-scope set to silence the warnings. (It has
no effect on behaviour.)
|
|
|
|
|
|
|
|
|
|
|
| |
See Note [Use occ-anald RHS in postInlineUnconditionally].
This explains how to eliminate an extra round of simplification,
which can happen if postInlineUnconditionally uses a RHS
that is no occurrence-analysed.
This opportunity has been there for ages; I discovered it
when looking at a compile-time perf regression that happened
because the opportunity wasn't exploited.
|
| |
|
|
|
|
|
| |
I noticed that smallEnoughToInline said "no" to UnfWhen guidance,
which seems quite wrong -- those functions are particularly small.
|
| |
|
|
|
|
|
|
|
|
|
| |
This is reverting a change introduced in linear types commit 40fa237e1da.
Previously, we had to abort early, but thanks to later changes,
this is no longer needed.
There's no test, but the behavior should be better.
The plan is to remove levity polymorphism checking in the desugarer anyway.
|
|
|
|
| |
The comment about 'parError' was obsolete.
|
|
|
|
| |
Remains of the dotnet FFI, see a7d8f43718 and 1fede4bc95
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch addresses #20143, which wants to discard unused calls to
unsafeEqualityProof.
There are two parts:
* In exprOkForSideEffects, we want to know that unsafeEqualityProof
indeed terminates, without any exceptions etc
* But we can only discard the case if we know that the coercion
variable is not used, which means we have to gather accurate
occurrence info for CoVars. Previously OccurAnal only did a half
hearted job of doing so; this patch finishes the job.
See Note [Gather occurrences of coercion variables] in OccurAnal.
Because the occurrence analyser does more work, there is a small
compile-time cost but it's pretty small. The compiler perf tests
are usually 0.0% but occasionally up to 0.3% increase. I'm just
going to accept this -- gathering accurate occurrence information
really seems like the Right Thing to do.
There is an increase in `compile_time/peak_megabytes_allocated`, for
T11545, or around 14%; but I can't reproduce it on my machine (it's
the same before and after), and the peak-usage stats are vulnerable to
when exactly the GC takes place, so I'm just going to accept it.
Metric Increase:
T11545
|
|
|
|
|
|
|
| |
This patch fixes #20103, by treating HasCallStack constraints as
cheap when eta-expanding.
See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As #19918 pointed out, the CallStack mechanism didn't work well with
RebindableSyntax.
This patch improves matters. See GHC.Tc.Types.Evidence
Note [Overview of implicit CallStacks]
* New predicate isPushCallStackOrigin distinguishes when a CallStack
constraint should be solved "directly" or by pushing an item on the
stack.
* The constructor EvCsPushCall now has a FastString, which can
describe not only a function call site, but also things like
"the literal 42" or "an if-then-else expression".
* I also fixed #20126 thus:
exprCtOrigin (HsIf {}) = IfThenElseOrigin
(Previously it was "can't happen".)
|
|
|
|
|
| |
Here we introduce a very thin abstraction for allocating, filling, and
freezing executable pages to replace allocateExec.
|
|
|
|
|
|
|
|
| |
Previously the -Wcompat-unqualified-imports warning would first check
whether an import is of a covered module, incurring an map lookup,
before checking the simple boolean predicate of whether it is qualified.
This is more expensive than strictly necessary (although at the moment
the warning is unused, so this will make little difference).
|
| |
|
|
|
|
|
|
|
|
| |
Previously the `MO_S_Quot` constant folding rule would incorrectly pass
the shift amount of the same width as the shifted value. However, the
machop's type expects the shift amount to be a Word.
Fixes #20142.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was noticed in #20134 that each simplifier iteration used an
increasing amount of memory and that a certain portion of memory was not
released until the simplfier had completely finished.
I profiled the program using `-hi` profiling and observed that there was
a thunk arising in the computation of `ug_boring_ok`. On each iteration
`ug_boring_ok` would be updated, but not forced, which would leave a
thunk in the shape of
ug_boring_ok = inlineBoringOk expr0 || inlineBoringOk expr2 || inlineBoringOk expr3 || ...
which would retain all previous `expr` until `ug_boring_ok` was forced
or discarded.
Forcing this accumulator eagerly results in a flat profile over multiple
simplifier runs.
This reduces the maximum residency when compiling the test in #20134
from 2GB to 1.3G.
-------------------------
Metric Decrease:
T11545
-------------------------
|
|
|
|
|
|
|
|
|
|
|
|
| |
Methodology: Create a -hi profile and then search for TcGblEnv
then use ghc-debug to work out why they are being retained and remove
the reason.
Retaining TcGblEnv is dangerous because it contains pointers to things
such as a TypeEnv which is updated throughout compilation. I found two
places which were retaining a TcGblEnv unecessarily.
Also fix a few places where an OccName was retaining an Id.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #9192 and #17126
updates containers submodule
1. Changes the type of the primop `reallyUnsafePtrEquality#` to the most
general version possible (heterogeneous as well as levity-polymorphic):
> reallyUnsafePtrEquality#
> :: forall {l :: Levity} {k :: Levity}
> (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k))
> . a -> b -> Int#
2. Adds a new internal module, `GHC.Ext.PtrEq`, which contains pointer
equality operations that are now subsumed by `reallyUnsafePtrEquality#`.
These functions are then re-exported by `GHC.Exts` (so that no function
goes missing from the export list of `GHC.Exts`, which is user-facing).
More specifically, `GHC.Ext.PtrEq` defines:
- A new function:
* reallyUnsafePtrEquality :: forall (a :: Type). a -> a -> Int#
- Library definitions of ex-primops:
* `sameMutableArray#`
* `sameSmallMutableArray`
* `sameMutableByteArray#`
* `sameMutableArrayArray#`
* `sameMutVar#`
* `sameTVar#`
* `sameMVar#`
* `sameIOPort#`
* `eqStableName#`
- New functions for comparing non-mutable arrays:
* `sameArray#`
* `sameSmallArray#`
* `sameByteArray#`
* `sameArrayArray#`
These were requested in #9192.
Generally speaking, existing libraries that
use `reallyUnsafePtrEquality#` will continue to work with the new,
levity-polymorphic version. But not all!
Some (`containers`, `unordered-containers`, `dependent-map`) contain
the following:
> unsafeCoerce# reallyUnsafePtrEquality# a b
If we make `reallyUnsafePtrEquality#` levity-polymorphic, this code
fails the current GHC representation-polymorphism checks.
We agreed that the right solution here is to modify the library;
in this case by deleting the call to `unsafeCoerce#`,
since `reallyUnsafePtrEquality#` is now type-heterogeneous too.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch enhances OccurAnal perf by using a dedicated WithUsageDetails
datatype instead of a tuple (similarly to what has been done in
demand-analysis) with strict fields.
OccEnv is also passed strictly with more strict fields as it improves
results even more.
T9198 flukes isn't reproducible locally (cf
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5667#note_364358)
Metric Decrease:
ManyConstructors
T10421
T12150
T12425
T12707
T13056
T13253
T13253-spj
T15164
T16577
T18282
T18698a
T18698b
T1969
T4801
T5642
T9020
T9233
T9630
T9675
T9961
WWRec
T12227
T13035
T18304
T6048
T12234
T783
T20049
Metric Increase:
T9198
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The issue was the renderer for x86 addressing modes assumes native size
registers, but we were passing in a possibly-smaller index in
conjunction with a native-sized base pointer.
The easist thing to do is just extend the register first.
I also changed the other NGC backends implementing jump tables
accordingly. On one hand, I think PowerPC and Sparc don't have the small
sub-registers anyways so there is less to worry about. On the other
hand, to the extent that's true the zero extension can become a no-op.
I should give credit where it's due: @hsyl20 really did all the work for
me in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_355874,
but I was daft and missed the "Oops" and so ended up spending a silly
amount of time putting it all back together myself.
The unregisterised backend change is a bit different, because here we
are translating the actual case not a jump table, and the fix is to
handle right-sized literals not addressing modes. But it makes sense to
include here too because it's the same change in the subsequent commit
that exposes both bugs.
|
|
|
|
| |
Fixes #19373
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit refactors the SuggestExtension type constructor of the
GhcHint to be more powerful and flexible. In particular, we can now
embed extra user information (essentially "sugar") to help clarifying
the suggestion. This makes the following possible:
Suggested fix: Perhaps you intended to use GADTs
or a similar language extension to enable syntax: data T where
We can still give to IDEs and tools a `LangExt.Extension` they can use,
but in the pretty-printed message we can tell the user a bit more on why
such extension is needed.
On top of that, we now have the ability to express conjuctions and
disjunctons, for those cases where GHC suggests to enable "X or Y" and
for the cases where we need "X and Y".
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The GHC.Prim module is quite special as there is no interface file,
therefore it doesn't appear in ms_textual_imports, but the ghc-prim
package does appear in the direct package dependencies. This confused
the recompilation checking which couldn't find any modules from ghc-prim
and concluded that the package was no longer a dependency.
The fix is to keep track of whether GHC.Prim is imported separately in
the relevant places.
Fixes #20084
|
|
|
|
|
|
|
|
|
| |
This is small step towards #19877. We want to make the Loader/Linker
interface more abstract to be easily reused (i.e. don't pass it
DynFlags) but the system linker uses TmpFs which required a DynFlags
value to get its temp directory. We explicitly pass the temp directory
now. Similarly TmpFs was consulting the DynFlags to decide whether to
clean or: this is now done by the caller in the driver code.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ticket #20125 showed that the Simplifier could sometimes duplicate a
constructor binding. CSE would often eliminate it later, but doing it
in the first place was utterly wrong.
See Note [Do not duplicate constructor applications] in Simplify.hs
I also added a short-cut to Simplify.simplNonRecX for the case
when the RHS is trivial. I don't think this will change anything,
just make the compiler run a tiny bit faster.
|
|
|
|
|
|
|
|
|
|
| |
This commit renames the `RecordPuns` type constructor inside
`GHC.LanguageExtensions.Type.hs` to `NamedFieldPuns`.
The rationale is that the `RecordPuns` language extension was deprecated
a long time ago, but it was still present in the AST, introducing an
annoying mismatch between what GHC suggested (i.e. "use NamedFieldPuns")
and what that translated into in terms of Haskell types.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous code assumed properties of the CoreToStg translation,
namely that a core let expression which be translated to a single
non-recursive top-level STG binding. This assumption was false, as
evidenced by #20060.
The consequence of this was the need to modify the call sites of
`myCoreToStgExpr`, the main one being in hscCompileCoreExpr', which
the meant we had to use byteCodeGen instead of stgExprToBCOs to convert
the returned value to bytecode.
I removed the `stgExprToBCOs` function as it is no longer
used in the compiler.
There is still some partiallity with this patch (the lookup in
hscCompileCoreExpr') but this should be more robust that before.
Fixes #20060
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch, provoked by regressions in the text package
(#19557), improves sharing of join points. This also fixes
the terrible behaviour in #20049.
See Note [Duplicating join points] in GHC.Core.Opt.Simplify.
* In the StrictArg case of mkDupableContWithDmds, don't
use Plan A for data constructors
* In postInlineUnconditionally, don't inline JoinIds
Avoids inlining join $j x = Just x
in case blah of
A -> $j x1
B -> $j x2
C -> $j x3
* In mkDupableStrictBind and mkDupableStrictAlt, create
join points (much) more often: exprIsTrivial rather than
exprIsDupable. This may be much, but we'll see.
Metric Decrease:
T12545
T13253-spj
T13719
T18140
T18282
T18304
T18698a
T18698b
Metric Increase:
T16577
T18923
T9961
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Word64#/Int64# are only used on 32-bit architectures. Before this patch,
operations on these types were directly using the FFI. Now we use real
primops that are then lowered into ccalls.
The advantage of doing this is that we can now perform constant folding on
Word64#/Int64# (#19024).
Most of this work was done by John Ericson in !3658. However this patch
doesn't go as far as e.g. changing Word64 to always be using Word64#.
Noticeable performance improvements
T9203(normal) run/alloc 89870808.0 66662456.0 -25.8% GOOD
haddock.Cabal(normal) run/alloc 14215777340.8 12780374172.0 -10.1% GOOD
haddock.base(normal) run/alloc 15420020877.6 13643834480.0 -11.5% GOOD
Metric Decrease:
T9203
haddock.Cabal
haddock.base
|