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"
28 //===----------------------------------------------------------------------===//
30 // These functions removes symbols from functions and modules. If OnlyDebugInfo
31 // is true, only debugging information is removed from the module.
33 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
35 //===----------------------------------------------------------------------===//
37 // These functions strips symbols from functions and modules.
38 // Only debugging information is not stripped.
40 ModulePass *createStripNonDebugSymbolsPass();
42 //===----------------------------------------------------------------------===//
44 // These pass removes llvm.dbg.declare intrinsics.
45 ModulePass *createStripDebugDeclarePass();
47 //===----------------------------------------------------------------------===//
49 // These pass removes unused symbols' debug info.
50 ModulePass *createStripDeadDebugInfoPass();
52 //===----------------------------------------------------------------------===//
53 /// createConstantMergePass - This function returns a new pass that merges
54 /// duplicate global constants together into a single constant that is shared.
55 /// This is useful because some passes (ie TraceValues) insert a lot of string
56 /// constants into the program, regardless of whether or not they duplicate an
59 ModulePass *createConstantMergePass();
62 //===----------------------------------------------------------------------===//
63 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
64 /// non-address taken internal globals.
66 ModulePass *createGlobalOptimizerPass();
69 //===----------------------------------------------------------------------===//
70 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
71 /// internal globals (functions or global variables)
73 ModulePass *createGlobalDCEPass();
76 //===----------------------------------------------------------------------===//
77 /// createGVExtractionPass - If deleteFn is true, this pass deletes
78 /// the specified global values. Otherwise, it deletes as much of the module as
79 /// possible, except for the global values specified.
81 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
84 //===----------------------------------------------------------------------===//
85 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
86 /// to inline direct function calls to small functions.
88 /// The -inline-threshold command line option takes precedence over the
89 /// threshold given here.
90 Pass *createFunctionInliningPass();
91 Pass *createFunctionInliningPass(int Threshold);
93 //===----------------------------------------------------------------------===//
94 /// createAlwaysInlinerPass - Return a new pass object that inlines only
95 /// functions that are marked as "always_inline".
96 Pass *createAlwaysInlinerPass();
97 Pass *createAlwaysInlinerPass(bool InsertLifetime);
99 //===----------------------------------------------------------------------===//
100 /// createPruneEHPass - Return a new pass object which transforms invoke
101 /// instructions into calls, if the callee can _not_ unwind the stack.
103 Pass *createPruneEHPass();
105 //===----------------------------------------------------------------------===//
106 /// createInternalizePass - This pass loops over all of the functions in the
107 /// input module, internalizing all globals (functions and variables) it can.
109 /// The symbols in \p ExportList are never internalized.
111 /// The symbol in DSOList are internalized if it is safe to drop them from
112 /// the symbol table.
114 /// For example of the difference, consider a dynamic library being built from
115 /// two translation units. The first one compiled to a native object
116 /// (ELF/MachO/COFF) and second one compiled to IL. Translation unit A has a
117 /// copy of linkonce_odr unnamed_addr function F. The translation unit B has a
118 /// copy of the linkonce_odr unnamed_addr functions F and G.
120 /// Assume the linker decides to keep the copy of F in B. This means that LLVM
121 /// must produce F in the object file it passes to the linker, otherwise we
122 /// will have an undefined reference. For G the situation is different. The
123 /// linker puts the function in the DSOList, since it is only wanted for the
124 /// symbol table. With this information internalize can now reason that since
125 /// the function is a linkonce_odr and its address is not important, it can be
126 /// omitted. Any other shared library needing this function will have a copy of
129 /// Note that commandline options that are used with the above function are not
131 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList,
132 ArrayRef<const char *> DSOList);
133 /// createInternalizePass - Same as above, but with an empty exportList.
134 ModulePass *createInternalizePass();
136 //===----------------------------------------------------------------------===//
137 /// createDeadArgEliminationPass - This pass removes arguments from functions
138 /// which are not used by the body of the function.
140 ModulePass *createDeadArgEliminationPass();
142 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
143 /// functions as well. This is definitely not safe, and should only be used by
145 ModulePass *createDeadArgHackingPass();
147 //===----------------------------------------------------------------------===//
148 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
149 /// be passed by value if the number of elements passed is smaller or
150 /// equal to maxElements (maxElements == 0 means always promote).
152 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
154 //===----------------------------------------------------------------------===//
155 /// createIPConstantPropagationPass - This pass propagates constants from call
156 /// sites into the bodies of functions.
158 ModulePass *createIPConstantPropagationPass();
160 //===----------------------------------------------------------------------===//
161 /// createIPSCCPPass - This pass propagates constants from call sites into the
162 /// bodies of functions, and keeps track of whether basic blocks are executable
165 ModulePass *createIPSCCPPass();
167 //===----------------------------------------------------------------------===//
169 /// createLoopExtractorPass - This pass extracts all natural loops from the
170 /// program into a function if it can.
172 Pass *createLoopExtractorPass();
174 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
175 /// program into a function if it can. This is used by bugpoint.
177 Pass *createSingleLoopExtractorPass();
179 /// createBlockExtractorPass - This pass extracts all blocks (except those
180 /// specified in the argument list) from the functions in the module.
182 ModulePass *createBlockExtractorPass();
184 /// createStripDeadPrototypesPass - This pass removes any function declarations
185 /// (prototypes) that are not used.
186 ModulePass *createStripDeadPrototypesPass();
188 //===----------------------------------------------------------------------===//
189 /// createFunctionAttrsPass - This pass discovers functions that do not access
190 /// memory, or only read memory, and gives them the readnone/readonly attribute.
191 /// It also discovers function arguments that are not captured by the function
192 /// and marks them with the nocapture attribute.
194 Pass *createFunctionAttrsPass();
196 //===----------------------------------------------------------------------===//
197 /// createMergeFunctionsPass - This pass discovers identical functions and
200 ModulePass *createMergeFunctionsPass();
202 //===----------------------------------------------------------------------===//
203 /// createPartialInliningPass - This pass inlines parts of functions.
205 ModulePass *createPartialInliningPass();
207 //===----------------------------------------------------------------------===//
208 // createMetaRenamerPass - Rename everything with metasyntatic names.
210 ModulePass *createMetaRenamerPass();
212 //===----------------------------------------------------------------------===//
213 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
215 ModulePass *createBarrierNoopPass();
217 } // End llvm namespace