summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Add `-dsuppress-core-sizes` flag (#20342)Sylvain Henry2021-09-284-8/+14
| | | | | This flag is used to remove the output of core stats per binding in Core dumps.
* driver: Fix Ctrl-C handling with -j1Matthew Pickering2021-09-281-27/+35
| | | | | | | | | Even in -j1 we now fork all the work into it's own thread so that Ctrl-C exceptions are thrown on the main thread, which is blocked waiting for the work thread to finish. The default exception handler then picks up Ctrl-C exception and the dangling thread is killed. Fixes #20292
* Remove NoGhcTc usage from HsMatchContextArtyom Kuznetsov2021-09-2812-38/+69
| | | | | | NoGhcTc is removed from HsMatchContext. As a result of this, HsMatchContext GhcTc is now a valid type that has Id in it, instead of Name and tcMatchesFun now takes Id instead of Name.
* Constant-folding for timesInt2# (#20374)Sylvain Henry2021-09-231-0/+33
|
* Use Info Table Provenances to decode cloned stack (#18163)Sven Tennie2021-09-2314-81/+356
| | | | | | | | | | | | | | | | Emit an Info Table Provenance Entry (IPE) for every stack represeted info table if -finfo-table-map is turned on. To decode a cloned stack, lookupIPE() is used. It provides a mapping between info tables and their source location. Please see these notes for details: - [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)] - [Mapping Info Tables to Source Positions] Metric Increase: T12545
* Introduce stack snapshotting / cloning (#18741)Sven Tennie2021-09-234-11/+46
| | | | | | | | | | | | | | Add `StackSnapshot#` primitive type that represents a cloned stack (StgStack). The cloning interface consists of two functions, that clone either the treads own stack (cloneMyStack) or another threads stack (cloneThreadStack). The stack snapshot is offline/cold, i.e. it isn't evaluated any further. This is useful for analyses as it prevents concurrent modifications. For technical details, please see Note [Stack Cloning]. Co-authored-by: Ben Gamari <bgamari.foss@gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
* Typo [skip ci]wip/typo-cgMatthew Pickering2021-09-231-1/+1
|
* Remove unused, undocumented debug/dump flag `-ddump-vt-trace`. See 20403.Benjamin Maurer2021-09-222-4/+0
|
* Link with libm dynamically (#19877)Sylvain Henry2021-09-224-10/+16
| | | | The compiler should be independent of the target.
* Convert Diagnostics in GHC.Tc.Gen.* (Part 2)Aaron Allen2021-09-224-114/+330
| | | | | | Converts diagnostics in: (#20116) - GHC.Tc.Gen.Default - GHC.Tc.Gen.Export
* deriving: Always use module prefix in dataTypeNameMatthew Pickering2021-09-181-1/+6
| | | | | | | | | | | This fixes a long standard bug where the module prefix was omitted from the data type name supplied by Data.Typeable instances. Instead of reusing the Outputable instance for TyCon, we now take matters into our own hands and explicitly print the module followed by the type constructor name. Fixes #20371
* CoreUtils: Make exprIsHNF return True for unlifted variables (#20140)Sebastian Graf2021-09-181-0/+2
| | | | | | Clearly, evaluating an unlifted variable will never perform any work. Fixes #20140.
* WorkWrap: Update Note [Wrapper activation] (#15056)Sebastian Graf2021-09-181-23/+28
| | | | | | | | | | | The last point of the Conclusion was wrong; we inline functions without pragmas after the initial phase. It also appears that #15056 was fixed, as there already is a test T15056 which properly does foldr/build fusion for the reproducer. I made sure that T15056's `foo` is just large enough for WW to happen (which it wasn't), but for the worker to be small enough to inline into `blam`. Fixes #15056.
* Constant folding for ctz/clz/popCnt (#20376)Sylvain Henry2021-09-171-0/+45
|
* Use an ADT for RecompReasonSylvain Henry2021-09-173-54/+113
|
* Refactor module dependencies codeSylvain Henry2021-09-1711-192/+212
| | | | | | * moved deps related code into GHC.Unit.Module.Deps * refactored Deps module to not export Dependencies constructor to help maintaining invariants
* Fix annoying warning about Data.List unqualified importSylvain Henry2021-09-171-1/+1
|
* Code Gen: Rewrite shortcutWeightMap more efficientlyMatthew Pickering2021-09-171-33/+53
| | | | | | | | | | | | This function was one of the main sources of allocation in a ticky profile due to how it repeatedly deleted nodes from a large map. Now firstly the cuts are normalised, so that chains of cuts are elimated before any rewrites are applied. Then the CFG is traversed and reconstructed once whilst applying the necessary rewrites to remove shortcutted edges (based on the normalised cuts). Ticket: #19471
* Code Gen: Use more efficient block merging algorithmMatthew Pickering2021-09-173-27/+109
| | | | | | | | | | | | | | | | | | The previous algorithm scaled poorly when there was a large number of blocks and edges. The algorithm links together block chains which have edges between them in the CFG. The new algorithm uses a union find data structure in order to efficiently merge together blocks and calculate which block chain each block id belonds to. I copied the UnionFind data structure which already existed in Cabal into the GHC library rathert than reimplement it myself. This change results in a very significant reduction in allocations when compiling the mmark package. Ticket: #19471
* Code Gen: Optimise successors calculation in loop calculationMatthew Pickering2021-09-171-5/+4
| | | | | | | | | | Before this change, the whole map would be traversed in order to delete a node from the graph before calculating successors. This is quite inefficient if the CFG is big, as was the case in the mmark package. A more efficient alternative is to leave the CFG untouched and then just delete the node once after the lookups have been performed. Ticket: #19471
* Code Gen: Replace another lazy fmap with strict mapMapMatthew Pickering2021-09-171-1/+1
|
* Code Gen: Use strict map rather than lazy map in loop analysisMatthew Pickering2021-09-171-1/+3
| | | | | | | | | | | We were ending up with a big 1GB thunk spike as the `fmap` operation did not force the key values promptly. This fixes the high maximum memory consumption when compiling the mmark package. Compilation is still slow and allocates a lot more than previous releases. Related to #19471
* compiler: Ensure that all CoreTodos have SCCsBen Gamari2021-09-172-3/+5
| | | | | | In #20365 we noticed that a significant amount of time is spend in the Core2Core cost-center, suggesting that some passes are likely missing SCC pragmas. Try to fix this.
* driver: Clean up temporary files after a module has been compiledMatthew Pickering2021-09-171-2/+8
| | | | | | | | | The refactoring accidently removed these calls to eagerly remove temporary files after a module has been compiled. This caused some issues with tmpdirs getting filled up on my system when the project had a large number of modules (for example, Agda) Fixes #20293
* Stop leaking <defunct> llc processesMatthew Pickering2021-09-171-1/+2
| | | | | | | | | | We needed to wait for the process to exit in the clean-up script as otherwise the `llc` process will not be killed until compilation finishes. This leads to running out of process spaces on some OSs. Thanks to Edsko de Vries for suggesting this fix. Fixes #20305
* Ensure .dyn_hi doesn't overwrite .hiZiyang Liu2021-09-173-9/+16
| | | | | | | | This commit fixes the following bug: when `outputHi` is set, and both `.dyn_hi` and `.hi` are needed, both would be written to `outputHi`, causing `.dyn_hi` to overwrite `.hi`. This causes subsequent `readIface` to fail - "mismatched interface file profile tag (wanted "", got "dyn")" - triggering unnecessary rebuild.
* driver: -M allow omitting the -dep-suffix (means empty) (fix #15483)Artem Pelenitsyn2021-09-171-4/+6
|
* EPA: correctly capture comments between 'where' and bindsAlan Zimmerman2021-09-178-32/+45
| | | | | | | | | | | | In the following foo = x where -- do stuff doStuff = do stuff The "-- do stuff" comment is captured in the HsValBinds. Closes #20297
* Emit warning if bang is applied to unlifted typesTito Sacchi2021-09-175-3/+32
| | | | | | | | | | | | | | | | GHC will trigger a warning similar to the following when a strictness flag is applied to an unlifted type (primitive or defined with the Unlifted* extensions) in the definition of a data constructor. Test.hs:7:13: warning: [-Wredundant-strictness-flags] • Strictness flag has no effect on unlifted type ‘Int#’ • In the definition of data constructor ‘TestCon’ In the data type declaration for ‘Test’ | 7 | data Test = TestCon !Int# | ^^^^^^^^^^^^^ Fixes #20187
* Improve pretty-printer defaulting logic (#19361)Krzysztof Gogolewski2021-09-173-34/+50
| | | | | | When determining whether to default a RuntimeRep or Multiplicity variable, use isMetaTyVar to distinguish between metavariables (which can be hidden) and skolems (which cannot).
* Improve error messages involving operators from Data.Type.OrdChristiaan Baaij2021-09-171-6/+7
| | | | Fixes #20009
* Fix #20203 improve constant fold for `and`/`or`CarrieMY2021-09-131-18/+120
| | | | | | | | | | | | | | | This patch follows the rules specified in note [Constant folding through nested expressions]. Modifications are summarized below. - Added andFoldingRules, orFoldingRules to primOpRules under those xxxxAndOp, xxxxOrOp - Refactored some helper functions - Modify data NumOps to include two fields: numAnd and numOr Resolves: #20203 See also: #19204
* ncg: Kill incorrect unreachable codeBen Gamari2021-09-111-3/+3
| | | | | | As noted in #18183, these cases were previously incorrect and unused. Closes #18183.
* Ensure that zapFragileUnfolding preseves evaluatednessBen Gamari2021-09-111-5/+5
| | | | | As noted in #20324, previously we would drop the fact that an unfolding was evaluated, despite what the documentation claims.
* Canonicalize bignum literalsSylvain Henry2021-09-1114-225/+226
| | | | | | | | | | | | | | | | | | Before this patch Integer and Natural literals were desugared into "real" Core in Core prep. Now we desugar them directly into their final ConApp form in HsToCore. We only keep the double representation for BigNat# (literals larger than a machine Word/Int) which are still desugared in Core prep. Using the final form directly allows case-of-known-constructor to fire for bignum literals, fixing #20245. Slight increase (+2.3) in T4801 which is a pathological case with Integer literals. Metric Increase: T4801 T11545
* Only dump Core stats when requested to do so (#20342)Sylvain Henry2021-09-081-1/+3
|
* EPA: Capture '+' location for NPlusKPatAlan Zimmerman2021-09-085-6/+15
| | | | | | | The location of the plus symbol was being discarded, we now capture it. Closes #20243
* ffi: Don't allow wrapper stub with CApi conventionMatthew Pickering2021-09-083-4/+16
| | | | Fixes #20272
* Let LLVM and C handle > native size arithmeticJohn Ericson2021-09-083-60/+67
| | | | | | NCG needs to call slow FFI functions where we "borrow" the C compiler's implementation, but there is no reason why we need to do that for LLVM, or the unregisterized backend where everything is via C anyways!
* Add and use new constructors to TcRnMessageAlfredo Di Napoli2021-09-0710-121/+329
| | | | | | | | | | | | | This commit adds the following constructors to the TcRnMessage type and uses them to replace sdoc-based diagnostics in some parts of GHC (e.g. TcRnUnknownMessage). It includes: * Add TcRnMonomorphicBindings diagnostic * Convert TcRnUnknownMessage in Tc.Solver.Interact * Add and use the TcRnOrphanInstance constructor to TcRnMessage * Add TcRnFunDepConflict and TcRnDupInstanceDecls constructors to TcRnMessage * Add and use TcRnConflictingFamInstDecls constructor to TcRnMessage * Get rid of TcRnUnknownMessage from GHC.Tc.Instance.Family
* Bignum: refactor conversion rulesSylvain Henry2021-09-071-258/+0
| | | | | | | | * make "passthrough" rules non built-in: they don't need to * enhance note about efficient conversions between numeric types * make integerFromNatural a little more efficient * fix noinline pragma for naturalToWordClamp# (at least with non built-in rules, we get warnings in cases like this)
* GHCi: don't discard plugins on reload (#20335)Sylvain Henry2021-09-061-4/+7
| | | | Fix regression introduced in ecfd0278
* EPA: order of semicolons and comments for top-level decls is wrongAlan Zimmerman2021-09-061-6/+11
| | | | | | | | | | A comment followed by a semicolon at the top level resulted in the preceding comments being attached to the following declaration. Capture the comments as belonging to the declaration preceding the semicolon instead. Closes #20258
* Convert diagnostics in GHC.Tc.Validity to proper TcRnMessage.hainq2021-09-017-229/+536
| | | | | | | | | | | | | | | | | | | | - Add 19 new messages. Update test outputs accordingly. - Pretty print suggest-extensions hints: remove space before interspersed commas. - Refactor Rank's MonoType constructors. Each MonoType constructor should represent a specific case. With the Doc suggestion belonging to the TcRnMessage diagnostics instead. - Move Rank from Validity to its own `GHC.Tc.Types.Rank` module. - Remove the outdated `check_irred_pred` check. - Remove the outdated duplication check in `check_valid_theta`, which was subsumed by `redundant-constraints`. - Add missing test cases for quantified-constraints/T16474 & th/T12387a.
* AArch64 NCG: Emit FABS instructions for fabsFloat# and fabsDouble#ARATA Mizuki2021-08-284-4/+24
| | | | Closes #20275
* Convert IFace Rename Errors (#19927)Aaron Allen2021-08-275-16/+53
| | | | | | Converts uses of TcRnUnknownMessage in GHC.Iface.Rename. Closes #19927
* GHC.Tc.Gen Diagnostics Conversion (Part 1)Aaron Allen2021-08-278-78/+319
| | | | | | | | Converts uses of `TcRnUnknownMessage` in these modules: - compiler/GHC/Tc/Gen/Annotation.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs
* Fix GHC.Core.Subst.substDVarSetSimon Peyton Jones2021-08-261-17/+17
| | | | | | | substDVarSet looked up coercion variables in the wrong environment! The fix is easy. It is still a pretty strange looking function, but the bug is gone. This fixes another manifestation of #20200.
* CallArity: Consider shadowing introduced by case and field bindersSebastian Graf2021-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In #20283, we saw a regression in `simple` due to CallArity for a very subtle reason: It simply didn't handle shadowing of case binders and constructor field binders! The test case T20283 has a very interesting binding `n_X1` that we want to eta-expand and that has a Unique (on GHC HEAD) that is reused by the Simplifier for a case binder: ``` let { n_X1 = ... } in ... let { lvl_s1Ul = ... case x_a1Rg of wild_X1 { __DEFAULT -> f_s1Tx rho_value_awA (GHC.Types.I# wild_X1); 0# -> lvl_s1TN } ... } in letrec { go3_X3 = \ (x_X4 :: GHC.Prim.Int#) (v_a1P9 [OS=OneShot] :: Double) -> let { karg_s1Wu = ... case lvl_s1Ul of { GHC.Types.D# y_a1Qf -> ... } } in case GHC.Prim.==# x_X4 y_a1R7 of { __DEFAULT -> go3_X3 (GHC.Prim.+# x_X4 1#) karg_s1Wu; 1# -> n_X1 karg_s1Wu -- Here we will assume that karg calls n_X1! }; } in go3_X3 0#; ``` Since the Case case of CallArity doesn't delete `X1` from the set of variables it is interested in knowing the usages of, we leak a very boring usage (of the case binder!) into the co-call graph that we mistakenly take for a usage of `n_X1`. We conclude that `lvl_s1Ul` and transitively `karg_s1Wu` call `n_X1` when really they don't. That culminates in the conclusion that `n_X1 karg_s1Wu` calls `n_X1` more than once. Wrong! Fortunately, this bug (which has been there right from CallArity's inception, I suppose) will never lead to a CallArity that is too optimistic. So by fixing this bug, we get strictly more opportunities for CallArity and all of them should be sound to exploit. Fixes #20283.
* Desugarer: Bring existentials in scope when substituting into record GADTsRyan Scott2021-08-251-3/+11
| | | | | | | | | | This fixes an outright bug in which the desugarer did not bring the existentially quantified type variables of a record GADT into `in_subst`'s in-scope set, leading to #20278. It also addresses a minor inefficiency in which `out_subst` was made into a substitution when a simpler `TvSubstEnv` would suffice. Fixes #20278.