Home | History | Annotate | Download | only in Transforms
      1 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This header file defines prototypes for accessor functions that expose passes
     11 // in the IPO transformations library.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_TRANSFORMS_IPO_H
     16 #define LLVM_TRANSFORMS_IPO_H
     17 
     18 #include <functional>
     19 #include <vector>
     20 
     21 namespace llvm {
     22 
     23 class StringRef;
     24 class ModuleSummaryIndex;
     25 class ModulePass;
     26 class Pass;
     27 class Function;
     28 class BasicBlock;
     29 class GlobalValue;
     30 
     31 //===----------------------------------------------------------------------===//
     32 //
     33 // These functions removes symbols from functions and modules.  If OnlyDebugInfo
     34 // is true, only debugging information is removed from the module.
     35 //
     36 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
     37 
     38 //===----------------------------------------------------------------------===//
     39 //
     40 // These functions strips symbols from functions and modules.
     41 // Only debugging information is not stripped.
     42 //
     43 ModulePass *createStripNonDebugSymbolsPass();
     44 
     45 //===----------------------------------------------------------------------===//
     46 //
     47 // These pass removes llvm.dbg.declare intrinsics.
     48 ModulePass *createStripDebugDeclarePass();
     49 
     50 //===----------------------------------------------------------------------===//
     51 //
     52 // These pass removes unused symbols' debug info.
     53 ModulePass *createStripDeadDebugInfoPass();
     54 
     55 //===----------------------------------------------------------------------===//
     56 /// createConstantMergePass - This function returns a new pass that merges
     57 /// duplicate global constants together into a single constant that is shared.
     58 /// This is useful because some passes (ie TraceValues) insert a lot of string
     59 /// constants into the program, regardless of whether or not they duplicate an
     60 /// existing string.
     61 ///
     62 ModulePass *createConstantMergePass();
     63 
     64 //===----------------------------------------------------------------------===//
     65 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
     66 /// non-address taken internal globals.
     67 ///
     68 ModulePass *createGlobalOptimizerPass();
     69 
     70 //===----------------------------------------------------------------------===//
     71 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
     72 /// internal globals (functions or global variables)
     73 ///
     74 ModulePass *createGlobalDCEPass();
     75 
     76 //===----------------------------------------------------------------------===//
     77 /// This transform is designed to eliminate available external globals
     78 /// (functions or global variables)
     79 ///
     80 ModulePass *createEliminateAvailableExternallyPass();
     81 
     82 //===----------------------------------------------------------------------===//
     83 /// createGVExtractionPass - If deleteFn is true, this pass deletes
     84 /// the specified global values. Otherwise, it deletes as much of the module as
     85 /// possible, except for the global values specified.
     86 ///
     87 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
     88                                    deleteFn = false);
     89 
     90 //===----------------------------------------------------------------------===//
     91 /// This pass performs iterative function importing from other modules.
     92 Pass *createFunctionImportPass(const ModuleSummaryIndex *Index = nullptr);
     93 
     94 //===----------------------------------------------------------------------===//
     95 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
     96 /// to inline direct function calls to small functions.
     97 ///
     98 /// The Threshold can be passed directly, or asked to be computed from the
     99 /// given optimization and size optimization arguments.
    100 ///
    101 /// The -inline-threshold command line option takes precedence over the
    102 /// threshold given here.
    103 Pass *createFunctionInliningPass();
    104 Pass *createFunctionInliningPass(int Threshold);
    105 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
    106 
    107 //===----------------------------------------------------------------------===//
    108 /// createAlwaysInlinerPass - Return a new pass object that inlines only
    109 /// functions that are marked as "always_inline".
    110 Pass *createAlwaysInlinerPass();
    111 Pass *createAlwaysInlinerPass(bool InsertLifetime);
    112 
    113 //===----------------------------------------------------------------------===//
    114 /// createPruneEHPass - Return a new pass object which transforms invoke
    115 /// instructions into calls, if the callee can _not_ unwind the stack.
    116 ///
    117 Pass *createPruneEHPass();
    118 
    119 //===----------------------------------------------------------------------===//
    120 /// createInternalizePass - This pass loops over all of the functions in the
    121 /// input module, internalizing all globals (functions and variables) it can.
    122 ////
    123 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
    124 /// gives to the client the ability to prevent internalizing specific symbols.
    125 ///
    126 /// The symbol in DSOList are internalized if it is safe to drop them from
    127 /// the symbol table.
    128 ///
    129 /// Note that commandline options that are used with the above function are not
    130 /// used now!
    131 ModulePass *
    132 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
    133 
    134 /// createInternalizePass - Same as above, but with an empty exportList.
    135 ModulePass *createInternalizePass();
    136 
    137 //===----------------------------------------------------------------------===//
    138 /// createDeadArgEliminationPass - This pass removes arguments from functions
    139 /// which are not used by the body of the function.
    140 ///
    141 ModulePass *createDeadArgEliminationPass();
    142 
    143 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
    144 /// functions as well.  This is definitely not safe, and should only be used by
    145 /// bugpoint.
    146 ModulePass *createDeadArgHackingPass();
    147 
    148 //===----------------------------------------------------------------------===//
    149 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
    150 /// be passed by value if the number of elements passed is smaller or
    151 /// equal to maxElements (maxElements == 0 means always promote).
    152 ///
    153 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
    154 
    155 //===----------------------------------------------------------------------===//
    156 /// createIPConstantPropagationPass - This pass propagates constants from call
    157 /// sites into the bodies of functions.
    158 ///
    159 ModulePass *createIPConstantPropagationPass();
    160 
    161 //===----------------------------------------------------------------------===//
    162 /// createIPSCCPPass - This pass propagates constants from call sites into the
    163 /// bodies of functions, and keeps track of whether basic blocks are executable
    164 /// in the process.
    165 ///
    166 ModulePass *createIPSCCPPass();
    167 
    168 //===----------------------------------------------------------------------===//
    169 //
    170 /// createLoopExtractorPass - This pass extracts all natural loops from the
    171 /// program into a function if it can.
    172 ///
    173 Pass *createLoopExtractorPass();
    174 
    175 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
    176 /// program into a function if it can.  This is used by bugpoint.
    177 ///
    178 Pass *createSingleLoopExtractorPass();
    179 
    180 /// createBlockExtractorPass - This pass extracts all blocks (except those
    181 /// specified in the argument list) from the functions in the module.
    182 ///
    183 ModulePass *createBlockExtractorPass();
    184 
    185 /// createStripDeadPrototypesPass - This pass removes any function declarations
    186 /// (prototypes) that are not used.
    187 ModulePass *createStripDeadPrototypesPass();
    188 
    189 //===----------------------------------------------------------------------===//
    190 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
    191 /// graph in RPO to deduce and propagate function attributes. Currently it
    192 /// only handles synthesizing norecurse attributes.
    193 ///
    194 Pass *createReversePostOrderFunctionAttrsPass();
    195 
    196 //===----------------------------------------------------------------------===//
    197 /// createMergeFunctionsPass - This pass discovers identical functions and
    198 /// collapses them.
    199 ///
    200 ModulePass *createMergeFunctionsPass();
    201 
    202 //===----------------------------------------------------------------------===//
    203 /// createPartialInliningPass - This pass inlines parts of functions.
    204 ///
    205 ModulePass *createPartialInliningPass();
    206 
    207 //===----------------------------------------------------------------------===//
    208 // createMetaRenamerPass - Rename everything with metasyntatic names.
    209 //
    210 ModulePass *createMetaRenamerPass();
    211 
    212 //===----------------------------------------------------------------------===//
    213 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
    214 /// manager.
    215 ModulePass *createBarrierNoopPass();
    216 
    217 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
    218 /// bitsets.
    219 ModulePass *createLowerTypeTestsPass();
    220 
    221 /// \brief This pass export CFI checks for use by external modules.
    222 ModulePass *createCrossDSOCFIPass();
    223 
    224 /// \brief This pass implements whole-program devirtualization using type
    225 /// metadata.
    226 ModulePass *createWholeProgramDevirtPass();
    227 
    228 //===----------------------------------------------------------------------===//
    229 // SampleProfilePass - Loads sample profile data from disk and generates
    230 // IR metadata to reflect the profile.
    231 ModulePass *createSampleProfileLoaderPass();
    232 ModulePass *createSampleProfileLoaderPass(StringRef Name);
    233 
    234 } // End llvm namespace
    235 
    236 #endif
    237