1 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header file defines prototypes for accessor functions that expose passes
11 // in the IPO transformations library.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_IPO_H
16 #define LLVM_TRANSFORMS_IPO_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
23 class FunctionInfoIndex;
30 //===----------------------------------------------------------------------===//
32 // These functions removes symbols from functions and modules. If OnlyDebugInfo
33 // is true, only debugging information is removed from the module.
35 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
37 //===----------------------------------------------------------------------===//
39 // These functions strips symbols from functions and modules.
40 // Only debugging information is not stripped.
42 ModulePass *createStripNonDebugSymbolsPass();
44 //===----------------------------------------------------------------------===//
46 // These pass removes llvm.dbg.declare intrinsics.
47 ModulePass *createStripDebugDeclarePass();
49 //===----------------------------------------------------------------------===//
51 // These pass removes unused symbols' debug info.
52 ModulePass *createStripDeadDebugInfoPass();
54 //===----------------------------------------------------------------------===//
55 /// createConstantMergePass - This function returns a new pass that merges
56 /// duplicate global constants together into a single constant that is shared.
57 /// This is useful because some passes (ie TraceValues) insert a lot of string
58 /// constants into the program, regardless of whether or not they duplicate an
61 ModulePass *createConstantMergePass();
63 //===----------------------------------------------------------------------===//
64 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
65 /// non-address taken internal globals.
67 ModulePass *createGlobalOptimizerPass();
69 //===----------------------------------------------------------------------===//
70 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
71 /// internal globals (functions or global variables)
73 ModulePass *createGlobalDCEPass();
75 //===----------------------------------------------------------------------===//
76 /// This transform is designed to eliminate available external globals
77 /// (functions or global variables)
79 ModulePass *createEliminateAvailableExternallyPass();
81 //===----------------------------------------------------------------------===//
82 /// createGVExtractionPass - If deleteFn is true, this pass deletes
83 /// the specified global values. Otherwise, it deletes as much of the module as
84 /// possible, except for the global values specified.
86 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
89 //===----------------------------------------------------------------------===//
90 /// This pass performs iterative function importing from other modules.
91 Pass *createFunctionImportPass(const FunctionInfoIndex *Index = nullptr);
93 //===----------------------------------------------------------------------===//
94 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
95 /// to inline direct function calls to small functions.
97 /// The Threshold can be passed directly, or asked to be computed from the
98 /// given optimization and size optimization arguments.
100 /// The -inline-threshold command line option takes precedence over the
101 /// threshold given here.
102 Pass *createFunctionInliningPass();
103 Pass *createFunctionInliningPass(int Threshold);
104 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
106 //===----------------------------------------------------------------------===//
107 /// createAlwaysInlinerPass - Return a new pass object that inlines only
108 /// functions that are marked as "always_inline".
109 Pass *createAlwaysInlinerPass();
110 Pass *createAlwaysInlinerPass(bool InsertLifetime);
112 //===----------------------------------------------------------------------===//
113 /// createPruneEHPass - Return a new pass object which transforms invoke
114 /// instructions into calls, if the callee can _not_ unwind the stack.
116 Pass *createPruneEHPass();
118 //===----------------------------------------------------------------------===//
119 /// createInternalizePass - This pass loops over all of the functions in the
120 /// input module, internalizing all globals (functions and variables) it can.
122 /// The symbols in \p ExportList are never internalized.
124 /// The symbol in DSOList are internalized if it is safe to drop them from
125 /// the symbol table.
127 /// Note that commandline options that are used with the above function are not
129 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
130 /// createInternalizePass - Same as above, but with an empty exportList.
131 ModulePass *createInternalizePass();
133 //===----------------------------------------------------------------------===//
134 /// createDeadArgEliminationPass - This pass removes arguments from functions
135 /// which are not used by the body of the function.
137 ModulePass *createDeadArgEliminationPass();
139 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
140 /// functions as well. This is definitely not safe, and should only be used by
142 ModulePass *createDeadArgHackingPass();
144 //===----------------------------------------------------------------------===//
145 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
146 /// be passed by value if the number of elements passed is smaller or
147 /// equal to maxElements (maxElements == 0 means always promote).
149 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
151 //===----------------------------------------------------------------------===//
152 /// createIPConstantPropagationPass - This pass propagates constants from call
153 /// sites into the bodies of functions.
155 ModulePass *createIPConstantPropagationPass();
157 //===----------------------------------------------------------------------===//
158 /// createIPSCCPPass - This pass propagates constants from call sites into the
159 /// bodies of functions, and keeps track of whether basic blocks are executable
162 ModulePass *createIPSCCPPass();
164 //===----------------------------------------------------------------------===//
166 /// createLoopExtractorPass - This pass extracts all natural loops from the
167 /// program into a function if it can.
169 Pass *createLoopExtractorPass();
171 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
172 /// program into a function if it can. This is used by bugpoint.
174 Pass *createSingleLoopExtractorPass();
176 /// createBlockExtractorPass - This pass extracts all blocks (except those
177 /// specified in the argument list) from the functions in the module.
179 ModulePass *createBlockExtractorPass();
181 /// createStripDeadPrototypesPass - This pass removes any function declarations
182 /// (prototypes) that are not used.
183 ModulePass *createStripDeadPrototypesPass();
185 //===----------------------------------------------------------------------===//
186 /// createPostOrderFunctionAttrsPass - This pass walks SCCs of the call graph
187 /// in post-order to deduce and propagate function attributes. It can discover
188 /// functions that do not access memory, or only read memory, and give them the
189 /// readnone/readonly attribute. It also discovers function arguments that are
190 /// not captured by the function and marks them with the nocapture attribute.
192 Pass *createPostOrderFunctionAttrsPass();
194 //===----------------------------------------------------------------------===//
195 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
196 /// graph in RPO to deduce and propagate function attributes. Currently it
197 /// only handles synthesizing norecurse attributes.
199 Pass *createReversePostOrderFunctionAttrsPass();
201 //===----------------------------------------------------------------------===//
202 /// createMergeFunctionsPass - This pass discovers identical functions and
205 ModulePass *createMergeFunctionsPass();
207 //===----------------------------------------------------------------------===//
208 /// createPartialInliningPass - This pass inlines parts of functions.
210 ModulePass *createPartialInliningPass();
212 //===----------------------------------------------------------------------===//
213 // createMetaRenamerPass - Rename everything with metasyntatic names.
215 ModulePass *createMetaRenamerPass();
217 //===----------------------------------------------------------------------===//
218 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
220 ModulePass *createBarrierNoopPass();
222 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
224 ModulePass *createLowerBitSetsPass();
226 /// \brief This pass export CFI checks for use by external modules.
227 ModulePass *createCrossDSOCFIPass();
229 //===----------------------------------------------------------------------===//
230 // SampleProfilePass - Loads sample profile data from disk and generates
231 // IR metadata to reflect the profile.
232 ModulePass *createSampleProfileLoaderPass();
233 ModulePass *createSampleProfileLoaderPass(StringRef Name);
235 } // End llvm namespace