LLVM API Documentation
00001 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This header file defines prototypes for accessor functions that expose passes 00011 // in the IPO transformations library. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_TRANSFORMS_IPO_H 00016 #define LLVM_TRANSFORMS_IPO_H 00017 00018 #include <vector> 00019 00020 namespace llvm { 00021 00022 class FunctionPass; 00023 class ModulePass; 00024 class Pass; 00025 class Function; 00026 class BasicBlock; 00027 class GlobalValue; 00028 00029 //===----------------------------------------------------------------------===// 00030 // 00031 // These functions removes symbols from functions and modules. If OnlyDebugInfo 00032 // is true, only debugging information is removed from the module. 00033 // 00034 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false); 00035 00036 //===----------------------------------------------------------------------===// 00037 // 00038 // These functions strips symbols from functions and modules. 00039 // Only debugging information is not stripped. 00040 // 00041 ModulePass *createStripNonDebugSymbolsPass(); 00042 00043 //===----------------------------------------------------------------------===// 00044 // 00045 // These pass removes llvm.dbg.declare intrinsics. 00046 ModulePass *createStripDebugDeclarePass(); 00047 00048 //===----------------------------------------------------------------------===// 00049 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics 00050 /// to invoke/unwind instructions. This should really be part of the C/C++ 00051 /// front-end, but it's so much easier to write transformations in LLVM proper. 00052 /// 00053 ModulePass *createLowerSetJmpPass(); 00054 00055 //===----------------------------------------------------------------------===// 00056 /// createConstantMergePass - This function returns a new pass that merges 00057 /// duplicate global constants together into a single constant that is shared. 00058 /// This is useful because some passes (ie TraceValues) insert a lot of string 00059 /// constants into the program, regardless of whether or not they duplicate an 00060 /// existing string. 00061 /// 00062 ModulePass *createConstantMergePass(); 00063 00064 00065 //===----------------------------------------------------------------------===// 00066 /// createGlobalOptimizerPass - This function returns a new pass that optimizes 00067 /// non-address taken internal globals. 00068 /// 00069 ModulePass *createGlobalOptimizerPass(); 00070 00071 00072 //===----------------------------------------------------------------------===// 00073 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and 00074 /// free function calls into malloc and free instructions. 00075 /// 00076 ModulePass *createRaiseAllocationsPass(); 00077 00078 00079 //===----------------------------------------------------------------------===// 00080 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol 00081 /// table entries for types that are never used. 00082 /// 00083 ModulePass *createDeadTypeEliminationPass(); 00084 00085 00086 //===----------------------------------------------------------------------===// 00087 /// createGlobalDCEPass - This transform is designed to eliminate unreachable 00088 /// internal globals (functions or global variables) 00089 /// 00090 ModulePass *createGlobalDCEPass(); 00091 00092 00093 //===----------------------------------------------------------------------===// 00094 /// createGVExtractionPass - If deleteFn is true, this pass deletes as 00095 /// the specified global values. Otherwise, it deletes as much of the module as 00096 /// possible, except for the global values specified. 00097 /// 00098 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool 00099 deleteFn = false, 00100 bool relinkCallees = false); 00101 00102 //===----------------------------------------------------------------------===// 00103 /// createFunctionInliningPass - Return a new pass object that uses a heuristic 00104 /// to inline direct function calls to small functions. 00105 /// 00106 Pass *createFunctionInliningPass(); 00107 Pass *createFunctionInliningPass(int Threshold); 00108 00109 //===----------------------------------------------------------------------===// 00110 /// createAlwaysInlinerPass - Return a new pass object that inlines only 00111 /// functions that are marked as "always_inline". 00112 Pass *createAlwaysInlinerPass(); 00113 00114 //===----------------------------------------------------------------------===// 00115 /// createPruneEHPass - Return a new pass object which transforms invoke 00116 /// instructions into calls, if the callee can _not_ unwind the stack. 00117 /// 00118 Pass *createPruneEHPass(); 00119 00120 //===----------------------------------------------------------------------===// 00121 /// createInternalizePass - This pass loops over all of the functions in the 00122 /// input module, internalizing all globals (functions and variables) not part 00123 /// of the api. If a list of symbols is specified with the 00124 /// -internalize-public-api-* command line options, those symbols are not 00125 /// internalized and all others are. Otherwise if AllButMain is set and the 00126 /// main function is found, all other globals are marked as internal. If no api 00127 /// is supplied and AllButMain is not set, or no main function is found, nothing 00128 /// is internalized. 00129 /// 00130 ModulePass *createInternalizePass(bool AllButMain); 00131 00132 /// createInternalizePass - This pass loops over all of the functions in the 00133 /// input module, internalizing all globals (functions and variables) not in the 00134 /// given exportList. 00135 /// 00136 /// Note that commandline options that are used with the above function are not 00137 /// used now! Also, when exportList is empty, nothing is internalized. 00138 ModulePass *createInternalizePass(const std::vector<const char *> &exportList); 00139 00140 //===----------------------------------------------------------------------===// 00141 /// createDeadArgEliminationPass - This pass removes arguments from functions 00142 /// which are not used by the body of the function. 00143 /// 00144 ModulePass *createDeadArgEliminationPass(); 00145 00146 /// DeadArgHacking pass - Same as DAE, but delete arguments of external 00147 /// functions as well. This is definitely not safe, and should only be used by 00148 /// bugpoint. 00149 ModulePass *createDeadArgHackingPass(); 00150 00151 //===----------------------------------------------------------------------===// 00152 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to 00153 /// be passed by value if the number of elements passed is smaller or 00154 /// equal to maxElements (maxElements == 0 means always promote). 00155 /// 00156 Pass *createArgumentPromotionPass(unsigned maxElements = 3); 00157 Pass *createStructRetPromotionPass(); 00158 00159 //===----------------------------------------------------------------------===// 00160 /// createIPConstantPropagationPass - This pass propagates constants from call 00161 /// sites into the bodies of functions. 00162 /// 00163 ModulePass *createIPConstantPropagationPass(); 00164 00165 //===----------------------------------------------------------------------===// 00166 /// createIPSCCPPass - This pass propagates constants from call sites into the 00167 /// bodies of functions, and keeps track of whether basic blocks are executable 00168 /// in the process. 00169 /// 00170 ModulePass *createIPSCCPPass(); 00171 00172 //===----------------------------------------------------------------------===// 00173 // 00174 /// createLoopExtractorPass - This pass extracts all natural loops from the 00175 /// program into a function if it can. 00176 /// 00177 FunctionPass *createLoopExtractorPass(); 00178 00179 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the 00180 /// program into a function if it can. This is used by bugpoint. 00181 /// 00182 FunctionPass *createSingleLoopExtractorPass(); 00183 00184 /// createBlockExtractorPass - This pass extracts all blocks (except those 00185 /// specified in the argument list) from the functions in the module. 00186 /// 00187 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE); 00188 00189 /// createIndMemRemPass - This pass removes potential indirect calls of 00190 /// malloc and free 00191 ModulePass *createIndMemRemPass(); 00192 00193 /// createStripDeadPrototypesPass - This pass removes any function declarations 00194 /// (prototypes) that are not used. 00195 ModulePass *createStripDeadPrototypesPass(); 00196 00197 //===----------------------------------------------------------------------===// 00198 /// createPartialSpecializationPass - This pass specializes functions for 00199 /// constant arguments. 00200 /// 00201 ModulePass *createPartialSpecializationPass(); 00202 00203 //===----------------------------------------------------------------------===// 00204 /// createFunctionAttrsPass - This pass discovers functions that do not access 00205 /// memory, or only read memory, and gives them the readnone/readonly attribute. 00206 /// It also discovers function arguments that are not captured by the function 00207 /// and marks them with the nocapture attribute. 00208 /// 00209 Pass *createFunctionAttrsPass(); 00210 00211 //===----------------------------------------------------------------------===// 00212 /// createMergeFunctionsPass - This pass discovers identical functions and 00213 /// collapses them. 00214 /// 00215 ModulePass *createMergeFunctionsPass(); 00216 00217 //===----------------------------------------------------------------------===// 00218 /// createPartialInliningPass - This pass inlines parts of functions. 00219 /// 00220 ModulePass *createPartialInliningPass(); 00221 00222 } // End llvm namespace 00223 00224 #endif