Changes between Version 25 and Version 26 of Commentary/Compiler/CodeGen
- Feb 1, 2014 5:32:30 PM (18 months ago)
v25 v26 32 32 The core of the Cmm pipeline is implemented by the `cpsTop` function in [[GhcFile(compiler/cmm/CmmPipeline.hs)]] module. The pipeline consists of following passes: 33 33 34 * ''' Simple control flow optimisation''', implemented in `CmmContFlowOpt`, simplifies the control flow graph by: 34 * '''''', implemented in `CmmContFlowOpt`, simplifies the control flow graph by: 35 35 * Eliminating blocks that have only one predecessor by concatenating them with that predecessor 36 36 * Shortcuting targets of branches and calls (see Note [What is shortcutting]) 37 Note that if a block becomes unreachable because of shortcutting it is eliminated from the graph. However, '''it is theoretically possible that this pass will produce unreachable blocks'''. The reason is the label renaming pass performed after block concatenation has been completed. 37 38 If a block becomes unreachable because of shortcutting it is eliminated from the graph. However, '''it is theoretically possible that this pass will produce unreachable blocks'''. The reason is the label renaming pass performed after block concatenation has been completed. 39 38 40 This pass might be optionally called for the second time at the end of the pipeline. 39 41 40 * '''More control flow optimisations'''. 41 * Common Block Elimination (like CSE). This essentially implements the Adams optimisation, we believe. 42 * Consider (sometime): block duplication. branch to K; and K is a short block. Branch chain elimination is just a special case of this. 42 * '''Common Block Elimination''', implemented in `CmmCommonBlockElim`, eliminates blocks that are identical (except for the label on their first node). Since this pass traverses blocks in depth-first order any unreachable blocks introduced by Control Flow Optimisations are eliminated. 43 43 44 * '''Proc-point analysis''' and '''transformation''', implemented in `CmmProcPoint`. The transformation part adds a function prologue to the front of each proc-point, following a standard entry convention. 45 * The analysis produces a set of `BlockId` that should become proc-points 46 * The transformation inserts a function prologue at the start of each proc-point, and a function epilogue just before each branch to a proc-point. 47 48 * '''Remove dead assignments and stores''', implemented in `CmmLive`, removes assignments to dead variables and things like ``a = a`` or ``I32[Hp] = I32[Hp]``. The latter may more appropriately be done in a general optimization pass, as it doesn't take advantage of liveness information. 44 * '''Determine proc-points''', implemented in `CmmProcPoint`. Proc-point analysis is done only when proc-point splitting is turned on. This is important for the LLVM backend. Proc-point are blocks in the graph that can be turned into entry points of procedures and proc-point splitting splits one function into many smaller ones. Initially we assume that entry point to a graph as well as continuation of every call is a proc-point. Then we look for blocks reachable from multiple proc-points and turn such blocks into a proc-point. 49 45 50 46 * '''Figure out the stack layout''', implemented in `CmmStackLayout`.