ghc-hetmet.git
15 years agoComments only. Haddockify parts of TcRnTypes.
Thomas Schilling [Thu, 11 Dec 2008 15:46:57 +0000 (15:46 +0000)]
Comments only.  Haddockify parts of TcRnTypes.

15 years agoComments only. Fix typo.
Thomas Schilling [Thu, 11 Dec 2008 15:31:04 +0000 (15:31 +0000)]
Comments only.  Fix typo.

15 years agoInclude PprTyThings in tags file.
Thomas Schilling [Thu, 11 Dec 2008 15:30:05 +0000 (15:30 +0000)]
Include PprTyThings in tags file.

15 years agoUse DynFlags to work out if we are doing ticky ticky profiling
Ian Lynagh [Thu, 18 Dec 2008 16:19:28 +0000 (16:19 +0000)]
Use DynFlags to work out if we are doing ticky ticky profiling
We used to use StaticFlags

15 years agoFix warnings in CgExpr
Ian Lynagh [Wed, 17 Dec 2008 20:11:52 +0000 (20:11 +0000)]
Fix warnings in CgExpr

15 years agoFix warnings in CgBindery
Ian Lynagh [Wed, 17 Dec 2008 19:46:07 +0000 (19:46 +0000)]
Fix warnings in CgBindery

15 years agoFix warnings in CgStackery
Ian Lynagh [Wed, 17 Dec 2008 19:17:13 +0000 (19:17 +0000)]
Fix warnings in CgStackery

15 years agoFix warnings in CgCase
Ian Lynagh [Wed, 17 Dec 2008 19:08:48 +0000 (19:08 +0000)]
Fix warnings in CgCase

15 years agoRemove some dead code from CgCase
Ian Lynagh [Wed, 17 Dec 2008 18:47:55 +0000 (18:47 +0000)]
Remove some dead code from CgCase

15 years agoFix warnings in StgCmmProf
Ian Lynagh [Wed, 17 Dec 2008 18:22:36 +0000 (18:22 +0000)]
Fix warnings in StgCmmProf

15 years agoFix warnings in CgProf
Ian Lynagh [Wed, 17 Dec 2008 18:17:11 +0000 (18:17 +0000)]
Fix warnings in CgProf

15 years agoFix warnings in CgInfoTbls
Ian Lynagh [Wed, 17 Dec 2008 18:01:44 +0000 (18:01 +0000)]
Fix warnings in CgInfoTbls

15 years agoRemove dead function srtLabelAndLength from CgInfoTbls
Ian Lynagh [Wed, 17 Dec 2008 18:00:44 +0000 (18:00 +0000)]
Remove dead function srtLabelAndLength from CgInfoTbls

15 years agoFix warnings in CgHeapery
Ian Lynagh [Wed, 17 Dec 2008 17:57:26 +0000 (17:57 +0000)]
Fix warnings in CgHeapery

15 years agoFix warnings in CgTailCall
Ian Lynagh [Wed, 17 Dec 2008 17:50:40 +0000 (17:50 +0000)]
Fix warnings in CgTailCall

15 years agoRemove a little dead code from CgTailCall
Ian Lynagh [Wed, 17 Dec 2008 17:49:47 +0000 (17:49 +0000)]
Remove a little dead code from CgTailCall

15 years agoFix warnings in CodeGen
Ian Lynagh [Wed, 17 Dec 2008 16:59:04 +0000 (16:59 +0000)]
Fix warnings in CodeGen

15 years agoFix warnings in StgCmmTicky
Ian Lynagh [Wed, 17 Dec 2008 16:54:33 +0000 (16:54 +0000)]
Fix warnings in StgCmmTicky

15 years agoRemove dead code from CgUtils
Ian Lynagh [Wed, 17 Dec 2008 16:39:20 +0000 (16:39 +0000)]
Remove dead code from CgUtils

15 years agoFix warnings in CgPrimOp
Ian Lynagh [Wed, 17 Dec 2008 16:39:12 +0000 (16:39 +0000)]
Fix warnings in CgPrimOp

15 years agoFix warnings in CgMonad
Ian Lynagh [Wed, 17 Dec 2008 16:39:03 +0000 (16:39 +0000)]
Fix warnings in CgMonad

15 years agoFix warnings in CgClosure
Ian Lynagh [Wed, 17 Dec 2008 16:38:50 +0000 (16:38 +0000)]
Fix warnings in CgClosure

15 years agoFix warnings in CgForeignCall
Ian Lynagh [Mon, 15 Dec 2008 22:25:15 +0000 (22:25 +0000)]
Fix warnings in CgForeignCall

15 years agoRemove some redundant code
Ian Lynagh [Mon, 15 Dec 2008 19:40:47 +0000 (19:40 +0000)]
Remove some redundant code
We were looking at opt_DoTickyProfiling, and if it was set claling ifTicky
which looks at opt_DoTickyProfiling itself.

15 years agoFix warnings in CgLetNoEscape
Ian Lynagh [Mon, 15 Dec 2008 17:37:52 +0000 (17:37 +0000)]
Fix warnings in CgLetNoEscape

