LLVM  mainline
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 "llvm/ADT/ArrayRef.h"
00019 #include "llvm/ADT/StringRef.h"
00020 
00021 namespace llvm {
00022 
00023 class FunctionInfoIndex;
00024 class ModulePass;
00025 class Pass;
00026 class Function;
00027 class BasicBlock;
00028 class GlobalValue;
00029 
00030 //===----------------------------------------------------------------------===//
00031 //
00032 // These functions removes symbols from functions and modules.  If OnlyDebugInfo
00033 // is true, only debugging information is removed from the module.
00034 //
00035 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
00036 
00037 //===----------------------------------------------------------------------===//
00038 //
00039 // These functions strips symbols from functions and modules.
00040 // Only debugging information is not stripped.
00041 //
00042 ModulePass *createStripNonDebugSymbolsPass();
00043 
00044 //===----------------------------------------------------------------------===//
00045 //
00046 // These pass removes llvm.dbg.declare intrinsics.
00047 ModulePass *createStripDebugDeclarePass();
00048 
00049 //===----------------------------------------------------------------------===//
00050 //
00051 // These pass removes unused symbols' debug info.
00052 ModulePass *createStripDeadDebugInfoPass();
00053 
00054 //===----------------------------------------------------------------------===//
00055 /// createConstantMergePass - This function returns a new pass that merges
00056 /// duplicate global constants together into a single constant that is shared.
00057 /// This is useful because some passes (ie TraceValues) insert a lot of string
00058 /// constants into the program, regardless of whether or not they duplicate an
00059 /// existing string.
00060 ///
00061 ModulePass *createConstantMergePass();
00062 
00063 //===----------------------------------------------------------------------===//
00064 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
00065 /// non-address taken internal globals.
00066 ///
00067 ModulePass *createGlobalOptimizerPass();
00068 
00069 //===----------------------------------------------------------------------===//
00070 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
00071 /// internal globals (functions or global variables)
00072 ///
00073 ModulePass *createGlobalDCEPass();
00074 
00075 //===----------------------------------------------------------------------===//
00076 /// This transform is designed to eliminate available external globals
00077 /// (functions or global variables)
00078 ///
00079 ModulePass *createEliminateAvailableExternallyPass();
00080 
00081 //===----------------------------------------------------------------------===//
00082 /// createGVExtractionPass - If deleteFn is true, this pass deletes
00083 /// the specified global values. Otherwise, it deletes as much of the module as
00084 /// possible, except for the global values specified.
00085 ///
00086 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
00087                                    deleteFn = false);
00088 
00089 //===----------------------------------------------------------------------===//
00090 /// This pass performs iterative function importing from other modules.
00091 Pass *createFunctionImportPass(const FunctionInfoIndex *Index = nullptr);
00092 
00093 //===----------------------------------------------------------------------===//
00094 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
00095 /// to inline direct function calls to small functions.
00096 ///
00097 /// The Threshold can be passed directly, or asked to be computed from the
00098 /// given optimization and size optimization arguments.
00099 ///
00100 /// The -inline-threshold command line option takes precedence over the
00101 /// threshold given here.
00102 Pass *createFunctionInliningPass();
00103 Pass *createFunctionInliningPass(int Threshold);
00104 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
00105 
00106 //===----------------------------------------------------------------------===//
00107 /// createAlwaysInlinerPass - Return a new pass object that inlines only
00108 /// functions that are marked as "always_inline".
00109 Pass *createAlwaysInlinerPass();
00110 Pass *createAlwaysInlinerPass(bool InsertLifetime);
00111 
00112 //===----------------------------------------------------------------------===//
00113 /// createPruneEHPass - Return a new pass object which transforms invoke
00114 /// instructions into calls, if the callee can _not_ unwind the stack.
00115 ///
00116 Pass *createPruneEHPass();
00117 
00118 //===----------------------------------------------------------------------===//
00119 /// createInternalizePass - This pass loops over all of the functions in the
00120 /// input module, internalizing all globals (functions and variables) it can.
00121 ////
00122 /// The symbols in \p ExportList are never internalized.
00123 ///
00124 /// The symbol in DSOList are internalized if it is safe to drop them from
00125 /// the symbol table.
00126 ///
00127 /// Note that commandline options that are used with the above function are not
00128 /// used now!
00129 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
00130 /// createInternalizePass - Same as above, but with an empty exportList.
00131 ModulePass *createInternalizePass();
00132 
00133 //===----------------------------------------------------------------------===//
00134 /// createDeadArgEliminationPass - This pass removes arguments from functions
00135 /// which are not used by the body of the function.
00136 ///
00137 ModulePass *createDeadArgEliminationPass();
00138 
00139 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
00140 /// functions as well.  This is definitely not safe, and should only be used by
00141 /// bugpoint.
00142 ModulePass *createDeadArgHackingPass();
00143 
00144 //===----------------------------------------------------------------------===//
00145 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
00146 /// be passed by value if the number of elements passed is smaller or
00147 /// equal to maxElements (maxElements == 0 means always promote).
00148 ///
00149 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
00150 
00151 //===----------------------------------------------------------------------===//
00152 /// createIPConstantPropagationPass - This pass propagates constants from call
00153 /// sites into the bodies of functions.
00154 ///
00155 ModulePass *createIPConstantPropagationPass();
00156 
00157 //===----------------------------------------------------------------------===//
00158 /// createIPSCCPPass - This pass propagates constants from call sites into the
00159 /// bodies of functions, and keeps track of whether basic blocks are executable
00160 /// in the process.
00161 ///
00162 ModulePass *createIPSCCPPass();
00163 
00164 //===----------------------------------------------------------------------===//
00165 //
00166 /// createLoopExtractorPass - This pass extracts all natural loops from the
00167 /// program into a function if it can.
00168 ///
00169 Pass *createLoopExtractorPass();
00170 
00171 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
00172 /// program into a function if it can.  This is used by bugpoint.
00173 ///
00174 Pass *createSingleLoopExtractorPass();
00175 
00176 /// createBlockExtractorPass - This pass extracts all blocks (except those
00177 /// specified in the argument list) from the functions in the module.
00178 ///
00179 ModulePass *createBlockExtractorPass();
00180 
00181 /// createStripDeadPrototypesPass - This pass removes any function declarations
00182 /// (prototypes) that are not used.
00183 ModulePass *createStripDeadPrototypesPass();
00184 
00185 //===----------------------------------------------------------------------===//
00186 /// createPostOrderFunctionAttrsPass - This pass walks SCCs of the call graph
00187 /// in post-order to deduce and propagate function attributes. It can discover
00188 /// functions that do not access memory, or only read memory, and give them the
00189 /// readnone/readonly attribute. It also discovers function arguments that are
00190 /// not captured by the function and marks them with the nocapture attribute.
00191 ///
00192 Pass *createPostOrderFunctionAttrsPass();
00193 
00194 //===----------------------------------------------------------------------===//
00195 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
00196 /// graph in RPO to deduce and propagate function attributes. Currently it
00197 /// only handles synthesizing norecurse attributes.
00198 ///
00199 Pass *createReversePostOrderFunctionAttrsPass();
00200 
00201 //===----------------------------------------------------------------------===//
00202 /// createMergeFunctionsPass - This pass discovers identical functions and
00203 /// collapses them.
00204 ///
00205 ModulePass *createMergeFunctionsPass();
00206 
00207 //===----------------------------------------------------------------------===//
00208 /// createPartialInliningPass - This pass inlines parts of functions.
00209 ///
00210 ModulePass *createPartialInliningPass();
00211 
00212 //===----------------------------------------------------------------------===//
00213 // createMetaRenamerPass - Rename everything with metasyntatic names.
00214 //
00215 ModulePass *createMetaRenamerPass();
00216 
00217 //===----------------------------------------------------------------------===//
00218 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
00219 /// manager.
00220 ModulePass *createBarrierNoopPass();
00221 
00222 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
00223 /// to bitsets.
00224 ModulePass *createLowerBitSetsPass();
00225 
00226 /// \brief This pass export CFI checks for use by external modules.
00227 ModulePass *createCrossDSOCFIPass();
00228 
00229 //===----------------------------------------------------------------------===//
00230 // SampleProfilePass - Loads sample profile data from disk and generates
00231 // IR metadata to reflect the profile.
00232 ModulePass *createSampleProfileLoaderPass();
00233 ModulePass *createSampleProfileLoaderPass(StringRef Name);
00234 
00235 } // End llvm namespace
00236 
00237 #endif