summaryrefslogtreecommitdiff
path: root/ghc/driver/ghc.lprl
diff options
context:
space:
mode:
authorsimonpj <unknown>2000-03-23 17:45:33 +0000
committersimonpj <unknown>2000-03-23 17:45:33 +0000
commit111cee3f1ad93816cb828e38b38521d85c3bcebb (patch)
tree65f0517386e1855a8bd7198eff92b2e12b07b923 /ghc/driver/ghc.lprl
parent290e7896a6785ba5dcfbc7045438f382afd447ff (diff)
downloadhaskell-111cee3f1ad93816cb828e38b38521d85c3bcebb.tar.gz
[project @ 2000-03-23 17:45:17 by simonpj]
This utterly gigantic commit is what I've been up to in background mode in the last couple of months. Originally the main goal was to get rid of Con (staturated constant applications) in the CoreExpr type, but one thing led to another, and I kept postponing actually committing. Sorry. Simon, 23 March 2000 I've tested it pretty thoroughly, but doubtless things will break. Here are the highlights * Con is gone; the CoreExpr type is simpler * NoRepLits have gone * Better usage info in interface files => less recompilation * Result type signatures work * CCall primop is tidied up * Constant folding now done by Rules * Lots of hackery in the simplifier * Improvements in CPR and strictness analysis Many bug fixes including * Sergey's DoCon compiles OK; no loop in the strictness analyser * Volker Wysk's programs don't crash the CPR analyser I have not done much on measuring compilation times and binary sizes; they could have got worse. I think performance has got significantly better, though, in most cases. Removing the Con form of Core expressions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The big thing is that For every constructor C there are now *two* Ids: C is the constructor's *wrapper*. It evaluates and unboxes arguments before calling $wC. It has a perfectly ordinary top-level defn in the module defining the data type. $wC is the constructor's *worker*. It is like a primop that simply allocates and builds the constructor value. Its arguments are the actual representation arguments of the constructor. Its type may be different to C, because: - useless dict args are dropped - strict args may be flattened For every primop P there is *one* Id, its (curried) Id Neither contructor worker Id nor the primop Id have a defminition anywhere. Instead they are saturated during the core-to-STG pass, and the code generator generates code for them directly. The STG language still has saturated primops and constructor applications. * The Const type disappears, along with Const.lhs. The literal part of Const.lhs reappears as Literal.lhs. Much tidying up in here, to bring all the range checking into this one module. * I got rid of NoRep literals entirely. They just seem to be too much trouble. * Because Con's don't exist any more, the funny C { args } syntax disappears from inteface files. Parsing ~~~~~~~ * Result type signatures now work f :: Int -> Int = \x -> x -- The Int->Int is the type of f g x y :: Int = x+y -- The Int is the type of the result of (g x y) Recompilation checking and make ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The .hi file for a modules is not touched if it doesn't change. (It used to be touched regardless, forcing a chain of recompilations.) The penalty for this is that we record exported things just as if they were mentioned in the body of the module. And the penalty for that is that we may recompile a module when the only things that have changed are the things it is passing on without using. But it seems like a good trade. * -recomp is on by default Foreign declarations ~~~~~~~~~~~~~~~~~~~~ * If you say foreign export zoo :: Int -> IO Int then you get a C produre called 'zoo', not 'zzoo' as before. I've also added a check that complains if you export (or import) a C procedure whose name isn't legal C. Code generation and labels ~~~~~~~~~~~~~~~~~~~~~~~~~~ * Now that constructor workers and wrappers have distinct names, there's no need to have a Foo_static_closure and a Foo_closure for constructor Foo. I nuked the entire StaticClosure story. This has effects in some of the RTS headers (i.e. s/static_closure/closure/g) Rules, constant folding ~~~~~~~~~~~~~~~~~~~~~~~ * Constant folding becomes just another rewrite rule, attached to the Id for the PrimOp. To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs). The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone. * Appending of constant strings now works, using fold/build fusion, plus the rewrite rule unpack "foo" c (unpack "baz" c n) = unpack "foobaz" c n Implemented in PrelRules.lhs * The CCall primop is tidied up quite a bit. There is now a data type CCall, defined in PrimOp, that packages up the info needed for a particular CCall. There is a new Id for each new ccall, with an big "occurrence name" {__ccall "foo" gc Int# -> Int#} In interface files, this is parsed as a single Id, which is what it is, really. Miscellaneous ~~~~~~~~~~~~~ * There were numerous places where the host compiler's minInt/maxInt was being used as the target machine's minInt/maxInt. I nuked all of these; everything is localised to inIntRange and inWordRange, in Literal.lhs * Desugaring record updates was broken: it didn't generate correct matches when used withe records with fancy unboxing etc. It now uses matchWrapper. * Significant tidying up in codeGen/SMRep.lhs * Add __word, __word64, __int64 terminals to signal the obvious types in interface files. Add the ability to print word values in hex into C code. * PrimOp.lhs is no longer part of a loop. Remove PrimOp.hi-boot* Types ~~~~~ * isProductTyCon no longer returns False for recursive products, nor for unboxed products; you have to test for these separately. There's no reason not to do CPR for recursive product types, for example. Ditto splitProductType_maybe. Simplification ~~~~~~~~~~~~~~~ * New -fno-case-of-case flag for the simplifier. We use this in the first run of the simplifier, where it helps to stop messing up expressions that the (subsequent) full laziness pass would otherwise find float out. It's much more effective than previous half-baked hacks in inlining. Actually, it turned out that there were three places in Simplify.lhs that needed to know use this flag. * Make the float-in pass push duplicatable bindings into the branches of a case expression, in the hope that we never have to allocate them. (see FloatIn.sepBindsByDropPoint) * Arrange that top-level bottoming Ids get a NOINLINE pragma This reduced gratuitous inlining of error messages. But arrange that such things still get w/w'd. * Arrange that a strict argument position is regarded as an 'interesting' context, so that if we see foldr k z (g x) then we'll be inclined to inline g; this can expose a build. * There was a missing case in CoreUtils.exprEtaExpandArity that meant we were missing some obvious cases for eta expansion Also improve the code when handling applications. * Make record selectors (identifiable by their IdFlavour) into "cheap" operations. [The change is a 2-liner in CoreUtils.exprIsCheap] This means that record selection may be inlined into function bodies, which greatly improves the arities of overloaded functions. * Make a cleaner job of inlining "lone variables". There was some distributed cunning, but I've centralised it all now in SimplUtils.analyseCont, which analyses the context of a call to decide whether it is "interesting". * Don't specialise very small functions in Specialise.specDefn It's better to inline it. Rather like the worker/wrapper case. * Be just a little more aggressive when floating out of let rhss. See comments with Simplify.wantToExpose A small change with an occasional big effect. * Make the inline-size computation think that case x of I# x -> ... is *free*. CPR analysis ~~~~~~~~~~~~ * Fix what was essentially a bug in CPR analysis. Consider letrec f x = let g y = let ... in f e1 in if ... then (a,b) else g x g has the CPR property if f does; so when generating the final annotated RHS for f, we must use an envt in which f is bound to its final abstract value. This wasn't happening. Instead, f was given the CPR tag but g wasn't; but of course the w/w pass gives rotten results in that case!! (Because f's CPR-ness relied on g's.) On they way I tidied up the code in CprAnalyse. It's quite a bit shorter. The fact that some data constructors return a constructed product shows up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs Strictness analysis and worker/wrapper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * BIG THING: pass in the demand to StrictAnal.saExpr. This affects situations like f (let x = e1 in (x,x)) where f turns out to have strictness u(SS), say. In this case we can mark x as demanded, and use a case expression for it. The situation before is that we didn't "know" that there is the u(SS) demand on the argument, so we simply computed that the body of the let expression is lazy in x, and marked x as lazily-demanded. Then even after f was w/w'd we got let x = e1 in case (x,x) of (a,b) -> $wf a b and hence let x = e1 in $wf a b I found a much more complicated situation in spectral/sphere/Main.shade, which improved quite a bit with this change. * Moved the StrictnessInfo type from IdInfo to Demand. It's the logical place for it, and helps avoid module loops * Do worker/wrapper for coerces even if the arity is zero. Thus: stdout = coerce Handle (..blurg..) ==> wibble = (...blurg...) stdout = coerce Handle wibble This is good because I found places where we were saying case coerce t stdout of { MVar a -> ... case coerce t stdout of { MVar b -> ... and the redundant case wasn't getting eliminated because of the coerce.
Diffstat (limited to 'ghc/driver/ghc.lprl')
-rw-r--r--ghc/driver/ghc.lprl66
1 files changed, 31 insertions, 35 deletions
diff --git a/ghc/driver/ghc.lprl b/ghc/driver/ghc.lprl
index d8a101ad1a..77c505d997 100644
--- a/ghc/driver/ghc.lprl
+++ b/ghc/driver/ghc.lprl
@@ -495,7 +495,7 @@ $Osuffix = ''; # default: use the normal suffix for that kind of output
$HiSuffix = 'hi';
$HiSuffix_prelude = '';
$CompilingPrelude=0;
-$Do_recomp_chkr = 0; # don't use the recompilatio checker unless asked
+$Do_recomp_chkr = 1; # Use the recompilation checker by default
$Do_cc = -1; # a MAGIC indeterminate value; will be set to 1 or 0.
$Do_as = 1;
@@ -726,25 +726,18 @@ sub setupOptimiseFlags {
'-fno-rules', # Similarly, don't apply any rules until after full laziness
# Notably, list fusion can prevent floating.
+ '-fno-case-of-case', # Don't do case-of-case transformations.
+ # This makes full laziness work better
+
'-fmax-simplifier-iterations2',
']',
# Specialisation is best done before full laziness
# so that overloaded functions have all their dictionary lambdas manifest
($Oopt_DoSpecialise) ? ( $Oopt_DoSpecialise, ) : (),
- '-ffull-laziness',
+ '-ffloat-outwards',
'-ffloat-inwards',
-# '-fsimplify',
-# '[',
-# # Run the simplifier before specialising, so that overloaded functions
-# # look like f = \d -> ...
-# # (Full laziness may lift out something hiding the \d
-# '-finline-phase1',
-# '-fmax-simplifier-iterations1',
-# ']',
-
-
'-fsimplify',
'[',
'-finline-phase1',
@@ -766,10 +759,17 @@ sub setupOptimiseFlags {
# before strictness analysis runs
'-finline-phase2',
- $Oopt_MaxSimplifierIterations,
+ '-fmax-simplifier-iterations2',
']',
+ '-fsimplify',
+ '[',
+ '-fmax-simplifier-iterations2',
+ # No -finline-phase: allow all Ids to be inlined now
+ # This gets foldr inlined before strictness analysis
+ ']',
+
'-fstrictness',
'-fcpr-analyse',
'-fworker-wrapper',
@@ -780,12 +780,19 @@ sub setupOptimiseFlags {
# No -finline-phase: allow all Ids to be inlined now
']',
- '-ffull-laziness', # nofib/spectral/hartel/wang doubles in speed if you
+ '-ffloat-outwards', # nofib/spectral/hartel/wang doubles in speed if you
# do full laziness late in the day. It only happens
# after fusion and other stuff, so the early pass doesn't
# catch it. For the record, the redex is
# f_el22 (f_el21 r_midblock)
+# Leave out lambda lifting for now
+# '-fsimplify', # Tidy up results of full laziness
+# '[',
+# '-fmax-simplifier-iterations2',
+# ']',
+# '-ffloat-outwards-full',
+
# We want CSE to follow the final full-laziness pass, because it may
# succeed in commoning up things floated out by full laziness.
#
@@ -1096,14 +1103,14 @@ sub setupLinkOpts {
,'-u', "${uscore}PrelAddr_I64zh_con_info"
,'-u', "${uscore}PrelAddr_W64zh_con_info"
,'-u', "${uscore}PrelStable_StablePtr_con_info"
- ,'-u', "${uscore}PrelBase_False_static_closure"
- ,'-u', "${uscore}PrelBase_True_static_closure"
+ ,'-u', "${uscore}PrelBase_False_closure"
+ ,'-u', "${uscore}PrelBase_True_closure"
,'-u', "${uscore}PrelPack_unpackCString_closure"
,'-u', "${uscore}PrelException_stackOverflow_closure"
,'-u', "${uscore}PrelException_heapOverflow_closure"
- ,'-u', "${uscore}PrelException_NonTermination_static_closure"
- ,'-u', "${uscore}PrelException_PutFullMVar_static_closure"
- ,'-u', "${uscore}PrelException_BlockedOnDeadMVar_static_closure"
+ ,'-u', "${uscore}PrelException_NonTermination_closure"
+ ,'-u', "${uscore}PrelException_PutFullMVar_closure"
+ ,'-u', "${uscore}PrelException_BlockedOnDeadMVar_closure"
,'-u', "${uscore}__init_Prelude"
,'-u', "${uscore}__init_PrelMain"
));
@@ -1668,23 +1675,12 @@ sub runHscAndProcessInterfaces {
# Tell the C compiler and assembler not to run
$do_cc = 0; $do_as = 0;
- # Update dependency info, touch both object file and
- # interface file, so that the following invariant is
- # maintained:
- #
- # a dependent module's interface file should after recompilation
- # checking be newer than the interface files of its imports.
- #
- # That is, if module A's interface file changes, then module B
- # (which import from A) needs to be checked.
- # If A's change does not affect B, which causes the compiler to bail
- # out early, we still need to touch the interface file of B. The reason
- # for this is that B may export A's interface.
+ # Update dependency info, by touching the object file
+ # This records in the file system that the work of
+ # recompiling this module has been done
#
&run_something("touch $ofile_target",
"Touch $ofile_target, to propagate dependencies") if $HscOut ne '-N=';
- &run_something("touch $hifile_target",
- "Touch $hifile_target, to propagate dependencies") if $ProduceHi =~ /-nohifile=/ ;
} else {
@@ -3218,8 +3214,8 @@ arg: while($_ = $Args[0]) {
# ---------------
- /^-fasm-(.*)$/ && do { $HscOut = '-S='; next arg; }; # force using nativeGen
- /^-fvia-[cC]$/ && do { $HscOut = '-C='; next arg; }; # force using C compiler
+ /^-fasm-(.*)$/ && do { $HscOut = '-S='; next arg; }; # force using nativeGen
+ /^-fvia-[cC]$/ && do { $HscOut = '-C='; next arg; }; # force using C compiler
# ---------------