LLVM API Documentation

IPO.h

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