summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* WIP: Force stable unfoldings in megaSeqIdInfowip/rwbarton-seq-unfReid Barton2017-04-301-2/+3
|
* Remove unused tidyOccNames and update NoteJoachim Breitner2017-04-301-16/+7
| | | | | | | addressing rwbarton’s concerns in https://phabricator.haskell.org/rGHC18ac80ff729e#66197 Differential Revision: https://phabricator.haskell.org/D3511
* Prefer #if defined to #ifdefBen Gamari2017-04-2821-49/+49
| | | | Our new CPP linter enforces this.
* Enable new warning for fragile/incorrect CPP #if usageErik de Castro Lopo2017-04-281-1/+1
| | | | | | | | | | | | | | | | The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
* Improve code generation for conditionalsSimon Peyton Jones2017-04-285-38/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch in in preparation for the fix to Trac #13397 The code generator has a special case for case tagToEnum (a>#b) of False -> e1 True -> e2 but it was not doing nearly so well on case a>#b of DEFAULT -> e1 1# -> e2 This patch arranges to behave essentially identically in both cases. In due course we can eliminate the special case for tagToEnum#, once we've completed Trac #13397. The changes are: * Make CmmSink swizzle the order of a conditional where necessary; see Note [Improving conditionals] in CmmSink * Hack the general case of StgCmmExpr.cgCase so that it use NoGcInAlts for conditionals. This doesn't seem right, but it's the same choice as the tagToEnum version. Without it, code size increases a lot (more heap checks). There's a loose end here. * Add comments in CmmOpt.cmmMachOpFoldM
* Re-engineer caseRules to add tagToEnum/dataToTagSimon Peyton Jones2017-04-284-136/+295
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See Note [Scrutinee Constant Folding] in SimplUtils * Add cases for tagToEnum and dataToTag. This is the main new bit. It allows the simplifier to remove the pervasive uses of case tagToEnum (a > b) of False -> e1 True -> e2 and replace it by the simpler case a > b of DEFAULT -> e1 1# -> e2 See Note [caseRules for tagToEnum] and Note [caseRules for dataToTag] in PrelRules. * This required some changes to the API of caseRules, and hence to code in SimplUtils. See Note [Scrutinee Constant Folding] in SimplUtils. * Avoid duplication of work in the (unusual) case of case BIG + 3# of b DEFAULT -> e1 6# -> e2 Previously we got case BIG of DEFAULT -> let b = BIG + 3# in e1 3# -> let b = 6# in e2 Now we get case BIG of b# DEFAULT -> let b = b' + 3# in e1 3# -> let b = 6# in e2 * Avoid duplicated code in caseRules A knock-on refactoring: * Move Note [Word/Int underflow/overflow] to Literal, as documentation to accompany mkMachIntWrap etc; and get rid of PrelRuls.intResult' in favour of mkMachIntWrap
* Move dataConTagZ to DataConSimon Peyton Jones2017-04-285-16/+14
| | | | Just a simple refactoring to remove duplication
* nativeGen: Use SSE2 SQRT instructionBen Gamari2017-04-283-7/+15
| | | | | | | | | | Reviewers: austin, dfeuer Subscribers: dfeuer, rwbarton, thomie GHC Trac Issues: #13629 Differential Revision: https://phabricator.haskell.org/D3508
* CSE: Fix cut and paste errorBen Gamari2017-04-281-2/+2
| | | | | | | | | | | | | extendCSRecEnv took the map to be extended from cs_map instead of cs_rec_map. Oops! Test Plan: Validate Reviewers: simonpj, austin Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3510
* Make the tyvars in TH-reified data family instances uniformRyan Scott2017-04-281-5/+8
| | | | | | | | | | | | | | | | | | | | | It turns out we were using two different sets of type variables when reifying data family instances in Template Haskell. We were using the tyvars quantifying over the instance itself for the LHS, but using the tyvars quantifying over the data family instance constructor for the RHS. This commit uses the instance tyvars for both the LHS and the RHS, fixing #13618. Test Plan: make test TEST=T13618 Reviewers: goldfire, austin, bgamari Reviewed By: goldfire, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13618 Differential Revision: https://phabricator.haskell.org/D3505
* Be a bit more eager to inline in a strict contextSimon Peyton Jones2017-04-282-6/+22
| | | | | | | | | | | | | | | | | | | If we see f (g x), and f is strict, we want to be a bit more eager to inline g, because it may well expose an eval (on x perhaps) that can be eliminated or shared. I saw this in nofib boyer2, function RewriteFuns.onewayunify1. It showed up as a consequence of the preceding patch that makes the simplifier do less work (Trac #13379). We had f d (g x) where f was a class-op. Previously we simplified both d and (g x) with a RuleArgCtxt (making g a bit more eager to inline). But now we simplify only d that way, then fire the rule, and only then simplify (g x). Firing the rule produces a strict funciion, so we want to make a strict function encourage inlining a bit.
* Cure exponential behaviour in the simplifierSimon Peyton Jones2017-04-282-58/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch nails a Bad Bug exposed in Trac #13379. Roughly, a deeply-nested application like f (f (f ....) ) ) could make the simplifier go exponential -- without producing an exponential-sized result! The reason was that we - simplified a (big) function argument - then decided to inline the function - then preInilneUnconditionally the argument - and then re-simplified the big argument And if the "big argument" itself had a similar structure things could get very bad. Once I'd understood, it was easy to fix: * See Note Note [Avoiding exponential behaviour] for an overview * The key change is that Simplify.simplLam now as a case for (isSimplified dup). This is what removes the perf bug. * But I also made simplCast more parsimonious about simplifying, avoiding doing so when the coercion is Refl * And similarly I now try to avoid simplifying arguments where possible before applying rules. See Note [Trying rewrite rules] The latter two points tackle common cases, and in those cases make the simplifier take fewer iterations.
* Eta expansion and join pointsSimon Peyton Jones2017-04-281-96/+43
| | | | | | | | | | | | | | | | | | CoreArity.etaExpand tried to deal with eta-expanding expressions with join points. For example let j x = e in \y. b But it is hard to eta-expand this in the "no-crap" way described in Note [No crap in eta-expanded code], becuase it would mean pushing the "apply to y" into the join RHS, and changing its type. And the join might be recursive, and it might have an unfolding. Moreover in elaborate cases like this I don't think we need the no-crap thing. So for now I'm simplifying the code by generating \z. (let j x = e in \y. b) z Let's see if that gives rise to any problems. See Note [Eta expansion for join points]
* Comments onlySimon Peyton Jones2017-04-282-7/+7
|
* Comments onlySimon Peyton Jones2017-04-281-7/+15
|
* A bit more tcTraceSimon Peyton Jones2017-04-281-2/+4
|
* Comments and tiny refactoringSimon Peyton Jones2017-04-282-5/+3
|
* Bump process to 1.6Ben Gamari2017-04-271-1/+1
| | | | Also bumps Cabal submodule due to version bound bump.
* Update Cabal submodule, with necessary wibbles.Edward Z. Yang2017-04-262-3/+2
| | | | | | | | | | | | Test Plan: validate Reviewers: bgamari, austin Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3501
* Document mkWeak#Ben Gamari2017-04-251-0/+5
| | | | | | | | | | | | Reviewers: simonmar, austin Reviewed By: simonmar Subscribers: RyanGlScott, rwbarton, thomie GHC Trac Issues: #10640, #13611 Differential Revision: https://phabricator.haskell.org/D3498
* Only pretty-print binders in closed type families with -fprint-explicit-forallsRyan Scott2017-04-251-1/+5
| | | | | | | | | | | | | | | | | | | Previously, we were unconditionally pretty-printing all type variable binders when pretty-printing closed type families (e.g., in the output of `:info` in GHCi). This threw me for a loop, so let's guard this behind the `-fprint-explicit-foralls` flag. Test Plan: make test TEST=T13420 Reviewers: goldfire, austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13420 Differential Revision: https://phabricator.haskell.org/D3497
* PPC NCG: Implement callish prim opsPeter Trommler2017-04-255-184/+611
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide PowerPC optimised implementations of callish prim ops. MO_?_QuotRem The generic implementation of quotient remainder prim ops uses a division and a remainder operation. There is no remainder on PowerPC and so we need to implement remainder "by hand" which results in a duplication of the divide operation when using the generic code. Avoid this duplication by implementing the prim op in the native code generator. MO_U_Mul2 Use PowerPC's instructions for long multiplication. Addition and subtraction Use PowerPC add/subtract with carry/overflow instructions MO_Clz and MO_Ctz Use PowerPC's CNTLZ instruction and implement count trailing zeros using count leading zeros MO_QuotRem2 Implement an algorithm given by Henry Warren in "Hacker's Delight" using PowerPC divide instruction. TODO: Use long division instructions when available (POWER7 and later). Test Plan: validate on AIX and 32-bit Linux Reviewers: simonmar, erikd, hvr, austin, bgamari Reviewed By: erikd, hvr, bgamari Subscribers: trofi, kgardas, thomie Differential Revision: https://phabricator.haskell.org/D2973
* compiler/cmm/PprC.hs: constify labels in .rodataSergei Trofimovich2017-04-245-35/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider one-line module module B (v) where v = "hello" in -fvia-C mode it generates code like static char gibberish_str[] = "hello"; It resides in data section (precious resource on ia64!). The patch switches genrator to emit: static const char gibberish_str[] = "hello"; Other types if symbols that gained 'const' qualifier are: - info tables (from haskell and CMM) - static reference tables (from haskell and CMM) Cleanups along the way: - fixed info tables defined in .cmm to reside in .rodata - split out closure declaration into 'IC_' / 'EC_' - added label declaration (based on label type) right before each label definition (based on section type) so that C compiler could check if declaration and definition matches at definition site. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ran testsuite on unregisterised x86_64 compiler Reviewers: simonmar, ezyang, austin, bgamari, erikd Reviewed By: bgamari, erikd Subscribers: rwbarton, thomie GHC Trac Issues: #8996 Differential Revision: https://phabricator.haskell.org/D3481
* Export function for use in GHC APIAlan Zimmerman2017-04-231-1/+2
|
* cpp: Use #pragma once instead of #ifndef guardsBen Gamari2017-04-233-16/+3
| | | | | | | | | | | | | | This both says what we mean and silences a bunch of spurious CPP linting warnings. This pragma is supported by all CPP implementations which we support. Reviewers: austin, erikd, simonmar, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3482
* pprDebugCLabel: drop duplicate trailing ')'Sergei Trofimovich2017-04-201-2/+2
| | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Simplify StgCases when all alts refer to the case binderJoachim Breitner2017-04-181-1/+30
| | | | | | as proposed in #13588. Differential Revision: https://phabricator.haskell.org/D3467
* Caret diag.: Avoid decoding whole module if only specific line is neededalexbiehl2017-04-172-15/+52
| | | | | | | | | | | | | | | | | Before we were decoding the whole file to get to the desired line. This patch introduces a fast function which searches a StringBuffer for the desired line so we only need to utf8 decode a little portion. This is especially interesting if we have big modules with lots of warnings. Reviewers: austin, bgamari, Rufflewind, trofi Reviewed By: Rufflewind, trofi Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3440
* Use intersect and minus instead of filterBartosz Nitka2017-04-175-6/+13
| | | | | | | | | | | | | | | These are asymptotically better and convey the intent a bit better. Test Plan: ./validate Reviewers: simonpj, bgamari, austin, goldfire Reviewed By: bgamari Subscribers: rwbarton, thomie, simonmar Differential Revision: https://phabricator.haskell.org/D3455
* Remove redundant flag (-O) registration (fixes #13392)Santiago Munin2017-04-171-1/+0
| | | | | | | | | | | | Reviewers: austin, bgamari, dfeuer Reviewed By: bgamari, dfeuer Subscribers: rwbarton, thomie GHC Trac Issues: #13392 Differential Revision: https://phabricator.haskell.org/D3461
* utils: Lazily decode UTF8 stringsBen Gamari2017-04-173-17/+25
| | | | | | | | | | Reviewers: austin, hvr Subscribers: rwbarton, thomie GHC Trac Issues: #13527 Differential Revision: https://phabricator.haskell.org/D3442
* hs_add_root() RTS API removalSergei Trofimovich2017-04-172-56/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Before ghc-7.2 hs_add_root() had to be used to initialize haskell modules when haskell was called from FFI. commit a52ff7619e8b7d74a9d933d922eeea49f580bca8 ("Change the way module initialisation is done (#3252, #4417)") removed needs for hs_add_root() and made function a no-op. For backward compatibility '__stginit_<module>' symbol was not removed. This change removes no-op hs_add_root() function and unused '__stginit_<module>' symbol from each haskell module. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ./validate Reviewers: simonmar, austin, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3460
* UNREG: fix spelling of '-split-objs' in warningSergei Trofimovich2017-04-161-1/+1
| | | | | | | | | Spelling if warning message slightly mismathed passed commandline: $ ghc-stage2 -split-objs -C N.hs on the commandline: warning: ignoring -fsplit-objs Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* UNREG: remove dead code around -split-objsSergei Trofimovich2017-04-162-13/+4
| | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Fix typo in TcErrors.hsMatthías Páll Gissurarson2017-04-131-1/+1
| | | | | This fixes a very simple typo in TcErrors.hs. I hope this is small enough in scope to be accepted through GitHub.
* Comments only in Type.isPredTySimon Peyton Jones2017-04-131-4/+8
|
* Remove dead quantifyTyVarsSimon Peyton Jones2017-04-135-56/+54
| | | | | | | | | | | This patch * removes a function TcMType.quantifyTyVars that was never called * renames quantifyZonkedTyVars to quantifyTyVars Plus a few comments. No functional change at all
* Yet more work on TcSimplify.simplifyInferSimon Peyton Jones2017-04-133-137/+169
| | | | | | | | | | | | | | | | | The proximate cause for this patch is Trac #13482, which pointed out further subtle interactions between - Inferring the most general type of a function - A partial type signature for that function That led me into /further/ changes to the shiny new stuff in TcSimplify.simplifyInfer, decideQuantification, decideMonoTyVars, and related functions. Happily, I was able to make some of it quite a bit simpler, notably the bit about promoting free tyvars. I'm happy with the result. Moreover I fixed Trac #13524 at the same time. Happy days.
* Split up RnEnv into 4 modules, RnUnbound, RnUtils and RnFixityMatthew Pickering2017-04-1222-924/+1060
| | | | | | | | | | | | | | | | | | | Summary: RnEnv contains functions which convertn RdrNames into Names. RnUnbound contains helper functions for reporting and creating unbound variables. RnFixity contains code which maintains the fixity environent whilst renaming. RnUtils contains the other stuff in RnEnv. Reviewers: austin, goldfire, bgamari Subscribers: goldfire, rwbarton, thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3436
* Drop special handling of iOSMoritz Angermann2017-04-124-27/+3
| | | | | | | | | | | | | | | | | | | | iOS at least since iOS8 (we are currently at iOS10.3), allows for dynamic libaries, hence any artificail restriction on dyanmic libraries should be lifted. Please ping me with any iOS related issues that should potentially resurface. The iOS toolchain has considerably changed over the years, and I'm willing to drop work arounds in good faith. Reviewers: bgamari, austin Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13559, #7722 Differential Revision: https://phabricator.haskell.org/D3451
* Allow qualified names to be children in export listsMatthew Pickering2017-04-121-1/+1
| | | | | | | | | | | | | | | | When doing this I noticed a horrible amount of duplication between lookupSubBndrOcc and lookupExportChild (which I am responsible for). I opened #13545 to keep track of this. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13528 Differential Revision: https://phabricator.haskell.org/D3434
* Suggest correct replacement flag name for -dppr-ticksReid Barton2017-04-121-5/+5
| | | | | | | | | | | | | | | It told me to use -fno-suppress-ticks, but it should have been -dno-suppress-ticks. Test Plan: tested -dppr-ticks and -frewrite-rules manually Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3430
* base: Implement bit casts between word and float typesErik de Castro Lopo2017-04-121-2/+3
| | | | | | | | | | | | | Test Plan: Test on x86 and x86_64 Reviewers: duncan, trofi, simonmar, tibbe, hvr, austin, rwbarton, bgamari Reviewed By: duncan Subscribers: Phyx, DemiMarie, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3358
* RnEnv cleanupMatthew Pickering2017-04-121-75/+66
| | | | | | | | | | | | | | | | | | | | | | | | unless (not ..) -> when Remove unused getLookupOccRn Remove lookupGreRn2 It was only called in one place in a very strange way. It is easier to just use lookupGreRn which has nearly the same implementation and then directly call `unboundName`. Remove unused function mapFvRnCPS Remove unused functions bindLocatedLocalsRn and bindLocatedLocalsFV Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3435
* Make let and app consistent in exprIsCheapXSimon Peyton Jones2017-04-122-20/+32
| | | | | | | | This fixes Trac #13558, by making App and Let behave consistently; see Note [Arguments and let-bindings exprIsCheapX] I renamed the mysterious exprIsOk to exprIsCheapX. (The "X" is because it is parameterised over a CheapAppFun.)
* Add Outputable instance for ArityTypeSimon Peyton Jones2017-04-121-0/+4
|
* Fix another literal-string bugletSimon Peyton Jones2017-04-121-6/+7
| | | | | | | We were failing to float a nested binding x :: Addr# = "foo"# to top level, even though we /were/ floating string literals themselves. A small oversight, easily fixed.
* Improve demand analysis for join pointsSimon Peyton Jones2017-04-121-20/+62
| | | | | | | | | I realised (Trac #13543) that we can improve demand analysis for join point quite straightforwardly. The idea is explained in Note [Demand analysis for join points] in DmdAnal
* Kill off complications in CoreFVsSimon Peyton Jones2017-04-122-219/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing type-in-type, Richard introduce some substantial complications in CoreFVs, gathering types and free variables of type. In Trac #13160 we decided that this complication was unnecessary, so this patch removes it. Unfortnately I then fell down a twisty rabbit hole. Roughly: * An apparently-innocuous change in the AnnApp case of fiExpr made the fuction a little bit stricter, so we ended up peering into the arguments when we didn't before (namely when there are no bindings being floated inwards). I've rejigged it so that it's not fragile any more. * Peering into the arguments was sometimes expensive, becuase exprIsExpandable can be expensive because it looks deeply into the expression. * The combination of the two led to a non-linear explosion of work when the argument of a function is a deeep nest of constructors. This bug has been lurking for ages. I solved it by replacing exprIsExpandable with exprIsHNF + exprIsTrivial; see Note [noFloatInto considerations] * The code around floating case-expressions turned out to be very delicate, because can_fail primops (which we want to float inwards) can't be floated outwards; so we have to be careful never to float them too far. Note [Floating primops] has the details * I ended up refactoring some rather opaque code in sepBindsByDropPoint. Working all this out meant that I rewrote quite a bit of code, so it's now a reasonably substantial patch. But it's a net improvement.
* Typos in comments [ci skip]Gabor Greif2017-04-1113-21/+21
|