FunctionPass

public enum FunctionPass

A subset of supported LLVM IR optimizer passes.

  • This pass uses the SSA based Aggressive DCE algorithm. This algorithm assumes instructions are dead until proven otherwise, which makes it more successful are removing non-obviously dead instructions.

    Declaration

    Swift

    case aggressiveDCE
  • This pass uses a bit-tracking DCE algorithm in order to remove computations of dead bits.

    Declaration

    Swift

    case bitTrackingDCE
  • Use assume intrinsics to set load/store alignments.

    Declaration

    Swift

    case alignmentFromAssumptions
  • Merge basic blocks, eliminate unreachable blocks, simplify terminator instructions, etc.

    Declaration

    Swift

    case cfgSimplification
  • This pass deletes stores that are post-dominated by must-aliased stores and are not loaded used between the stores.

    Declaration

    Swift

    case deadStoreElimination
  • Converts vector operations into scalar operations.

    Declaration

    Swift

    case scalarizer
  • This pass merges loads and stores in diamonds. Loads are hoisted into the header, while stores sink into the footer.

    Declaration

    Swift

    case mergedLoadStoreMotion
  • gvn

    This pass performs global value numbering and redundant load elimination cotemporaneously.

    Declaration

    Swift

    case gvn
  • Transform induction variables in a program to all use a single canonical induction variable per loop.

    Declaration

    Swift

    case indVarSimplify
  • Combine instructions to form fewer, simple instructions. This pass does not modify the CFG, and has a tendency to make instructions dead, so a subsequent DCE pass is useful.

    This pass combines things like:

    %Y = add int 1, %X
    %Z = add int 1, %Y
    

    into:

    %Z = add int 2, %X
    

    Declaration

    Swift

    case instructionCombining
  • Thread control through mult-pred/multi-succ blocks where some preds always go to some succ. Thresholds other than minus one override the internal BB duplication default threshold.

    Declaration

    Swift

    case jumpThreading
  • This pass is a loop invariant code motion and memory promotion pass.

    Declaration

    Swift

    case licm
  • This pass performs DCE of non-infinite loops that it can prove are dead.

    Declaration

    Swift

    case loopDeletion
  • This pass recognizes and replaces idioms in loops.

    Declaration

    Swift

    case loopIdiom
  • This pass is a simple loop rotating pass.

    Declaration

    Swift

    case loopRotate
  • This pass is a simple loop rerolling pass.

    Declaration

    Swift

    case loopReroll
  • This pass is a simple loop unrolling pass.

    Declaration

    Swift

    case loopUnroll
  • This pass is a simple loop unswitching pass.

    Declaration

    Swift

    case loopUnswitch
  • This pass performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset’s.

    Declaration

    Swift

    case memCpyOpt
  • Tries to inline the fast path of library calls such as sqrt.

    Declaration

    Swift

    case partiallyInlineLibCalls
  • This pass converts SwitchInst instructions into a sequence of chained binary branch instructions.

    Declaration

    Swift

    case lowerSwitch
  • This pass is used to promote memory references to be register references. A simple example of the transformation performed by this pass is going from code like this:

    %X = alloca i32, i32 1
    store i32 42, i32 *%X
    %Y = load i32* %X
    ret i32 %Y
    

    To code like this:

    ret i32 42
    

    Declaration

    Swift

    case promoteMemoryToRegister
  • This pass reassociates commutative expressions in an order that is designed to promote better constant propagation, GCSE, LICM, PRE, etc.

    For example:

    4 + (x + 5)  ->  x + (4 + 5)
    

    Declaration

    Swift

    case reassociate
  • Sparse conditional constant propagation.

    Declaration

    Swift

    case sccp
  • Replace aggregates or pieces of aggregates with scalar SSA values.

    Declaration

    Swift

    case scalarReplAggregates
  • Replace aggregates or pieces of aggregates with scalar SSA values.

    Declaration

    Swift

    case scalarReplAggregatesSSA
  • Tries to inline the fast path of library calls such as sqrt.

    Declaration

    Swift

    case simplifyLibCalls
  • This pass eliminates call instructions to the current function which occur immediately before return instructions.

    Declaration

    Swift

    case tailCallElimination
  • A worklist driven constant propagation pass.

    Declaration

    Swift

    case constantPropagation
  • This pass is used to demote registers to memory references. It basically undoes the .promoteMemoryToRegister pass to make CFG hacking easier.

    Declaration

    Swift

    case demoteMemoryToRegister
  • Propagate CFG-derived value information

    Declaration

    Swift

    case correlatedValuePropagation
  • This pass performs a simple and fast CSE pass over the dominator tree.

    Declaration

    Swift

    case earlyCSE
  • Removes llvm.expect intrinsics and creates block_weights metadata.

    Declaration

    Swift

    case lowerExpectIntrinsic
  • Adds metadata to LLVM IR types and performs metadata-based TBAA.

    Declaration

    Swift

    case typeBasedAliasAnalysis
  • Adds metadata to LLVM IR types and performs metadata-based scoped no-alias analysis.

    Declaration

    Swift

    case scopedNoAliasAA
  • LLVM’s primary stateless and local alias analysis.

    Declaration

    Swift

    case basicAliasAnalysis
  • Runs the LLVM IR Verifier to sanity check the results of passes.

    Declaration

    Swift

    case verifier
  • A pass to inline and remove functions marked as always_inline.

    Declaration

    Swift

    case alwaysInliner
  • This pass promotes by reference arguments to be passed by value if the number of elements passed is less than or equal to 3.

    Declaration

    Swift

    case argumentPromotion
  • This function returns a new pass that merges duplicate global constants together into a single constant that is shared. This is useful because some passes (ie TraceValues) insert a lot of string constants into the program, regardless of whether or not they duplicate an existing string.

    Declaration

    Swift

    case constantMerge
  • This pass removes arguments from functions which are not used by the body of the function.

    Declaration

    Swift

    case deadArgElimination
  • This pass walks SCCs of the call graph in RPO to deduce and propagate function attributes. Currently it only handles synthesizing norecurse attributes.

    Declaration

    Swift

    case functionAttrs
  • Uses a heuristic to inline direct function calls to small functions.

    Declaration

    Swift

    case functionInlining
  • This transform is designed to eliminate unreachable internal globals (functions or global variables)

    Declaration

    Swift

    case globalDCE
  • This function returns a new pass that optimizes non-address taken internal globals.

    Declaration

    Swift

    case globalOptimizer
  • This pass propagates constants from call sites into the bodies of functions.

    Declaration

    Swift

    case ipConstantPropagation
  • This pass propagates constants from call sites into the bodies of functions, and keeps track of whether basic blocks are executable in the process.

    Declaration

    Swift

    case ipscc
  • Return a new pass object which transforms invoke instructions into calls, if the callee can not unwind the stack.

    Declaration

    Swift

    case pruneEH
  • This pass removes any function declarations (prototypes) that are not used.

    Declaration

    Swift

    case stripDeadPrototypes
  • These functions removes symbols from functions and modules without touching symbols for debugging information.

    Declaration

    Swift

    case stripSymbols
  • Performs a loop vectorization pass to widen instructions in loops to operate on multiple consecutive iterations.

    Declaration

    Swift

    case loopVectorize
  • This pass performs a superword-level parallelism pass to combine similar independent instructions into vector instructions.

    Declaration

    Swift

    case slpVectorize