Chris Lattner | 259a9b2 | 2002-07-23 19:56:27 +0000 | [diff] [blame] | 1 | //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===// |
Misha Brukman | df586aa | 2005-04-21 20:59:05 +0000 | [diff] [blame] | 2 | // |
John Criswell | b644598 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | e9cc742 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | df586aa | 2005-04-21 20:59:05 +0000 | [diff] [blame] | 7 | // |
John Criswell | b644598 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | b3f4d1b | 2001-10-31 04:32:53 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 259a9b2 | 2002-07-23 19:56:27 +0000 | [diff] [blame] | 10 | // This header file defines prototypes for accessor functions that expose passes |
| 11 | // in the IPO transformations library. |
Chris Lattner | b3f4d1b | 2001-10-31 04:32:53 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chris Lattner | 86fa226 | 2002-07-23 19:48:52 +0000 | [diff] [blame] | 15 | #ifndef LLVM_TRANSFORMS_IPO_H |
| 16 | #define LLVM_TRANSFORMS_IPO_H |
Chris Lattner | b3f4d1b | 2001-10-31 04:32:53 +0000 | [diff] [blame] | 17 | |
Rafael Espindola | a92da5b | 2012-12-11 16:36:02 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/ArrayRef.h" |
Chris Lattner | df2ae52 | 2004-08-13 03:03:44 +0000 | [diff] [blame] | 19 | |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 20 | namespace llvm { |
| 21 | |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 22 | class ModulePass; |
Devang Patel | 13058a5 | 2007-01-26 00:47:38 +0000 | [diff] [blame] | 23 | class Pass; |
Chris Lattner | 58f9002 | 2002-11-19 18:42:59 +0000 | [diff] [blame] | 24 | class Function; |
Chris Lattner | df2ae52 | 2004-08-13 03:03:44 +0000 | [diff] [blame] | 25 | class BasicBlock; |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 26 | class GlobalValue; |
Chris Lattner | 8e79dbf | 2002-04-10 20:31:22 +0000 | [diff] [blame] | 27 | |
Chris Lattner | 86fa226 | 2002-07-23 19:48:52 +0000 | [diff] [blame] | 28 | //===----------------------------------------------------------------------===// |
Chris Lattner | 4459cb2 | 2004-12-02 21:24:19 +0000 | [diff] [blame] | 29 | // |
| 30 | // These functions removes symbols from functions and modules. If OnlyDebugInfo |
| 31 | // is true, only debugging information is removed from the module. |
| 32 | // |
| 33 | ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false); |
| 34 | |
| 35 | //===----------------------------------------------------------------------===// |
Devang Patel | b5e867a | 2008-11-18 21:34:39 +0000 | [diff] [blame] | 36 | // |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 37 | // These functions strips symbols from functions and modules. |
Devang Patel | 66f84e7 | 2009-03-09 20:49:37 +0000 | [diff] [blame] | 38 | // Only debugging information is not stripped. |
Devang Patel | b5e867a | 2008-11-18 21:34:39 +0000 | [diff] [blame] | 39 | // |
| 40 | ModulePass *createStripNonDebugSymbolsPass(); |
| 41 | |
| 42 | //===----------------------------------------------------------------------===// |
Devang Patel | 66f84e7 | 2009-03-09 20:49:37 +0000 | [diff] [blame] | 43 | // |
| 44 | // These pass removes llvm.dbg.declare intrinsics. |
| 45 | ModulePass *createStripDebugDeclarePass(); |
| 46 | |
| 47 | //===----------------------------------------------------------------------===// |
Devang Patel | 2b434e1 | 2010-07-01 19:49:20 +0000 | [diff] [blame] | 48 | // |
| 49 | // These pass removes unused symbols' debug info. |
| 50 | ModulePass *createStripDeadDebugInfoPass(); |
| 51 | |
| 52 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 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 |
| 57 | /// existing string. |
| 58 | /// |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 59 | ModulePass *createConstantMergePass(); |
Chris Lattner | 259a9b2 | 2002-07-23 19:56:27 +0000 | [diff] [blame] | 60 | |
Chris Lattner | 259a9b2 | 2002-07-23 19:56:27 +0000 | [diff] [blame] | 61 | //===----------------------------------------------------------------------===// |
Chris Lattner | fa3cfd3 | 2004-10-07 04:12:02 +0000 | [diff] [blame] | 62 | /// createGlobalOptimizerPass - This function returns a new pass that optimizes |
| 63 | /// non-address taken internal globals. |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 64 | /// |
Chris Lattner | fa3cfd3 | 2004-10-07 04:12:02 +0000 | [diff] [blame] | 65 | ModulePass *createGlobalOptimizerPass(); |
Chris Lattner | 14da4ea | 2004-02-25 21:34:51 +0000 | [diff] [blame] | 66 | |
Chris Lattner | 14da4ea | 2004-02-25 21:34:51 +0000 | [diff] [blame] | 67 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 68 | /// createGlobalDCEPass - This transform is designed to eliminate unreachable |
| 69 | /// internal globals (functions or global variables) |
| 70 | /// |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 71 | ModulePass *createGlobalDCEPass(); |
Chris Lattner | 8cf6e10 | 2002-07-24 17:10:58 +0000 | [diff] [blame] | 72 | |
Chris Lattner | 8cf6e10 | 2002-07-24 17:10:58 +0000 | [diff] [blame] | 73 | //===----------------------------------------------------------------------===// |
Jay Foad | 6a51402 | 2011-07-26 09:36:52 +0000 | [diff] [blame] | 74 | /// createGVExtractionPass - If deleteFn is true, this pass deletes |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 75 | /// the specified global values. Otherwise, it deletes as much of the module as |
| 76 | /// possible, except for the global values specified. |
| 77 | /// |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 78 | ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool |
Dan Gohman | 8f292e7 | 2010-08-26 00:22:55 +0000 | [diff] [blame] | 79 | deleteFn = false); |
Chris Lattner | 58f9002 | 2002-11-19 18:42:59 +0000 | [diff] [blame] | 80 | |
| 81 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 82 | /// createFunctionInliningPass - Return a new pass object that uses a heuristic |
| 83 | /// to inline direct function calls to small functions. |
| 84 | /// |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 85 | /// The Threshold can be passed directly, or asked to be computed from the |
| 86 | /// given optimization and size optimization arguments. |
| 87 | /// |
Jakob Stoklund Olesen | 31a7eb4 | 2010-11-02 23:40:26 +0000 | [diff] [blame] | 88 | /// The -inline-threshold command line option takes precedence over the |
| 89 | /// threshold given here. |
Devang Patel | 13058a5 | 2007-01-26 00:47:38 +0000 | [diff] [blame] | 90 | Pass *createFunctionInliningPass(); |
Chris Lattner | 22ad7ab | 2008-01-12 06:49:13 +0000 | [diff] [blame] | 91 | Pass *createFunctionInliningPass(int Threshold); |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 92 | Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel); |
Chris Lattner | 8cf6e10 | 2002-07-24 17:10:58 +0000 | [diff] [blame] | 93 | |
| 94 | //===----------------------------------------------------------------------===// |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 95 | /// createAlwaysInlinerPass - Return a new pass object that inlines only |
Devang Patel | f58f96f | 2008-09-03 20:24:05 +0000 | [diff] [blame] | 96 | /// functions that are marked as "always_inline". |
| 97 | Pass *createAlwaysInlinerPass(); |
Chad Rosier | 07d37bc | 2012-02-25 02:56:01 +0000 | [diff] [blame] | 98 | Pass *createAlwaysInlinerPass(bool InsertLifetime); |
Devang Patel | f58f96f | 2008-09-03 20:24:05 +0000 | [diff] [blame] | 99 | |
| 100 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 101 | /// createPruneEHPass - Return a new pass object which transforms invoke |
| 102 | /// instructions into calls, if the callee can _not_ unwind the stack. |
| 103 | /// |
Devang Patel | 13058a5 | 2007-01-26 00:47:38 +0000 | [diff] [blame] | 104 | Pass *createPruneEHPass(); |
Chris Lattner | 994e7c2 | 2003-08-31 16:30:25 +0000 | [diff] [blame] | 105 | |
| 106 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 107 | /// createInternalizePass - This pass loops over all of the functions in the |
Rafael Espindola | cda2911 | 2013-10-03 18:29:09 +0000 | [diff] [blame] | 108 | /// input module, internalizing all globals (functions and variables) it can. |
| 109 | //// |
| 110 | /// The symbols in \p ExportList are never internalized. |
| 111 | /// |
| 112 | /// The symbol in DSOList are internalized if it is safe to drop them from |
| 113 | /// the symbol table. |
| 114 | /// |
Matthijs Kooijman | 1b60621 | 2008-06-26 09:48:11 +0000 | [diff] [blame] | 115 | /// Note that commandline options that are used with the above function are not |
Rafael Espindola | 4253bd8 | 2012-10-26 18:47:48 +0000 | [diff] [blame] | 116 | /// used now! |
Duncan P. N. Exon Smith | 4680f40 | 2014-04-02 22:05:57 +0000 | [diff] [blame] | 117 | ModulePass *createInternalizePass(ArrayRef<const char *> ExportList); |
Rafael Espindola | 4253bd8 | 2012-10-26 18:47:48 +0000 | [diff] [blame] | 118 | /// createInternalizePass - Same as above, but with an empty exportList. |
Duncan P. N. Exon Smith | 4680f40 | 2014-04-02 22:05:57 +0000 | [diff] [blame] | 119 | ModulePass *createInternalizePass(); |
Chris Lattner | 8cf6e10 | 2002-07-24 17:10:58 +0000 | [diff] [blame] | 120 | |
Chris Lattner | 4ff0706 | 2003-06-16 12:16:52 +0000 | [diff] [blame] | 121 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 122 | /// createDeadArgEliminationPass - This pass removes arguments from functions |
| 123 | /// which are not used by the body of the function. |
| 124 | /// |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 125 | ModulePass *createDeadArgEliminationPass(); |
Chris Lattner | a2e48a8 | 2003-11-05 21:43:42 +0000 | [diff] [blame] | 126 | |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 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 |
| 129 | /// bugpoint. |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 130 | ModulePass *createDeadArgHackingPass(); |
Chris Lattner | 4ff0706 | 2003-06-16 12:16:52 +0000 | [diff] [blame] | 131 | |
Chris Lattner | e4511db | 2003-10-23 16:51:49 +0000 | [diff] [blame] | 132 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 133 | /// createArgumentPromotionPass - This pass promotes "by reference" arguments to |
Chris Lattner | eb6bb80 | 2008-04-19 19:50:01 +0000 | [diff] [blame] | 134 | /// be passed by value if the number of elements passed is smaller or |
| 135 | /// equal to maxElements (maxElements == 0 means always promote). |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 136 | /// |
Chris Lattner | eb6bb80 | 2008-04-19 19:50:01 +0000 | [diff] [blame] | 137 | Pass *createArgumentPromotionPass(unsigned maxElements = 3); |
Chris Lattner | 1f607f2 | 2004-03-07 21:30:08 +0000 | [diff] [blame] | 138 | |
| 139 | //===----------------------------------------------------------------------===// |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 140 | /// createIPConstantPropagationPass - This pass propagates constants from call |
| 141 | /// sites into the bodies of functions. |
| 142 | /// |
Chris Lattner | 1556b27 | 2004-09-20 04:41:39 +0000 | [diff] [blame] | 143 | ModulePass *createIPConstantPropagationPass(); |
Chris Lattner | e4511db | 2003-10-23 16:51:49 +0000 | [diff] [blame] | 144 | |
Chris Lattner | 3b33c7a | 2004-12-10 07:55:01 +0000 | [diff] [blame] | 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 |
| 148 | /// in the process. |
| 149 | /// |
| 150 | ModulePass *createIPSCCPPass(); |
Chris Lattner | 8cf6e10 | 2002-07-24 17:10:58 +0000 | [diff] [blame] | 151 | |
| 152 | //===----------------------------------------------------------------------===// |
Chris Lattner | 6d24a7c | 2004-03-14 02:36:34 +0000 | [diff] [blame] | 153 | // |
Jeff Cohen | 677babc | 2005-01-08 17:21:40 +0000 | [diff] [blame] | 154 | /// createLoopExtractorPass - This pass extracts all natural loops from the |
| 155 | /// program into a function if it can. |
| 156 | /// |
Dan Gohman | 9a7320c | 2009-09-28 14:37:51 +0000 | [diff] [blame] | 157 | Pass *createLoopExtractorPass(); |
Jeff Cohen | 677babc | 2005-01-08 17:21:40 +0000 | [diff] [blame] | 158 | |
Chris Lattner | f624c99 | 2004-03-14 20:00:37 +0000 | [diff] [blame] | 159 | /// createSingleLoopExtractorPass - This pass extracts one natural loop from the |
| 160 | /// program into a function if it can. This is used by bugpoint. |
| 161 | /// |
Dan Gohman | 9a7320c | 2009-09-28 14:37:51 +0000 | [diff] [blame] | 162 | Pass *createSingleLoopExtractorPass(); |
Chris Lattner | 6d24a7c | 2004-03-14 02:36:34 +0000 | [diff] [blame] | 163 | |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 164 | /// createBlockExtractorPass - This pass extracts all blocks (except those |
| 165 | /// specified in the argument list) from the functions in the module. |
| 166 | /// |
Rafael Espindola | 40f1883 | 2010-07-31 00:32:17 +0000 | [diff] [blame] | 167 | ModulePass *createBlockExtractorPass(); |
Chris Lattner | df2ae52 | 2004-08-13 03:03:44 +0000 | [diff] [blame] | 168 | |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 169 | /// createStripDeadPrototypesPass - This pass removes any function declarations |
| 170 | /// (prototypes) that are not used. |
| 171 | ModulePass *createStripDeadPrototypesPass(); |
| 172 | |
Andrew Lenharth | 9fed8f5 | 2008-09-03 21:00:28 +0000 | [diff] [blame] | 173 | //===----------------------------------------------------------------------===// |
Duncan Sands | 44c8cd9 | 2008-12-31 16:14:43 +0000 | [diff] [blame] | 174 | /// createFunctionAttrsPass - This pass discovers functions that do not access |
Duncan Sands | af25ee7 | 2008-09-19 08:17:05 +0000 | [diff] [blame] | 175 | /// memory, or only read memory, and gives them the readnone/readonly attribute. |
Duncan Sands | 44c8cd9 | 2008-12-31 16:14:43 +0000 | [diff] [blame] | 176 | /// It also discovers function arguments that are not captured by the function |
| 177 | /// and marks them with the nocapture attribute. |
Duncan Sands | af25ee7 | 2008-09-19 08:17:05 +0000 | [diff] [blame] | 178 | /// |
Duncan Sands | 44c8cd9 | 2008-12-31 16:14:43 +0000 | [diff] [blame] | 179 | Pass *createFunctionAttrsPass(); |
Nick Lewycky | d01d42e | 2008-11-02 05:52:50 +0000 | [diff] [blame] | 180 | |
| 181 | //===----------------------------------------------------------------------===// |
| 182 | /// createMergeFunctionsPass - This pass discovers identical functions and |
| 183 | /// collapses them. |
| 184 | /// |
| 185 | ModulePass *createMergeFunctionsPass(); |
Duncan Sands | af25ee7 | 2008-09-19 08:17:05 +0000 | [diff] [blame] | 186 | |
Owen Anderson | 2f82e27 | 2009-06-14 08:26:32 +0000 | [diff] [blame] | 187 | //===----------------------------------------------------------------------===// |
| 188 | /// createPartialInliningPass - This pass inlines parts of functions. |
| 189 | /// |
| 190 | ModulePass *createPartialInliningPass(); |
Eli Bendersky | 49f6565 | 2014-03-12 16:12:36 +0000 | [diff] [blame] | 191 | |
Alex Rosenberg | 04b43aa | 2012-09-11 02:46:18 +0000 | [diff] [blame] | 192 | //===----------------------------------------------------------------------===// |
| 193 | // createMetaRenamerPass - Rename everything with metasyntatic names. |
| 194 | // |
| 195 | ModulePass *createMetaRenamerPass(); |
Owen Anderson | 2f82e27 | 2009-06-14 08:26:32 +0000 | [diff] [blame] | 196 | |
Chandler Carruth | e8479e1 | 2012-10-18 08:05:46 +0000 | [diff] [blame] | 197 | //===----------------------------------------------------------------------===// |
| 198 | /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass |
| 199 | /// manager. |
| 200 | ModulePass *createBarrierNoopPass(); |
| 201 | |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 202 | } // End llvm namespace |
| 203 | |
Chris Lattner | b3f4d1b | 2001-10-31 04:32:53 +0000 | [diff] [blame] | 204 | #endif |