Freigeben über


What do c2 Phases do?

On the Forums, someone asked the good question of "What do the C2 phases actually do?"  Andy got some info from our documentation team about the phases, so I thought I'd also add them here.  Expect this info in future version of the SDK:

 

Phase

Phase Action

CxxIL Reader

Converts CxxIL to Phoenix IR.

Warnings Analysis Detection Phase

Detects and emits back-end warnings (C4700, C4701, and so on).

Add CallGraph Call Site Information

Modifies call graph (if present) to refer to specific call sites within the function.

Inliner

Inlines functions.

Type Checker

Verifies that IR is correctly typed.

Flow Optimization

Streamlines control flow (for example, eliminates jumps to jumps).

MIR Lower

Lowers object model instructions.

Loop recognition and loop transformations

Performs basic loop restructuring.

Global optimization

Performs optimizations such as constant propagation, global value numbering, constant subexpression elimination, and dead code elimination.

Loop optimizations

Recognizes induction variables for strength reduction and loop-invariant code motion.

GS Shadow Copying

Implements the /GS option (stack security).

GS Security Cookie Allocation

Implements the /GS option (stack security).

X86 scalar Sse

Prepares the compiler to use SSE floating point instead of x87 floating point.

Canonicalize

Transforms IR to canonical form in preparation for lowering.

ShiftExpansion Strength Reduction

Transform multiplications and divisions by constants into shifts and additions.

Address Mode Builder

Transforms HIR/MIR to take advantage of target architecture's built-in addressing modes.

Lower

Lowers most instructions to machine level.

SSA-based idioms optimization phase

Performs classic "peephole" optimizations.

Priority Order Register Allocation

Assigns registers to operands.

X87 Stack Allocation

Allocates the x87 stack.

GS Security Cookie Initialization and Check

Implements the /GS option (stack security).

Native EH Lower

Expresses exception handling the way that the run-time convention expects.

Stack Packer

Assigns stack locations to operands.

Frame Generation

Determines shape of stack frame for the function.

Switch Lower

Lowers switch instructions.

Dead Stores

Removes dead stores (that is, stores that are guaranteed not to be read).

Block Layout

Places IR in final order.

Flow Optimization

Removes jump-to-jump and jump-to-next instructions.

Finish EH Lower

Finishes the process begun by Native EH Lower.

Encoding

Produces machine encoding for IR, and debug information.

Emission

Puts encoded IR into the object file.

Emit Referenced Symbols

Verifies the references made from the encoded IR to ensure that the compiler emits a fully closed set of functions and data.

Assembly Listing

Produces the .asm listing file.