15 years agoWorkaround for #2262, from Barney Stratford
Simon Marlow [Tue, 16 Dec 2008 12:47:06 +0000 (12:47 +0000)]
Workaround for #2262, from Barney Stratford
See http://www.haskell.org/pipermail/glasgow-haskell-users/2008-December/016333.html

15 years agoUNDO: Add -fpass-case-bndr-to-join-points
Simon Marlow [Tue, 16 Dec 2008 11:42:35 +0000 (11:42 +0000)]
UNDO: Add -fpass-case-bndr-to-join-points

rolling back:

Fri Dec  5 10:51:59 GMT 2008  simonpj@microsoft.com
  * Add -fpass-case-bndr-to-join-points

  See Note [Passing the case binder to join points] in Simplify.lhs
  The default now is *not* to pass the case binder.  There are some
  nofib results with the above note; the effect is almost always
  negligible.

  I don't expect this flag to be used by users (hence no docs). It's just
  there to let me try the performance effects of switching on and off.

    M ./compiler/main/StaticFlagParser.hs +1
    M ./compiler/main/StaticFlags.hs +4
    M ./compiler/simplCore/Simplify.lhs -14 +73

15 years agoRollback INLINE patches
Simon Marlow [Tue, 16 Dec 2008 10:35:56 +0000 (10:35 +0000)]
Rollback INLINE patches

rolling back:

