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"
29 //===----------------------------------------------------------------------===//
31 // These functions removes symbols from functions and modules. If OnlyDebugInfo
32 // is true, only debugging information is removed from the module.
34 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
36 //===----------------------------------------------------------------------===//
38 // These functions strips symbols from functions and modules.
39 // Only debugging information is not stripped.
41 ModulePass *createStripNonDebugSymbolsPass();
43 //===----------------------------------------------------------------------===//
45 // These pass removes llvm.dbg.declare intrinsics.
46 ModulePass *createStripDebugDeclarePass();
48 //===----------------------------------------------------------------------===//
50 // These pass removes unused symbols' debug info.
51 ModulePass *createStripDeadDebugInfoPass();
53 //===----------------------------------------------------------------------===//
54 /// createConstantMergePass - This function returns a new pass that merges
55 /// duplicate global constants together into a single constant that is shared.
56 /// This is useful because some passes (ie TraceValues) insert a lot of string
57 /// constants into the program, regardless of whether or not they duplicate an
60 ModulePass *createConstantMergePass();
62 //===----------------------------------------------------------------------===//
63 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
64 /// non-address taken internal globals.
66 ModulePass *createGlobalOptimizerPass();
68 //===----------------------------------------------------------------------===//
69 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
70 /// internal globals (functions or global variables)
72 ModulePass *createGlobalDCEPass();
74 //===----------------------------------------------------------------------===//
75 /// This transform is designed to eliminate available external globals
76 /// (functions or global variables)
78 ModulePass *createEliminateAvailableExternallyPass();
80 //===----------------------------------------------------------------------===//
81 /// createGVExtractionPass - If deleteFn is true, this pass deletes
82 /// the specified global values. Otherwise, it deletes as much of the module as
83 /// possible, except for the global values specified.
85 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
88 //===----------------------------------------------------------------------===//
89 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
90 /// to inline direct function calls to small functions.
92 /// The Threshold can be passed directly, or asked to be computed from the
93 /// given optimization and size optimization arguments.
95 /// The -inline-threshold command line option takes precedence over the
96 /// threshold given here.
97 Pass *createFunctionInliningPass();
98 Pass *createFunctionInliningPass(int Threshold);
99 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
101 //===----------------------------------------------------------------------===//
102 /// createAlwaysInlinerPass - Return a new pass object that inlines only
103 /// functions that are marked as "always_inline".
104 Pass *createAlwaysInlinerPass();
105 Pass *createAlwaysInlinerPass(bool InsertLifetime);
107 //===----------------------------------------------------------------------===//
108 /// createPruneEHPass - Return a new pass object which transforms invoke
109 /// instructions into calls, if the callee can _not_ unwind the stack.
111 Pass *createPruneEHPass();
113 //===----------------------------------------------------------------------===//
114 /// createInternalizePass - This pass loops over all of the functions in the
115 /// input module, internalizing all globals (functions and variables) it can.
117 /// The symbols in \p ExportList are never internalized.
119 /// The symbol in DSOList are internalized if it is safe to drop them from
120 /// the symbol table.
122 /// Note that commandline options that are used with the above function are not
124 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
125 /// createInternalizePass - Same as above, but with an empty exportList.
126 ModulePass *createInternalizePass();
128 //===----------------------------------------------------------------------===//
129 /// createDeadArgEliminationPass - This pass removes arguments from functions
130 /// which are not used by the body of the function.
132 ModulePass *createDeadArgEliminationPass();
134 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
135 /// functions as well. This is definitely not safe, and should only be used by
137 ModulePass *createDeadArgHackingPass();
139 //===----------------------------------------------------------------------===//
140 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
141 /// be passed by value if the number of elements passed is smaller or
142 /// equal to maxElements (maxElements == 0 means always promote).
144 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
146 //===----------------------------------------------------------------------===//
147 /// createIPConstantPropagationPass - This pass propagates constants from call
148 /// sites into the bodies of functions.
150 ModulePass *createIPConstantPropagationPass();
152 //===----------------------------------------------------------------------===//
153 /// createIPSCCPPass - This pass propagates constants from call sites into the
154 /// bodies of functions, and keeps track of whether basic blocks are executable
157 ModulePass *createIPSCCPPass();
159 //===----------------------------------------------------------------------===//
161 /// createLoopExtractorPass - This pass extracts all natural loops from the
162 /// program into a function if it can.
164 Pass *createLoopExtractorPass();
166 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
167 /// program into a function if it can. This is used by bugpoint.
169 Pass *createSingleLoopExtractorPass();
171 /// createBlockExtractorPass - This pass extracts all blocks (except those
172 /// specified in the argument list) from the functions in the module.
174 ModulePass *createBlockExtractorPass();
176 /// createStripDeadPrototypesPass - This pass removes any function declarations
177 /// (prototypes) that are not used.
178 ModulePass *createStripDeadPrototypesPass();
180 //===----------------------------------------------------------------------===//
181 /// createFunctionAttrsPass - This pass discovers functions that do not access
182 /// memory, or only read memory, and gives them the readnone/readonly attribute.
183 /// It also discovers function arguments that are not captured by the function
184 /// and marks them with the nocapture attribute.
186 Pass *createFunctionAttrsPass();
188 //===----------------------------------------------------------------------===//
189 /// createMergeFunctionsPass - This pass discovers identical functions and
192 ModulePass *createMergeFunctionsPass();
194 //===----------------------------------------------------------------------===//
195 /// createPartialInliningPass - This pass inlines parts of functions.
197 ModulePass *createPartialInliningPass();
199 //===----------------------------------------------------------------------===//
200 // createMetaRenamerPass - Rename everything with metasyntatic names.
202 ModulePass *createMetaRenamerPass();
204 //===----------------------------------------------------------------------===//
205 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
207 ModulePass *createBarrierNoopPass();
209 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
211 ModulePass *createLowerBitSetsPass();
213 //===----------------------------------------------------------------------===//
214 // SampleProfilePass - Loads sample profile data from disk and generates
215 // IR metadata to reflect the profile.
216 ModulePass *createSampleProfileLoaderPass();
217 ModulePass *createSampleProfileLoaderPass(StringRef Name);
219 } // End llvm namespace