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
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 //===----------------------------------------------------------------------===//
37 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
38 /// to invoke/unwind instructions. This should really be part of the C/C++
39 /// front-end, but it's so much easier to write transformations in LLVM proper.
41 ModulePass* createLowerSetJmpPass();
43 //===----------------------------------------------------------------------===//
44 /// createConstantMergePass - This function returns a new pass that merges
45 /// duplicate global constants together into a single constant that is shared.
46 /// This is useful because some passes (ie TraceValues) insert a lot of string
47 /// constants into the program, regardless of whether or not they duplicate an
50 ModulePass *createConstantMergePass();
53 //===----------------------------------------------------------------------===//
54 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
55 /// non-address taken internal globals.
57 ModulePass *createGlobalOptimizerPass();
60 //===----------------------------------------------------------------------===//
61 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
62 /// free function calls into malloc and free instructions.
64 ModulePass *createRaiseAllocationsPass();
67 //===----------------------------------------------------------------------===//
68 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
69 /// table entries for types that are never used.
71 ModulePass *createDeadTypeEliminationPass();
74 //===----------------------------------------------------------------------===//
75 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
76 /// internal globals (functions or global variables)
78 ModulePass *createGlobalDCEPass();
81 //===----------------------------------------------------------------------===//
82 /// createFunctionExtractionPass - If deleteFn is true, this pass deletes as
83 /// the specified function. Otherwise, it deletes as much of the module as
84 /// possible, except for the function specified.
86 ModulePass *createFunctionExtractionPass(Function *F, bool deleteFn = false,
87 bool relinkCallees = false);
89 //===----------------------------------------------------------------------===//
90 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
91 /// the specified global values. Otherwise, it deletes as much of the module as
92 /// possible, except for the global values specified.
94 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
96 bool relinkCallees = false);
98 //===----------------------------------------------------------------------===//
99 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
100 /// to inline direct function calls to small functions.
102 Pass *createFunctionInliningPass();
103 Pass *createFunctionInliningPass(int Threshold);
105 //===----------------------------------------------------------------------===//
106 /// createPruneEHPass - Return a new pass object which transforms invoke
107 /// instructions into calls, if the callee can _not_ unwind the stack.
109 Pass *createPruneEHPass();
111 //===----------------------------------------------------------------------===//
112 /// createInternalizePass - This pass loops over all of the functions in the
113 /// input module, looking for a main function. If a list of symbols is
114 /// specified with the -internalize-public-api-* command line options, those
115 /// symbols are internalized. Otherwise if InternalizeEverything is set and
116 /// the main function is found, all other globals are marked as internal.
118 ModulePass *createInternalizePass(bool InternalizeEverything);
119 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
121 //===----------------------------------------------------------------------===//
122 /// createDeadArgEliminationPass - This pass removes arguments from functions
123 /// which are not used by the body of the function.
125 ModulePass *createDeadArgEliminationPass();
127 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
128 /// functions as well. This is definitely not safe, and should only be used by
130 ModulePass *createDeadArgHackingPass();
132 //===----------------------------------------------------------------------===//
133 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
134 /// be passed by value.
136 Pass *createArgumentPromotionPass();
137 Pass *createStructRetPromotionPass();
139 //===----------------------------------------------------------------------===//
140 /// createIPConstantPropagationPass - This pass propagates constants from call
141 /// sites into the bodies of functions.
143 ModulePass *createIPConstantPropagationPass();
145 //===----------------------------------------------------------------------===//
146 /// createIPSCCPPass - This pass propagates constants from call sites into the
147 /// bodies of functions, and keeps track of whether basic blocks are executable
150 ModulePass *createIPSCCPPass();
152 //===----------------------------------------------------------------------===//
154 /// createLoopExtractorPass - This pass extracts all natural loops from the
155 /// program into a function if it can.
157 FunctionPass *createLoopExtractorPass();
159 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
160 /// program into a function if it can. This is used by bugpoint.
162 FunctionPass *createSingleLoopExtractorPass();
164 /// createBlockExtractorPass - This pass extracts all blocks (except those
165 /// specified in the argument list) from the functions in the module.
167 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
169 /// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
170 /// specific well-known (library) functions.
171 ModulePass *createSimplifyLibCallsPass();
174 /// createIndMemRemPass - This pass removes potential indirect calls of
176 ModulePass *createIndMemRemPass();
178 /// createStripDeadPrototypesPass - This pass removes any function declarations
179 /// (prototypes) that are not used.
180 ModulePass *createStripDeadPrototypesPass();
182 } // End llvm namespace