Fri Dec  5 16:54:00 GMT 2008  simonpj@microsoft.com
  * Completely new treatment of INLINE pragmas (big patch)

  This is a major patch, which changes the way INLINE pragmas work.
  Although lots of files are touched, the net is only +21 lines of
  code -- and I bet that most of those are comments!

  HEADS UP: interface file format has changed, so you'll need to
  recompile everything.

  There is not much effect on overall performance for nofib,
  probably because those programs don't make heavy use of INLINE pragmas.

          Program           Size    Allocs   Runtime   Elapsed
              Min         -11.3%     -6.9%     -9.2%     -8.2%
              Max          -0.1%     +4.6%     +7.5%     +8.9%
   Geometric Mean          -2.2%     -0.2%     -1.0%     -0.8%

  (The +4.6% for on allocs is cichelli; see other patch relating to
  -fpass-case-bndr-to-join-points.)

  The old INLINE system
  ~~~~~~~~~~~~~~~~~~~~~
  The old system worked like this. A function with an INLINE pragam
  got a right-hand side which looked like
       f = __inline_me__ (\xy. e)
  The __inline_me__ part was an InlineNote, and was treated specially
  in various ways.  Notably, the simplifier didn't inline inside an
  __inline_me__ note.

  As a result, the code for f itself was pretty crappy. That matters
  if you say (map f xs), because then you execute the code for f,
  rather than inlining a copy at the call site.

  The new story: InlineRules
  ~~~~~~~~~~~~~~~~~~~~~~~~~~
  The new system removes the InlineMe Note altogether.  Instead there
  is a new constructor InlineRule in CoreSyn.Unfolding.  This is a
  bit like a RULE, in that it remembers the template to be inlined inside
  the InlineRule.  No simplification or inlining is done on an InlineRule,
  just like RULEs.

  An Id can have an InlineRule *or* a CoreUnfolding (since these are two
  constructors from Unfolding). The simplifier treats them differently:

    - An InlineRule is has the substitution applied (like RULES) but
      is otherwise left undisturbed.

    - A CoreUnfolding is updated with the new RHS of the definition,
      on each iteration of the simplifier.

  An InlineRule fires regardless of size, but *only* when the function
  is applied to enough arguments.  The "arity" of the rule is specified
  (by the programmer) as the number of args on the LHS of the "=".  So
  it makes a difference whether you say
     {-# INLINE f #-}
   f x = \y -> e     or     f x y = e
  This is one of the big new features that InlineRule gives us, and it
  is one that Roman really wanted.

  In contrast, a CoreUnfolding can fire when it is applied to fewer
  args than than the function has lambdas, provided the result is small
  enough.

  Consequential stuff
  ~~~~~~~~~~~~~~~~~~~
  * A 'wrapper' no longer has a WrapperInfo in the IdInfo.  Instead,
    the InlineRule has a field identifying wrappers.

  * Of course, IfaceSyn and interface serialisation changes appropriately.

  * Making implication constraints inline nicely was a bit fiddly. In
    the end I added a var_inline field to HsBInd.VarBind, which is why
    this patch affects the type checker slightly

  * I made some changes to the way in which eta expansion happens in
    CorePrep, mainly to ensure that *arguments* that become let-bound
    are also eta-expanded.  I'm still not too happy with the clarity
    and robustness fo the result.

  * We now complain if the programmer gives an INLINE pragma for
    a recursive function (prevsiously we just ignored it).  Reason for
    change: we don't want an InlineRule on a LoopBreaker, because then
    we'd have to check for loop-breaker-hood at occurrence sites (which
    isn't currenlty done).  Some tests need changing as a result.

  This patch has been in my tree for quite a while, so there are
  probably some other minor changes.

    M ./compiler/basicTypes/Id.lhs -11
    M ./compiler/basicTypes/IdInfo.lhs -82
    M ./compiler/basicTypes/MkId.lhs -2 +2
    M ./compiler/coreSyn/CoreFVs.lhs -2 +25
    M ./compiler/coreSyn/CoreLint.lhs -5 +1
    M ./compiler/coreSyn/CorePrep.lhs -59 +53
    M ./compiler/coreSyn/CoreSubst.lhs -22 +31
    M ./compiler/coreSyn/CoreSyn.lhs -66 +92
    M ./compiler/coreSyn/CoreUnfold.lhs -112 +112
    M ./compiler/coreSyn/CoreUtils.lhs -185 +184
    M ./compiler/coreSyn/MkExternalCore.lhs -1
    M ./compiler/coreSyn/PprCore.lhs -4 +40
    M ./compiler/deSugar/DsBinds.lhs -70 +118
    M ./compiler/deSugar/DsForeign.lhs -2 +4
    M ./compiler/deSugar/DsMeta.hs -4 +3
    M ./compiler/hsSyn/HsBinds.lhs -3 +3
    M ./compiler/hsSyn/HsUtils.lhs -2 +7
    M ./compiler/iface/BinIface.hs -11 +25
    M ./compiler/iface/IfaceSyn.lhs -13 +21
    M ./compiler/iface/MkIface.lhs -24 +19
    M ./compiler/iface/TcIface.lhs -29 +23
    M ./compiler/main/TidyPgm.lhs -55 +49
    M ./compiler/parser/ParserCore.y -5 +6
    M ./compiler/simplCore/CSE.lhs -2 +1
    M ./compiler/simplCore/FloatIn.lhs -6 +1
    M ./compiler/simplCore/FloatOut.lhs -23
    M ./compiler/simplCore/OccurAnal.lhs -36 +5
    M ./compiler/simplCore/SetLevels.lhs -59 +54
    M ./compiler/simplCore/SimplCore.lhs -48 +52
    M ./compiler/simplCore/SimplEnv.lhs -26 +22
    M ./compiler/simplCore/SimplUtils.lhs -28 +4
    M ./compiler/simplCore/Simplify.lhs -91 +109
    M ./compiler/specialise/Specialise.lhs -15 +18
    M ./compiler/stranal/WorkWrap.lhs -14 +11
    M ./compiler/stranal/WwLib.lhs -2 +2
    M ./compiler/typecheck/Inst.lhs -1 +3
    M ./compiler/typecheck/TcBinds.lhs -17 +27
    M ./compiler/typecheck/TcClassDcl.lhs -1 +2
    M ./compiler/typecheck/TcExpr.lhs -4 +6
    M ./compiler/typecheck/TcForeign.lhs -1 +1
    M ./compiler/typecheck/TcGenDeriv.lhs -14 +13
    M ./compiler/typecheck/TcHsSyn.lhs -3 +2
    M ./compiler/typecheck/TcInstDcls.lhs -5 +4
    M ./compiler/typecheck/TcRnDriver.lhs -2 +11
    M ./compiler/typecheck/TcSimplify.lhs -10 +17
    M ./compiler/vectorise/VectType.hs +7

Mon Dec  8 12:43:10 GMT 2008  simonpj@microsoft.com
  * White space only

    M ./compiler/simplCore/Simplify.lhs -2

Mon Dec  8 12:48:40 GMT 2008  simonpj@microsoft.com
  * Move simpleOptExpr from CoreUnfold to CoreSubst

    M ./compiler/coreSyn/CoreSubst.lhs -1 +87
    M ./compiler/coreSyn/CoreUnfold.lhs -72 +1

Mon Dec  8 17:30:18 GMT 2008  simonpj@microsoft.com
  * Use CoreSubst.simpleOptExpr in place of the ad-hoc simpleSubst (reduces code too)

    M ./compiler/deSugar/DsBinds.lhs -50 +16

Tue Dec  9 17:03:02 GMT 2008  simonpj@microsoft.com
  * Fix Trac #2861: bogus eta expansion

  Urghlhl!  I "tided up" the treatment of the "state hack" in CoreUtils, but
  missed an unexpected interaction with the way that a bottoming function
  simply swallows excess arguments.  There's a long
       Note [State hack and bottoming functions]
  to explain (which accounts for most of the new lines of code).

    M ./compiler/coreSyn/CoreUtils.lhs -16 +53

Mon Dec 15 10:02:21 GMT 2008  Simon Marlow <marlowsd@gmail.com>
  * Revert CorePrep part of "Completely new treatment of INLINE pragmas..."

  The original patch said:

  * I made some changes to the way in which eta expansion happens in
    CorePrep, mainly to ensure that *arguments* that become let-bound
    are also eta-expanded.  I'm still not too happy with the clarity
    and robustness fo the result.

  Unfortunately this change apparently broke some invariants that were
  relied on elsewhere, and in particular lead to panics when compiling
  with profiling on.

  Will re-investigate in the new year.

    M ./compiler/coreSyn/CorePrep.lhs -53 +58
    M ./configure.ac -1 +1

Mon Dec 15 12:28:51 GMT 2008  Simon Marlow <marlowsd@gmail.com>
  * revert accidental change to configure.ac

    M ./configure.ac -1 +1

15 years agorevert accidental change to configure.ac
Simon Marlow [Mon, 15 Dec 2008 12:28:51 +0000 (12:28 +0000)]
revert accidental change to configure.ac

15 years agoRevert CorePrep part of "Completely new treatment of INLINE pragmas..."
Simon Marlow [Mon, 15 Dec 2008 10:02:21 +0000 (10:02 +0000)]
Revert CorePrep part of "Completely new treatment of INLINE pragmas..."

The original patch said:

* I made some changes to the way in which eta expansion happens in
  CorePrep, mainly to ensure that *arguments* that become let-bound
  are also eta-expanded.  I'm still not too happy with the clarity
  and robustness fo the result.

Unfortunately this change apparently broke some invariants that were
relied on elsewhere, and in particular lead to panics when compiling
with profiling on.

Will re-investigate in the new year.

15 years agowake up other Capabilities even when there is only one spark (see #2868)
Simon Marlow [Wed, 10 Dec 2008 16:46:44 +0000 (16:46 +0000)]
wake up other Capabilities even when there is only one spark (see #2868)

15 years agoDocument new GC options -q1 and -qg<n>
Simon Marlow [Wed, 10 Dec 2008 16:45:57 +0000 (16:45 +0000)]
Document new GC options -q1 and -qg<n>

15 years agoSysTools no longer needs -fno-cse
Ian Lynagh [Thu, 11 Dec 2008 18:23:27 +0000 (18:23 +0000)]
SysTools no longer needs -fno-cse

15 years agoMake the lists of files and directories to be cleaned-up non-global
Ian Lynagh [Thu, 11 Dec 2008 18:07:39 +0000 (18:07 +0000)]
Make the lists of files and directories to be cleaned-up non-global
They still need to be stored in IORefs, as the exception handler needs
to know what they all are.

15 years agoThe default cleanup handler should /always/ delete the temp files
Ian Lynagh [Thu, 11 Dec 2008 17:00:06 +0000 (17:00 +0000)]
The default cleanup handler should /always/ delete the temp files
Not only if there has been an exception. It worked for GHC anyway,
as it was getting an ExitSuccess exception, but GHC API clients
shouldn't be required to do that.

15 years agoFix user guide typesetting
Ian Lynagh [Wed, 10 Dec 2008 16:54:34 +0000 (16:54 +0000)]
Fix user guide typesetting

15 years agoFIX #1364: added support for C finalizers that run as soon as the value is not longer...
Simon Marlow [Wed, 10 Dec 2008 15:04:25 +0000 (15:04 +0000)]
FIX #1364: added support for C finalizers that run as soon as the value is not longer reachable.

Patch originally by Ivan Tomac <tomac@pacific.net.au>, amended by
Simon Marlow:

  - mkWeakFinalizer# commoned up with mkWeakFinalizerEnv#
  - GC parameters to ALLOC_PRIM fixed

15 years agoOn FreeBSD, try MAP_FIXED if ordinary mmap() fails to give us suitable memory
Simon Marlow [Wed, 10 Dec 2008 11:57:51 +0000 (11:57 +0000)]
On FreeBSD, try MAP_FIXED if ordinary mmap() fails to give us suitable memory
This appears to be necessary on FreeBSD.  It might be necessary on
other OSs too, but I'm being cautious because using MAP_FIXED can lead
to crashes by overwriting existing mappings, and we have no (easy) way
to prevent that.

15 years agoDocument hs_init() infelicity (#2863)
Simon Marlow [Tue, 9 Dec 2008 16:43:22 +0000 (16:43 +0000)]
Document hs_init() infelicity (#2863)

15 years agoImprove documentation for data family instances (cf Trac #1968)
simonpj@microsoft.com [Wed, 10 Dec 2008 05:44:32 +0000 (05:44 +0000)]
Improve documentation for data family instances (cf Trac #1968)

The HEAD allows GADT syntax for data/newtype family instances.
(GHC 6.10 does not seem to.)

15 years agoMake some profiling flags dynamic
Ian Lynagh [Tue, 9 Dec 2008 23:01:57 +0000 (23:01 +0000)]
Make some profiling flags dynamic
In particular:
    -fauto-sccs-on-all-toplevs          -auto-all   -no-auto-all
    -fauto-sccs-on-exported-toplevs     -auto       -no-auto
    -fauto-sccs-on-individual-cafs      -caf-all    -no-caf-all

15 years agoFix warnings in StgCmmGran
Ian Lynagh [Tue, 9 Dec 2008 22:24:13 +0000 (22:24 +0000)]
Fix warnings in StgCmmGran

15 years agoAdd OPTIONS_CATCH,DERIVE,YHC to those that GHC knows about; trac #2847
Ian Lynagh [Tue, 9 Dec 2008 19:17:24 +0000 (19:17 +0000)]
Add OPTIONS_CATCH,DERIVE,YHC to those that GHC knows about; trac #2847

15 years agoFix warnings in CgHpc
Ian Lynagh [Tue, 9 Dec 2008 19:17:13 +0000 (19:17 +0000)]
Fix warnings in CgHpc

15 years agoParse pragma names better; trac #2847
Ian Lynagh [Tue, 9 Dec 2008 19:03:18 +0000 (19:03 +0000)]
Parse pragma names better; trac #2847
We require that pragma names are not followed by pragma character,
defined as
    isAlphaNum c || c == '_'

15 years agoFix warnings in CgParallel
Ian Lynagh [Tue, 9 Dec 2008 18:44:02 +0000 (18:44 +0000)]
Fix warnings in CgParallel

15 years agoFix warnings in StgCmmHpc
Ian Lynagh [Tue, 9 Dec 2008 18:40:04 +0000 (18:40 +0000)]
Fix warnings in StgCmmHpc

15 years agoRemove an unnecessary -w flag
Ian Lynagh [Tue, 9 Dec 2008 18:38:12 +0000 (18:38 +0000)]
Remove an unnecessary -w flag

15 years agoFix Trac #2861: bogus eta expansion
simonpj@microsoft.com [Tue, 9 Dec 2008 17:03:02 +0000 (17:03 +0000)]
Fix Trac #2861: bogus eta expansion

Urghlhl!  I "tided up" the treatment of the "state hack" in CoreUtils, but
missed an unexpected interaction with the way that a bottoming function
simply swallows excess arguments.  There's a long
     Note [State hack and bottoming functions]
to explain (which accounts for most of the new lines of code).

15 years agoFix #2592: do an orderly shutdown when the heap is exhausted
Simon Marlow [Tue, 9 Dec 2008 10:59:19 +0000 (10:59 +0000)]
Fix #2592: do an orderly shutdown when the heap is exhausted
Really we should be raising an exception in this case, but that's
tricky (see comments).  At least now we shut down the runtime
correctly rather than just exiting.

15 years agoFix #2848: avoid overflow during time calculation
Simon Marlow [Tue, 9 Dec 2008 10:56:00 +0000 (10:56 +0000)]
Fix #2848: avoid overflow during time calculation

15 years agoFix #2838: we should narrow a CmmInt before converting to ImmInteger
Simon Marlow [Tue, 9 Dec 2008 10:55:15 +0000 (10:55 +0000)]
Fix #2838: we should narrow a CmmInt before converting to ImmInteger

15 years agofix an assertion failure in prof/threaded/debug mode
Simon Marlow [Thu, 4 Dec 2008 10:12:01 +0000 (10:12 +0000)]
fix an assertion failure in prof/threaded/debug mode

15 years agoInject implicit bindings after CoreTidy, not before Simplify
simonpj@microsoft.com [Mon, 8 Dec 2008 17:35:25 +0000 (17:35 +0000)]
Inject implicit bindings after CoreTidy, not before Simplify

Originally I inject the "implicit bindings" (record selectors, class
method selectors, data con wrappers...) after CoreTidy.  However, in a
misguided attempt to fix Trac #2070, I moved the injection point to
before the Simplifier, so that record selectors would be optimised by
the simplifier.

This was misguided because record selectors (indeed all implicit bindings)
are GlobalIds, whose IdInfo is meant to be frozen.  But the Simplifier,
and other Core-to-Core optimisations, merrily change the IdInfo.  That
ultimately made Trac #2844 happen, where a record selector got arity 2,
but the GlobalId (which importing scopes re-construct from the class decl
rather than reading from the interface file) has arity 1.

So this patch moves the injection back to CoreTidy. Happily #2070 should
still be OK because we now use CoreSubst.simpleOptExpr on the unfoldings
for implict things, which gets rid of the most gratuitous infelicities.

Still, there's a strong case for stoppping record selectors from being
GlobalIds, and treating them much more like dict-funs.  I'm thinking
about that.  Meanwhile, #2844 is ok now.

15 years agoAdd assertion for arity match (checks Trac #2844)
simonpj@microsoft.com [Mon, 8 Dec 2008 17:32:41 +0000 (17:32 +0000)]
Add assertion for arity match (checks Trac #2844)

The exported arity of a function must match the arity for the
STG function.  Trac #2844 was a pretty obscure manifestation of
the failure of this invariant. This patch doesn't cure the bug;
rather it adds an assertion to CoreToStg to check the invariant
so we should get an earlier and less obscure warning if this
fails in future.

15 years agoUse CoreSubst.simpleOptExpr in place of the ad-hoc simpleSubst (reduces code too)
simonpj@microsoft.com [Mon, 8 Dec 2008 17:30:18 +0000 (17:30 +0000)]
Use CoreSubst.simpleOptExpr in place of the ad-hoc simpleSubst (reduces code too)

15 years agoMove simpleOptExpr from CoreUnfold to CoreSubst
simonpj@microsoft.com [Mon, 8 Dec 2008 12:48:40 +0000 (12:48 +0000)]
Move simpleOptExpr from CoreUnfold to CoreSubst

15 years agoWhite space only
simonpj@microsoft.com [Mon, 8 Dec 2008 12:43:10 +0000 (12:43 +0000)]
White space only

15 years agoComments only
simonpj@microsoft.com [Mon, 8 Dec 2008 12:41:55 +0000 (12:41 +0000)]
Comments only

15 years agoCompletely new treatment of INLINE pragmas (big patch)
simonpj@microsoft.com [Fri, 5 Dec 2008 16:54:00 +0000 (16:54 +0000)]
Completely new treatment of INLINE pragmas (big patch)

This is a major patch, which changes the way INLINE pragmas work.
Although lots of files are touched, the net is only +21 lines of
code -- and I bet that most of those are comments!

HEADS UP: interface file format has changed, so you'll need to
recompile everything.

There is not much effect on overall performance for nofib,
probably because those programs don't make heavy use of INLINE pragmas.

        Program           Size    Allocs   Runtime   Elapsed
            Min         -11.3%     -6.9%     -9.2%     -8.2%
            Max          -0.1%     +4.6%     +7.5%     +8.9%
 Geometric Mean          -2.2%     -0.2%     -1.0%     -0.8%

(The +4.6% for on allocs is cichelli; see other patch relating to
-fpass-case-bndr-to-join-points.)

The old INLINE system
~~~~~~~~~~~~~~~~~~~~~
The old system worked like this. A function with an INLINE pragam
got a right-hand side which looked like
     f = __inline_me__ (\xy. e)
The __inline_me__ part was an InlineNote, and was treated specially
in various ways.  Notably, the simplifier didn't inline inside an
__inline_me__ note.

As a result, the code for f itself was pretty crappy. That matters
if you say (map f xs), because then you execute the code for f,
rather than inlining a copy at the call site.

The new story: InlineRules
~~~~~~~~~~~~~~~~~~~~~~~~~~
The new system removes the InlineMe Note altogether.  Instead there
is a new constructor InlineRule in CoreSyn.Unfolding.  This is a
bit like a RULE, in that it remembers the template to be inlined inside
the InlineRule.  No simplification or inlining is done on an InlineRule,
just like RULEs.

An Id can have an InlineRule *or* a CoreUnfolding (since these are two
constructors from Unfolding). The simplifier treats them differently:

  - An InlineRule is has the substitution applied (like RULES) but
    is otherwise left undisturbed.

  - A CoreUnfolding is updated with the new RHS of the definition,
    on each iteration of the simplifier.

An InlineRule fires regardless of size, but *only* when the function
is applied to enough arguments.  The "arity" of the rule is specified
(by the programmer) as the number of args on the LHS of the "=".  So
it makes a difference whether you say
   {-# INLINE f #-}
f x = \y -> e     or     f x y = e
This is one of the big new features that InlineRule gives us, and it
is one that Roman really wanted.

In contrast, a CoreUnfolding can fire when it is applied to fewer
args than than the function has lambdas, provided the result is small
enough.

Consequential stuff
~~~~~~~~~~~~~~~~~~~
* A 'wrapper' no longer has a WrapperInfo in the IdInfo.  Instead,
  the InlineRule has a field identifying wrappers.

* Of course, IfaceSyn and interface serialisation changes appropriately.

* Making implication constraints inline nicely was a bit fiddly. In
  the end I added a var_inline field to HsBInd.VarBind, which is why
  this patch affects the type checker slightly

* I made some changes to the way in which eta expansion happens in
  CorePrep, mainly to ensure that *arguments* that become let-bound
  are also eta-expanded.  I'm still not too happy with the clarity
  and robustness fo the result.

* We now complain if the programmer gives an INLINE pragma for
  a recursive function (prevsiously we just ignored it).  Reason for
  change: we don't want an InlineRule on a LoopBreaker, because then
  we'd have to check for loop-breaker-hood at occurrence sites (which
  isn't currenlty done).  Some tests need changing as a result.

This patch has been in my tree for quite a while, so there are
probably some other minor changes.

15 years agoAdd -fpass-case-bndr-to-join-points
simonpj@microsoft.com [Fri, 5 Dec 2008 10:51:59 +0000 (10:51 +0000)]
Add -fpass-case-bndr-to-join-points

See Note [Passing the case binder to join points] in Simplify.lhs
The default now is *not* to pass the case binder.  There are some
nofib results with the above note; the effect is almost always
negligible.

I don't expect this flag to be used by users (hence no docs). It's just
there to let me try the performance effects of switching on and off.

15 years agoAdd static flag -fsimple-list-literals
simonpj@microsoft.com [Fri, 5 Dec 2008 10:50:02 +0000 (10:50 +0000)]
Add static flag -fsimple-list-literals

The new static flag -fsimple-list-literals makes ExplicitList literals
be desugared in the straightforward way, rather than using 'build' as
now.  See SLPJ comments with Note [Desugaring explicit lists].

I don't expect this flag to be used by users (hence no docs). It's just
there to let me try the performance effects of switching on and off.

15 years agoComments only in OccurAnal
simonpj@microsoft.com [Fri, 5 Dec 2008 10:32:52 +0000 (10:32 +0000)]
Comments only in OccurAnal

15 years agoComments only
simonpj@microsoft.com [Fri, 5 Dec 2008 10:24:37 +0000 (10:24 +0000)]
Comments only

15 years agoLayout only
simonpj@microsoft.com [Fri, 5 Dec 2008 10:22:52 +0000 (10:22 +0000)]
Layout only

15 years agoComments only (Note [Entering error thunks])
simonpj@microsoft.com [Fri, 5 Dec 2008 10:21:49 +0000 (10:21 +0000)]
Comments only (Note [Entering error thunks])

15 years agoMake CoreToStg a little more robust to eta expansion
simonpj@microsoft.com [Fri, 5 Dec 2008 10:19:32 +0000 (10:19 +0000)]
Make CoreToStg a little more robust to eta expansion

15 years agoAdd no-op case for addIdSpecialisations (very minor optimisation)
simonpj@microsoft.com [Fri, 5 Dec 2008 10:10:22 +0000 (10:10 +0000)]
Add no-op case for addIdSpecialisations (very minor optimisation)

15 years agoTrim redundant import
simonpj@microsoft.com [Fri, 5 Dec 2008 10:10:06 +0000 (10:10 +0000)]
Trim redundant import

15 years agoMake CoreTidy retain deadness info (better -ddump-simpl)
simonpj@microsoft.com [Fri, 5 Dec 2008 10:05:18 +0000 (10:05 +0000)]
Make CoreTidy retain deadness info (better -ddump-simpl)

GHC now retains more robust information about dead variables; but
CoreTidy was throwing it away.  This patch makes CoreTidy retain it,
which gives better output for -ddump-simpl.

New opportunity: shrink interface files by using wildcards for dead variables.

15 years agoRemove INLINE pragmas on recursive functions
simonpj@microsoft.com [Fri, 5 Dec 2008 10:03:53 +0000 (10:03 +0000)]
Remove INLINE pragmas on recursive functions

INLINE pragmas on recursive functions are ignored; and this
is checked in my upcoming patch for inlinings.

15 years agoComments only (on Activation)
simonpj@microsoft.com [Fri, 5 Dec 2008 10:01:39 +0000 (10:01 +0000)]
Comments only (on Activation)

15 years agoWe need to tell cabal-bin which version of Cabal to use
Ian Lynagh [Wed, 3 Dec 2008 12:32:08 +0000 (12:32 +0000)]
We need to tell cabal-bin which version of Cabal to use
Otherwise, if the bootstrapping compiler has a newer version, we get
a mismatch between the version used to compile ghc-prim's Setup.hs and
the version that installPackage uses.

15 years agoDocument 'loadModule'.
Thomas Schilling [Tue, 2 Dec 2008 15:48:00 +0000 (15:48 +0000)]
Document 'loadModule'.

15 years agoAdd 'needsTemplateHaskell' utility function and document why one might
Thomas Schilling [Tue, 2 Dec 2008 15:23:58 +0000 (15:23 +0000)]
Add 'needsTemplateHaskell' utility function and document why one might
want to use it.

15 years agoDocumentation only.
Thomas Schilling [Tue, 2 Dec 2008 15:01:58 +0000 (15:01 +0000)]
Documentation only.

15 years agoExport 'succeeded' and 'failed' helper functions.
Thomas Schilling [Tue, 2 Dec 2008 14:44:51 +0000 (14:44 +0000)]
Export 'succeeded' and 'failed' helper functions.

15 years agoPut full ImportDecls in ModSummary instead of just ModuleNames
Simon Marlow [Tue, 2 Dec 2008 13:37:36 +0000 (13:37 +0000)]
Put full ImportDecls in ModSummary instead of just ModuleNames
... and use it to make ghc -M generate correct cross-package
dependencies when using package-qualified imports (needed for the new
build system).  Since we're already parsing the ImportDecl from the
source file, there seems no good reason not to keep it in the
ModSummary, it might be useful for other things too.

15 years agoghc -M: need to add a dep on Prelude unless -fno-implicit-prelude is on
Simon Marlow [Fri, 28 Nov 2008 16:57:07 +0000 (16:57 +0000)]
ghc -M: need to add a dep on Prelude unless -fno-implicit-prelude is on

15 years agomake -include-pkg-deps work (not sure when this got lost)
Simon Marlow [Fri, 28 Nov 2008 13:57:46 +0000 (13:57 +0000)]
make -include-pkg-deps work (not sure when this got lost)

15 years agoFix more problems caused by padding in the Capability structure
Simon Marlow [Tue, 2 Dec 2008 12:07:35 +0000 (12:07 +0000)]
Fix more problems caused by padding in the Capability structure
Fixes crashes on Windows and Sparc

15 years agoadd missing case to Ord GlobalReg (EagerBlackhole == EagerBlackhole)
Simon Marlow [Fri, 28 Nov 2008 13:01:06 +0000 (13:01 +0000)]
add missing case to Ord GlobalReg (EagerBlackhole == EagerBlackhole)

15 years agoBetter error message for fundep conflict
simonpj@microsoft.com [Mon, 1 Dec 2008 16:28:45 +0000 (16:28 +0000)]
Better error message for fundep conflict

15 years agoFix typo in quasi-quote documentation's sample.
shelarcy [Sat, 29 Nov 2008 02:43:44 +0000 (02:43 +0000)]
Fix typo in quasi-quote documentation's sample.

15 years agoRemove the v_Split_info global variable and use a field of dflags instead
Ian Lynagh [Sun, 30 Nov 2008 15:24:03 +0000 (15:24 +0000)]
Remove the v_Split_info global variable and use a field of dflags instead

15 years agoDocument the --machine-readable RTS flag
Ian Lynagh [Sun, 30 Nov 2008 15:23:11 +0000 (15:23 +0000)]
Document the --machine-readable RTS flag

15 years agoLet 'loadModule' generate proper code depending on the 'hscTarget'.
Thomas Schilling [Fri, 28 Nov 2008 16:44:12 +0000 (16:44 +0000)]
Let 'loadModule' generate proper code depending on the 'hscTarget'.

With this change it should be possible to perform something similar to
'load' by traversing the module graph in dependency order and calling
'{parse,typecheck,load}Module' on each.  Of course, if you want smart
recompilation checking you should still use 'load'.

15 years agoExpose a separate 'hscBackend' phase for 'HsCompiler' and change
Thomas Schilling [Fri, 28 Nov 2008 16:37:46 +0000 (16:37 +0000)]
Expose a separate 'hscBackend' phase for 'HsCompiler' and change
parameter to 'InteractiveStatus' to a 'Maybe'.

15 years agoWhoops, *don't* reset the complete session in 'withLocalCallbacks'.
Thomas Schilling [Fri, 28 Nov 2008 15:07:27 +0000 (15:07 +0000)]
Whoops, *don't* reset the complete session in 'withLocalCallbacks'.

15 years agoUse a record instead of a typeclass for 'HsCompiler'. This is mostly
Thomas Schilling [Fri, 28 Nov 2008 12:19:47 +0000 (12:19 +0000)]
Use a record instead of a typeclass for 'HsCompiler'.  This is mostly
equivalent to a typeclass implementation that uses a functional
dependency from the target mode to the result type.

15 years agoRemove dead code
Ian Lynagh [Fri, 28 Nov 2008 19:38:31 +0000 (19:38 +0000)]
Remove dead code

15 years agoUpdate docs not to talk about deprecated -optdep-* flags; fixes trac #2773
Ian Lynagh [Fri, 28 Nov 2008 19:36:33 +0000 (19:36 +0000)]
Update docs not to talk about deprecated -optdep-* flags; fixes trac #2773

15 years agoUse relative URLs in the GHC API haddock docs; fixes #2755
Ian Lynagh [Fri, 28 Nov 2008 18:45:11 +0000 (18:45 +0000)]
Use relative URLs in the GHC API haddock docs; fixes #2755

15 years agoTeach runghc about --help; fixes trac #2757
Ian Lynagh [Fri, 28 Nov 2008 19:17:06 +0000 (19:17 +0000)]
Teach runghc about --help; fixes trac #2757

15 years agoUse a per-session data structure for callbacks. Make 'WarnErrLogger'
Thomas Schilling [Fri, 28 Nov 2008 10:36:28 +0000 (10:36 +0000)]
Use a per-session data structure for callbacks.  Make 'WarnErrLogger'
part of it.

Part of the GHC API essentially represents a compilation framework.
The difference of a *framework* as opposed to a *library* is that the
overall structure of the functionality is pre-defined but certain
details can be customised via callbacks.  (Also known as the Hollywood
Principle: "Don't call us, we'll call you.")

This patch introduces a per-session data structure that contains all
the callbacks instead of adding lots of small function arguments
whenever we want to give the user more control over certain parts of
the API.  This should also help with future changes: Adding a new
callback doesn't break old code since code that doesn't know about the
new callback will use the (hopefully sane) default implementation.

Overall, however, we should try and keep the number of callbacks small
and well-defined (and provide useful defaults) and use simple library
routines for the rest.

15 years agoImprove error message for #2739 (but no fix).
Thomas Schilling [Thu, 27 Nov 2008 13:57:25 +0000 (13:57 +0000)]
Improve error message for #2739 (but no fix).

This patch changes 'loadModule' to define a fake linkable.  The
previous implementation of providing no linkable at all violated a
pre-condition in the ByteCode linker.  This doesn't fix #2739, but it
improves the error message a bit.

15 years agoRemove the packing I added recently to the Capability structure
Simon Marlow [Fri, 28 Nov 2008 10:50:46 +0000 (10:50 +0000)]
Remove the packing I added recently to the Capability structure
The problem is that the packing caused some unaligned loads, which
lead to bus errors on Sparc (and reduced performance elsewhere,
presumably).

15 years agodon't emit CmmComments for now
Simon Marlow [Thu, 27 Nov 2008 09:01:45 +0000 (09:01 +0000)]
don't emit CmmComments for now
  - if the string contains */, we need to fix it (demonstrated by
    building Cabal with -fvia-C)
  - the strings can get quite large, so we probably only want to
    inject comments when some debugging option is on.

15 years agoCollect instead of print warnings in 'warnUnnecessarySourceImports'.
Thomas Schilling [Thu, 27 Nov 2008 10:25:34 +0000 (10:25 +0000)]
Collect instead of print warnings in 'warnUnnecessarySourceImports'.

15 years agoForce recompilation of BCOs when they were compiled in HscNothing mode.
Thomas Schilling [Wed, 26 Nov 2008 18:34:02 +0000 (18:34 +0000)]
Force recompilation of BCOs when they were compiled in HscNothing mode.

Previously, loading a set of modules in HscNothing mode and then
switching to HscInterpreted could lead to crashes since modules
compiled with HscNothing were thought to be valid bytecode objects.

This patch forces recompilation in these cases, hence switching between
HscNothing and HscInterpreted should be safe now.