summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmProcPoint.hs
Commit message (Collapse)AuthorAgeFilesLines
* Drop proc-points that don't exist in the graph (#8205)Jan Stolarek2013-09-111-17/+47
| | | | | | | | On some architectures it might happen that stack layout pass will invalidate the list of calculated procpoints by dropping some of them. We fix this by checking whether a proc-point is in a graph at the beginning of proc-point analysis. This is a speculative fix for #8205.
* Remove unnecessary warnings suppressions, fixes ticket #7756; thanks ↵Edward Z. Yang2013-03-091-1/+0
| | | | | | monoidal for submitting. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Rename all of the 'cmmz' flags and make them more consistent.Austin Seipp2012-12-191-1/+1
| | | | | | | | | | | | | | | | There's only a single compiler backend now, so the 'z' suffix means nothing. Also, the flags were confusingly named ('cmm-foo' vs 'foo-cmm',) and counter-intuitively, '-ddump-cmm' did not do at all what you expected since the new backend went live. Basically, all of the -ddump-cmmz-* flags are now -ddump-cmm-*. Some were renamed to be more consistent. This doesn't update the manual; it already mentions '-ddump-cmm' and that flag implies all the others anyway, which is probably what you want. Signed-off-by: Austin Seipp <mad.one@gmail.com>
* replaceLabels: null out the cml_cont field of CmmCallSimon Marlow2012-11-121-1/+4
| | | | This fixes a CmmLint complaint when doing proc-point splitting.
* Attach global register liveness info to Cmm procedures.Geoffrey Mainland2012-10-301-9/+16
| | | | | | | All Cmm procedures now include the set of global registers that are live on procedure entry, i.e., the global registers used to pass arguments to the procedure. Only global registers that are use to pass arguments are included in this list.
* Avoid calling toInfoLbl on the entry label (#7313)Simon Marlow2012-10-231-20/+23
|
* Produce new-style Cmm from the Cmm parserSimon Marlow2012-10-081-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main change here is that the Cmm parser now allows high-level cmm code with argument-passing and function calls. For example: foo ( gcptr a, bits32 b ) { if (b > 0) { // we can make tail calls passing arguments: jump stg_ap_0_fast(a); } return (x,y); } More details on the new cmm syntax are in Note [Syntax of .cmm files] in CmmParse.y. The old syntax is still more-or-less supported for those occasional code fragments that really need to explicitly manipulate the stack. However there are a couple of differences: it is now obligatory to give a list of live GlobalRegs on every jump, e.g. jump %ENTRY_CODE(Sp(0)) [R1]; Again, more details in Note [Syntax of .cmm files]. I have rewritten most of the .cmm files in the RTS into the new syntax, except for AutoApply.cmm which is generated by the genapply program: this file could be generated in the new syntax instead and would probably be better off for it, but I ran out of enthusiasm. Some other changes in this batch: - The PrimOp calling convention is gone, primops now use the ordinary NativeNodeCall convention. This means that primops and "foreign import prim" code must be written in high-level cmm, but they can now take more than 10 arguments. - CmmSink now does constant-folding (should fix #7219) - .cmm files now go through the cmmPipeline, and as a result we generate better code in many cases. All the object files generated for the RTS .cmm files are now smaller. Performance should be better too, but I haven't measured it yet. - RET_DYN frames are removed from the RTS, lots of code goes away - we now have some more canned GC points to cover unboxed-tuples with 2-4 pointers, which will reduce code size a little.
* splitAtProcPoints: jump to the right place when tablesNextToCode == FalseSimon Marlow2012-09-201-11/+24
|
* New codegen: do not split proc-points when using the NCGSimon Marlow2012-07-301-6/+20
| | | | | | | | | Proc-point splitting is only required by backends that do not support having proc-points within a code block (that is, everything except the native backend, i.e. LLVM and C). Not doing proc-point splitting saves some compilation time, and might produce slightly better code in some cases.
* GHC 7.4 is now required for building HEADIan Lynagh2012-07-201-3/+0
|
* Fix build with GHC 7.0Ian Lynagh2012-07-131-0/+3
|
* Track liveness of GlobalRegs in the new code generatorSimon Marlow2012-07-091-2/+4
| | | | | | This gives the register allocator access to R1.., F1.., D1.. etc. for the new code generator, and is a cheap way to eliminate all the extra "x = R1" assignments that we get from copyIn.
* Remove "fuel", adapt to Hoopl changes, fix warningsSimon Marlow2012-07-051-12/+6
|
* Merge remote-tracking branch 'origin/master' into newcgSimon Marlow2012-07-041-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/master: (756 commits) don't crash if argv[0] == NULL (#7037) -package P was loading all versions of P in GHCi (#7030) Add a Note, copying text from #2437 improve the --help docs a bit (#7008) Copy Data.HashTable's hashString into our Util module Build fix Build fixes Parse error: suggest brackets and indentation. Don't build the ghc DLL on Windows; works around trac #5987 On Windows, detect if DLLs have too many symbols; trac #5987 Add some more Integer rules; fixes #6111 Fix PA dfun construction with silent superclass args Add silent superclass parameters to the vectoriser Add silent superclass parameters (again) Mention Generic1 in the user's guide Make the GHC API a little more powerful. tweak llvm version warning message New version of the patch for #5461. Fix Word64ToInteger conversion rule. Implemented feature request on reconfigurable pretty-printing in GHCi (#5461) ... Conflicts: compiler/basicTypes/UniqSupply.lhs compiler/cmm/CmmBuildInfoTables.hs compiler/cmm/CmmLint.hs compiler/cmm/CmmOpt.hs compiler/cmm/CmmPipeline.hs compiler/cmm/CmmStackLayout.hs compiler/cmm/MkGraph.hs compiler/cmm/OldPprCmm.hs compiler/codeGen/CodeGen.lhs compiler/codeGen/StgCmm.hs compiler/codeGen/StgCmmBind.hs compiler/codeGen/StgCmmLayout.hs compiler/codeGen/StgCmmUtils.hs compiler/main/CodeOutput.lhs compiler/main/HscMain.hs compiler/nativeGen/AsmCodeGen.lhs compiler/simplStg/SimplStg.lhs
| * Remove PlatformOutputableIan Lynagh2012-06-131-1/+1
| | | | | | | | | | We can now get the Platform from the DynFlags inside an SDoc, so we no longer need to pass the Platform in.
* | Remove dead code and optimise a bitSimon Marlow2012-03-151-205/+25
| |
* | Remove the old stack layout algorithmsSimon Marlow2012-03-151-1/+2
| | | | | | | | | | | | | | | | Also, do removeDeadAssignments instead of cmmLiveness before stack allocation, because the former also does liveness analysis, and we can do just one liveness analysis instead of two. The stack layout algorithm doesn't introduce any dead assignments, so this doesn't affect the generated code.
* | New stack layout algorithmSimon Marlow2012-02-081-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Also: - improvements to code generation: push slow-call continuations on the stack instead of generating explicit continuations - remove unused CmmInfo wrapper type (replace with CmmInfoTable) - squash Area and AreaId together, remove now-unused RegSlot - comment out old unused stack-allocation code that no longer compiles after removal of RegSlot
* | snapshot of latest improvementsSimon Marlow2012-01-231-1/+1
| |
* | implement RegSet by Set, not UniqSetSimon Marlow2012-01-201-1/+1
| |
* | SnapshotSimon Marlow2012-01-171-14/+16
| |
* | More codegen refactoring with simonpjSimon Marlow2011-12-191-36/+66
|/
* Remove some legacy codeIan Lynagh2011-10-201-11/+0
| | | | __GLASGOW_HASKELL__ >= 612 is now always true
* Renaming onlySimon Peyton Jones2011-08-251-1/+1
| | | | | CmmTop -> CmmDecl CmmPgm -> CmmGroup
* More refactoring (CgRep)Simon Peyton Jones2011-08-251-1/+0
| | | | | | * Move CgRep (private to old codgen) from SMRep to ClosureInfo * Avoid using CgRep in new codegen * Move SMRep and Bitmap from codeGen/ to cmm/
* Snapshot of codegen refactoring to share with simonpjSimon Marlow2011-08-251-5/+4
|
* Remove last use of entryLblToInfoLblMax Bolingbroke2011-07-291-6/+10
|
* Common up uses of entryLblToInfoLbl in CmmProcPointMax Bolingbroke2011-07-291-20/+21
|
* Put the info CLabel in CmmInfoTable rather than a localness flag, tidy up ↵Max Bolingbroke2011-07-281-1/+1
| | | | some info<->entry conversions
* More work towards cross-compilationIan Lynagh2011-07-151-6/+7
| | | | | | | | | | | | There's now a variant of the Outputable class that knows what platform we're targetting: class PlatformOutputable a where pprPlatform :: Platform -> a -> SDoc pprPlatformPrec :: Platform -> Rational -> a -> SDoc and various instances have had to be converted to use that class, and we pass Platform around accordingly.
* Remove type synonyms for CmmFormals, CmmActuals (and hinted versions).Edward Z. Yang2011-06-131-1/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Give manifestSP better information about the actual SP location.Edward Z. Yang2011-04-271-0/+2
| | | | | | | This patch fixes silliness where the SP pointer is continually bumped up and down. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Merge in new code generator branch.Simon Marlow2011-01-241-115/+556
| | | | | | | | | | | | | | | | | | | | | | | | | | This changes the new code generator to make use of the Hoopl package for dataflow analysis. Hoopl is a new boot package, and is maintained in a separate upstream git repository (as usual, GHC has its own lagging darcs mirror in http://darcs.haskell.org/packages/hoopl). During this merge I squashed recent history into one patch. I tried to rebase, but the history had some internal conflicts of its own which made rebase extremely confusing, so I gave up. The history I squashed was: - Update new codegen to work with latest Hoopl - Add some notes on new code gen to cmm-notes - Enable Hoopl lag package. - Add SPJ note to cmm-notes - Improve GC calls on new code generator. Work in this branch was done by: - Milan Straka <fox@ucw.cz> - John Dias <dias@cs.tufts.edu> - David Terei <davidterei@gmail.com> Edward Z. Yang <ezyang@mit.edu> merged in further changes from GHC HEAD and fixed a few bugs.
* Fix warnings in CmmProcPointIan Lynagh2008-12-291-10/+1
|
* Big collection of patches for the new codegen branch.dias@eecs.harvard.edu2008-10-131-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Fixed bug that emitted the copy-in code for closure entry in the wrong place -- at the initialization of the closure. o Refactored some of the closure entry code. o Added code to check that no LocalRegs are live-in to a procedure -- trip up some buggy programs earlier o Fixed environment bindings for thunks -- we weren't (re)binding the free variables in a thunk o Fixed a bug in proc-point splitting that dropped some updates to the entry block in a procedure. o Fixed improper calls to code that generates CmmLit's for strings o New invariant on cg_loc in CgIdInfo: the expression is always tagged o Code to load free vars on entry to a thunk was (wrongly) placed before the heap check. o Some of the StgCmm code was redundantly passing around Id's along with CgIdInfo's; no more. o Initialize the LocalReg's that point to a closure before allocating and initializing the closure itself -- otherwise, we have problems with recursive closure bindings o BlockEnv and BlockSet types are now abstract. o Update frames: - push arguments in Old call area - keep track of the return sp in the FCode monad - keep the return sp in every call, tail call, and return (because it might be different at different call sites, e.g. tail calls to the gc after a heap check are performed before pushing the update frame) - set the sp appropriately on returns and tail calls o Reduce call, tail call, and return to a single LastCall node o Added slow entry code, using different calling conventions on entry and tail call o More fixes to the calling convention code. The tricky stuff is all about the closure environment: it must be passed in R1, but in non-closures, there is no such argument, so we can't treat all arguments the same way: the closure environment is special. Maybe the right step forward would be to define a different calling convention for closure arguments. o Let-no-escapes need to be emitted out-of-line -- otherwise, we drop code. o Respect RTS requirement of word alignment for pointers My stack allocation can pack sub-word values into a single word on the stack, but it wasn't requiring word-alignment for pointers. It does now, by word-aligning both pointer registers and call areas. o CmmLint was over-aggresively ruling out non-word-aligned memory references, which may be kosher now that we can spill small values into a single word. o Wrong label order on a conditional branch when compiling switches. o void args weren't dropped in many cases. To help prevent this kind of mistake, I defined a NonVoid wrapper, which I'm applying only to Id's for now, although there are probably other good candidates. o A little code refactoring: separate modules for procpoint analysis splitting, stack layout, and building infotables. o Stack limit check: insert along with the heap limit check, using a symbolic constant (a special CmmLit), then replace it when the stack layout is known. o Removed last node: MidAddToContext o Adding block id as a literal: means that the lowering of the calling conventions no longer has to produce labels early, which was inhibiting common-block elimination. Will also make it easier for the non-procpoint-splitting path. o Info tables: don't try to describe the update frame! o Over aggressive use of NonVoid!!!! Don't drop the non-void args before setting the type of the closure!!! o Sanity checking: Added a pass to stub dead dead slots on the stack (only ~10 lines with the dataflow framework) o More sanity checking: Check that incoming pointer arguments are non-stubbed. Note: these checks are still subject to dead-code removal, but they should still be quite helpful. o Better sanity checking: why stop at function arguments? Instead, in mkAssign, check that _any_ assignment to a pointer type is non-null -- the sooner the crash, the easier it is to debug. Still need to add the debugging flag to turn these checks on explicitly. o Fixed yet another calling convention bug. This time, the calls to the GC were wrong. I've added a new convention for GC calls and invoked it where appropriate. We should really straighten out the calling convention stuff: some of the code (and documentation) is spread across the compiler, and there's some magical use of the node register that should really be handled (not avoided) by calling conventions. o Switch bug: the arms in mkCmmLitSwitch weren't returning to a single join point. o Environment shadowing problem in Stg->Cmm: When a closure f is bound at the top-level, we should not bind f to the node register on entry to the closure. Why? Because if the body of f contains a let-bound closure g that refers to f, we want to make sure that it refers to the static closure for f. Normally, this would all be fine, because when we compile a closure, we rebind free variables in the environment. But f doesn't look like a free variable because it's a static value. So, the binding for f remains in the environment when we compile g, inconveniently referring to the wrong thing. Now, I bind the variable in the local environment only if the closure is not bound at the top level. It's still okay to make assumptions about the node holding the closure environment; we just won't find the binding in the environment, so code that names the closure will now directly get the label of the static closure, not the node register holding a pointer to the static closure. o Don't generate bogus Cmm code containing SRTs during the STG -> Cmm pass! The tables made reference to some labels that don't exist when we compute and generate the tables in the back end. o Safe foreign calls need some special treatment (at least until we have the integrated codegen). In particular: o they need info tables o they are not procpoints -- the successor had better be in the same procedure o we cannot (yet) implement the calling conventions early, which means we have to carry the calling-conv info all the way to the end o We weren't following the old convention when registering a module. Now, we use update frames to push any new modules that have to be registered and enter the youngest one on the stack. We also use the update frame machinery to specify that the return should pop the return address off the stack. o At each safe foreign call, an infotable must be at the bottom of the stack, and the TSO->sp must point to it. o More problems with void args in a direct call to a function: We were checking the args (minus voids) to check whether the call was saturated, which caused problems when the function really wasn't saturated because it took an extra void argument. o Forgot to distinguish integer != from floating != during Stg->Cmm o Updating slotEnv and areaMap to include safe foreign calls The dataflow analyses that produce the slotEnv and areaMap give results for each basic block, but we also need the results for a safe foreign call, which is a middle node. After running the dataflow analysis, we have another pass that updates the results to includ any safe foreign calls. o Added a static flag for the debugging technique that inserts instructions to stub dead slots on the stack and crashes when a stubbed value is loaded into a pointer-typed LocalReg. o C back end expects to see return continuations before their call sites. Sorted the flowgraphs appropriately after splitting. o PrimOp calling conventions are special -- unlimited registers, no stack Yet another calling convention... o More void value problems: if the RHS of a case arm is a void-typed variable, don't try to return it. o When calling some primOp, they may allocate memory; if so, we need to do a heap check when we return from the call.
* Replacing copyins and copyouts with data-movement instructionsdias@eecs.harvard.edu2008-05-291-0/+1
| | | | | | | | | | | | | | o Moved BlockId stuff to a new file to avoid module recursion o Defined stack areas for parameter-passing locations and spill slots o Part way through replacing copy in and copy out nodes - added movement instructions for stack pointer - added movement instructions for call and return parameters (but not with the proper calling conventions) o Inserting spills and reloads for proc points is now procpoint-aware (it was relying on the presence of a CopyIn node as a proxy for procpoint knowledge) o Changed ZipDataflow to expect AGraphs (instead of being polymorphic in the type of graph)
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* Keep the CPS pass from creating proc points due to unreachable parents.Michael D. Adams2007-07-151-2/+6
| | | | | | | | | | | | The parser/flattener will generate an extra block after an if/else statement even if both branches exit the function. So it is possible for the input to the CPS pass to have dead/unreachable blocks. If a dead block goes to a live block then the live block would have more parents than the dead block and prior to this patch the live block would then be identified as a proc point. This is fixed by adding a check to see if the parent has at least one owner.
* Fix error message in CPS passMichael D. Adams2007-07-031-1/+1
|
* Multiple improvements to CPS algorithm.Michael D. Adams2007-07-021-1/+1
| | | | | | | | | | | | | | | These include: - Stack size detection now includes function arguments. - Stack size detection now avoids stack checks just because of the GC block. - A CmmCall followed by a CmmBranch will no longer generate an extra continuation consisting just of the brach. - Multiple CmmCall/CmmBranch pairs that all go to the same place will try to use the same continuation. If they can't (because the return value signature is different), adaptor block are built. - Function entry statements are now in a separate block. (Fixed bug with branches to the entry block having unintended effects.) - Other changes that I can't recall right now.
* Comment and formatting updates for the CPS passMichael D. Adams2007-06-281-32/+68
|
* Added stack checks to the CPS algorithmMichael D. Adams2007-06-271-1/+2
| | | | | | | | | | | | This eliminates one of the panics introduced by the previous patch: 'First pass at implementing info tables for CPS' The other panic introduced by that patch still remains. It was due to the need to convert from a ContinuationInfo to a CmmInfo. (codeGen/CgInfoTbls.hs:emitClosureCodeAndInfoTable) (codeGen/CgInfoTbls.hs:emitReturnTarget)
* First pass at implementing info tables for CPSMichael D. Adams2007-06-271-1/+1
| | | | | | | | | | | | | | | | This is a fairly complete implementation, however two 'panic's have been placed in the critical path where the implementation is still a bit lacking so do not expect it to run quite yet. One call to panic is because we still need to create a GC block for procedures that don't have them yet. (cmm/CmmCPS.hs:continuationToProc) The other is due to the need to convert from a ContinuationInfo to a CmmInfo. (codeGen/CgInfoTbls.hs:emitClosureCodeAndInfoTable) (codeGen/CgInfoTbls.hs:emitReturnTarget)
* Added an SRT to each CmmCall and added the current SRT to the CgMonadMichael D. Adams2007-06-271-1/+1
|
* Renamed CmmCPSData to CmmBrokenBlock and documented itMichael D. Adams2007-05-241-1/+1
|
* Factored proc-point analysis into separate file (compiler/cmm/CmmProcPoint)Michael D. Adams2007-05-231-0/+79