blob: ce1a7d6a5230a3ca4e7c409bd9a1d75a4a79d3d6 [file] [log] [blame]
Chris Lattner259a9b22002-07-23 19:56:27 +00001//===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
Misha Brukmandf586aa2005-04-21 20:59:05 +00002//
John Criswellb6445982003-10-20 20:19:47 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnere9cc7422007-12-29 19:59:42 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmandf586aa2005-04-21 20:59:05 +00007//
John Criswellb6445982003-10-20 20:19:47 +00008//===----------------------------------------------------------------------===//
Chris Lattnerb3f4d1b2001-10-31 04:32:53 +00009//
Chris Lattner259a9b22002-07-23 19:56:27 +000010// This header file defines prototypes for accessor functions that expose passes
11// in the IPO transformations library.
Chris Lattnerb3f4d1b2001-10-31 04:32:53 +000012//
13//===----------------------------------------------------------------------===//
14
Chris Lattner86fa2262002-07-23 19:48:52 +000015#ifndef LLVM_TRANSFORMS_IPO_H
16#define LLVM_TRANSFORMS_IPO_H
Chris Lattnerb3f4d1b2001-10-31 04:32:53 +000017
Rafael Espindolaa92da5b2012-12-11 16:36:02 +000018#include "llvm/ADT/ArrayRef.h"
Chris Lattnerdf2ae522004-08-13 03:03:44 +000019
Brian Gaeke960707c2003-11-11 22:41:34 +000020namespace llvm {
21
Chris Lattner1556b272004-09-20 04:41:39 +000022class ModulePass;
Devang Patel13058a52007-01-26 00:47:38 +000023class Pass;
Chris Lattner58f90022002-11-19 18:42:59 +000024class Function;
Chris Lattnerdf2ae522004-08-13 03:03:44 +000025class BasicBlock;
Andrew Lenharth3f13b662008-03-07 19:51:57 +000026class GlobalValue;
Chris Lattner8e79dbf2002-04-10 20:31:22 +000027
Chris Lattner86fa2262002-07-23 19:48:52 +000028//===----------------------------------------------------------------------===//
Chris Lattner4459cb22004-12-02 21:24:19 +000029//
30// These functions removes symbols from functions and modules. If OnlyDebugInfo
31// is true, only debugging information is removed from the module.
32//
33ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
34
35//===----------------------------------------------------------------------===//
Devang Patelb5e867a2008-11-18 21:34:39 +000036//
Eli Bendersky49f65652014-03-12 16:12:36 +000037// These functions strips symbols from functions and modules.
Devang Patel66f84e72009-03-09 20:49:37 +000038// Only debugging information is not stripped.
Devang Patelb5e867a2008-11-18 21:34:39 +000039//
40ModulePass *createStripNonDebugSymbolsPass();
41
42//===----------------------------------------------------------------------===//
Devang Patel66f84e72009-03-09 20:49:37 +000043//
44// These pass removes llvm.dbg.declare intrinsics.
45ModulePass *createStripDebugDeclarePass();
46
47//===----------------------------------------------------------------------===//
Devang Patel2b434e12010-07-01 19:49:20 +000048//
49// These pass removes unused symbols' debug info.
50ModulePass *createStripDeadDebugInfoPass();
51
52//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +000053/// 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 Lattner1556b272004-09-20 04:41:39 +000059ModulePass *createConstantMergePass();
Chris Lattner259a9b22002-07-23 19:56:27 +000060
Chris Lattner259a9b22002-07-23 19:56:27 +000061//===----------------------------------------------------------------------===//
Chris Lattnerfa3cfd32004-10-07 04:12:02 +000062/// createGlobalOptimizerPass - This function returns a new pass that optimizes
63/// non-address taken internal globals.
Chris Lattnerf624c992004-03-14 20:00:37 +000064///
Chris Lattnerfa3cfd32004-10-07 04:12:02 +000065ModulePass *createGlobalOptimizerPass();
Chris Lattner14da4ea2004-02-25 21:34:51 +000066
Chris Lattner14da4ea2004-02-25 21:34:51 +000067//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +000068/// createGlobalDCEPass - This transform is designed to eliminate unreachable
69/// internal globals (functions or global variables)
70///
Chris Lattner1556b272004-09-20 04:41:39 +000071ModulePass *createGlobalDCEPass();
Chris Lattner8cf6e102002-07-24 17:10:58 +000072
Chris Lattner8cf6e102002-07-24 17:10:58 +000073//===----------------------------------------------------------------------===//
Jay Foad6a514022011-07-26 09:36:52 +000074/// createGVExtractionPass - If deleteFn is true, this pass deletes
Andrew Lenharth3f13b662008-03-07 19:51:57 +000075/// the specified global values. Otherwise, it deletes as much of the module as
76/// possible, except for the global values specified.
77///
Eli Bendersky49f65652014-03-12 16:12:36 +000078ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
Dan Gohman8f292e72010-08-26 00:22:55 +000079 deleteFn = false);
Chris Lattner58f90022002-11-19 18:42:59 +000080
81//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +000082/// createFunctionInliningPass - Return a new pass object that uses a heuristic
83/// to inline direct function calls to small functions.
84///
Eli Bendersky49f65652014-03-12 16:12:36 +000085/// The Threshold can be passed directly, or asked to be computed from the
86/// given optimization and size optimization arguments.
87///
Jakob Stoklund Olesen31a7eb42010-11-02 23:40:26 +000088/// The -inline-threshold command line option takes precedence over the
89/// threshold given here.
Devang Patel13058a52007-01-26 00:47:38 +000090Pass *createFunctionInliningPass();
Chris Lattner22ad7ab2008-01-12 06:49:13 +000091Pass *createFunctionInliningPass(int Threshold);
Eli Bendersky49f65652014-03-12 16:12:36 +000092Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
Chris Lattner8cf6e102002-07-24 17:10:58 +000093
94//===----------------------------------------------------------------------===//
Eli Bendersky49f65652014-03-12 16:12:36 +000095/// createAlwaysInlinerPass - Return a new pass object that inlines only
Devang Patelf58f96f2008-09-03 20:24:05 +000096/// functions that are marked as "always_inline".
97Pass *createAlwaysInlinerPass();
Chad Rosier07d37bc2012-02-25 02:56:01 +000098Pass *createAlwaysInlinerPass(bool InsertLifetime);
Devang Patelf58f96f2008-09-03 20:24:05 +000099
100//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +0000101/// createPruneEHPass - Return a new pass object which transforms invoke
102/// instructions into calls, if the callee can _not_ unwind the stack.
103///
Devang Patel13058a52007-01-26 00:47:38 +0000104Pass *createPruneEHPass();
Chris Lattner994e7c22003-08-31 16:30:25 +0000105
106//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +0000107/// createInternalizePass - This pass loops over all of the functions in the
Rafael Espindolacda29112013-10-03 18:29:09 +0000108/// 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 Kooijman1b606212008-06-26 09:48:11 +0000115/// Note that commandline options that are used with the above function are not
Rafael Espindola4253bd82012-10-26 18:47:48 +0000116/// used now!
Duncan P. N. Exon Smith4680f402014-04-02 22:05:57 +0000117ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
Rafael Espindola4253bd82012-10-26 18:47:48 +0000118/// createInternalizePass - Same as above, but with an empty exportList.
Duncan P. N. Exon Smith4680f402014-04-02 22:05:57 +0000119ModulePass *createInternalizePass();
Chris Lattner8cf6e102002-07-24 17:10:58 +0000120
Chris Lattner4ff07062003-06-16 12:16:52 +0000121//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +0000122/// createDeadArgEliminationPass - This pass removes arguments from functions
123/// which are not used by the body of the function.
124///
Chris Lattner1556b272004-09-20 04:41:39 +0000125ModulePass *createDeadArgEliminationPass();
Chris Lattnera2e48a82003-11-05 21:43:42 +0000126
Chris Lattnerf624c992004-03-14 20:00:37 +0000127/// 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 Lattner1556b272004-09-20 04:41:39 +0000130ModulePass *createDeadArgHackingPass();
Chris Lattner4ff07062003-06-16 12:16:52 +0000131
Chris Lattnere4511db2003-10-23 16:51:49 +0000132//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +0000133/// createArgumentPromotionPass - This pass promotes "by reference" arguments to
Chris Lattnereb6bb802008-04-19 19:50:01 +0000134/// be passed by value if the number of elements passed is smaller or
135/// equal to maxElements (maxElements == 0 means always promote).
Chris Lattnerf624c992004-03-14 20:00:37 +0000136///
Chris Lattnereb6bb802008-04-19 19:50:01 +0000137Pass *createArgumentPromotionPass(unsigned maxElements = 3);
Chris Lattner1f607f22004-03-07 21:30:08 +0000138
139//===----------------------------------------------------------------------===//
Chris Lattnerf624c992004-03-14 20:00:37 +0000140/// createIPConstantPropagationPass - This pass propagates constants from call
141/// sites into the bodies of functions.
142///
Chris Lattner1556b272004-09-20 04:41:39 +0000143ModulePass *createIPConstantPropagationPass();
Chris Lattnere4511db2003-10-23 16:51:49 +0000144
Chris Lattner3b33c7a2004-12-10 07:55:01 +0000145//===----------------------------------------------------------------------===//
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///
150ModulePass *createIPSCCPPass();
Chris Lattner8cf6e102002-07-24 17:10:58 +0000151
152//===----------------------------------------------------------------------===//
Chris Lattner6d24a7c2004-03-14 02:36:34 +0000153//
Jeff Cohen677babc2005-01-08 17:21:40 +0000154/// createLoopExtractorPass - This pass extracts all natural loops from the
155/// program into a function if it can.
156///
Dan Gohman9a7320c2009-09-28 14:37:51 +0000157Pass *createLoopExtractorPass();
Jeff Cohen677babc2005-01-08 17:21:40 +0000158
Chris Lattnerf624c992004-03-14 20:00:37 +0000159/// createSingleLoopExtractorPass - This pass extracts one natural loop from the
160/// program into a function if it can. This is used by bugpoint.
161///
Dan Gohman9a7320c2009-09-28 14:37:51 +0000162Pass *createSingleLoopExtractorPass();
Chris Lattner6d24a7c2004-03-14 02:36:34 +0000163
Reid Spencer3aaaa0b2007-02-05 20:47:22 +0000164/// createBlockExtractorPass - This pass extracts all blocks (except those
165/// specified in the argument list) from the functions in the module.
166///
Rafael Espindola40f18832010-07-31 00:32:17 +0000167ModulePass *createBlockExtractorPass();
Chris Lattnerdf2ae522004-08-13 03:03:44 +0000168
Reid Spencer3aaaa0b2007-02-05 20:47:22 +0000169/// createStripDeadPrototypesPass - This pass removes any function declarations
170/// (prototypes) that are not used.
171ModulePass *createStripDeadPrototypesPass();
172
Andrew Lenharth9fed8f52008-09-03 21:00:28 +0000173//===----------------------------------------------------------------------===//
Duncan Sands44c8cd92008-12-31 16:14:43 +0000174/// createFunctionAttrsPass - This pass discovers functions that do not access
Duncan Sandsaf25ee72008-09-19 08:17:05 +0000175/// memory, or only read memory, and gives them the readnone/readonly attribute.
Duncan Sands44c8cd92008-12-31 16:14:43 +0000176/// It also discovers function arguments that are not captured by the function
177/// and marks them with the nocapture attribute.
Duncan Sandsaf25ee72008-09-19 08:17:05 +0000178///
Duncan Sands44c8cd92008-12-31 16:14:43 +0000179Pass *createFunctionAttrsPass();
Nick Lewyckyd01d42e2008-11-02 05:52:50 +0000180
181//===----------------------------------------------------------------------===//
182/// createMergeFunctionsPass - This pass discovers identical functions and
183/// collapses them.
184///
185ModulePass *createMergeFunctionsPass();
Duncan Sandsaf25ee72008-09-19 08:17:05 +0000186
Owen Anderson2f82e272009-06-14 08:26:32 +0000187//===----------------------------------------------------------------------===//
188/// createPartialInliningPass - This pass inlines parts of functions.
189///
190ModulePass *createPartialInliningPass();
Eli Bendersky49f65652014-03-12 16:12:36 +0000191
Alex Rosenberg04b43aa2012-09-11 02:46:18 +0000192//===----------------------------------------------------------------------===//
193// createMetaRenamerPass - Rename everything with metasyntatic names.
194//
195ModulePass *createMetaRenamerPass();
Owen Anderson2f82e272009-06-14 08:26:32 +0000196
Chandler Carruthe8479e12012-10-18 08:05:46 +0000197//===----------------------------------------------------------------------===//
198/// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
199/// manager.
200ModulePass *createBarrierNoopPass();
201
Brian Gaeke960707c2003-11-11 22:41:34 +0000202} // End llvm namespace
203
Chris Lattnerb3f4d1b2001-10-31 04:32:53 +0000204#endif