1 //===-- Scalar.h - Scalar 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 Scalar transformations library.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_SCALAR_H
16 #define LLVM_TRANSFORMS_SCALAR_H
22 class GetElementPtrInst;
27 //===----------------------------------------------------------------------===//
29 // ConstantPropagation - A worklist driven constant propagation pass
31 FunctionPass *createConstantPropagationPass();
33 //===----------------------------------------------------------------------===//
35 // SCCP - Sparse conditional constant propagation.
37 FunctionPass *createSCCPPass();
39 //===----------------------------------------------------------------------===//
41 // DeadInstElimination - This pass quickly removes trivially dead instructions
42 // without modifying the CFG of the function. It is a BasicBlockPass, so it
43 // runs efficiently when queued next to other BasicBlockPass's.
45 Pass *createDeadInstEliminationPass();
47 //===----------------------------------------------------------------------===//
49 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
50 // because it is worklist driven that can potentially revisit instructions when
51 // their other instructions become dead, to eliminate chains of dead
54 FunctionPass *createDeadCodeEliminationPass();
56 //===----------------------------------------------------------------------===//
58 // DeadStoreElimination - This pass deletes stores that are post-dominated by
59 // must-aliased stores and are not loaded used between the stores.
61 FunctionPass *createDeadStoreEliminationPass();
63 //===----------------------------------------------------------------------===//
65 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
66 // algorithm assumes instructions are dead until proven otherwise, which makes
67 // it more successful are removing non-obviously dead instructions.
69 FunctionPass *createAggressiveDCEPass();
71 //===----------------------------------------------------------------------===//
73 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
76 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
77 bool UseDomTree = true);
79 //===----------------------------------------------------------------------===//
81 // InductionVariableSimplify - Transform induction variables in a program to all
82 // use a single canonical induction variable per loop.
84 Pass *createIndVarSimplifyPass();
86 //===----------------------------------------------------------------------===//
88 // InstructionCombining - Combine instructions to form fewer, simple
89 // instructions. This pass does not modify the CFG, and has a tendency to make
90 // instructions dead, so a subsequent DCE pass is useful.
92 // This pass combines things like:
98 FunctionPass *createInstructionCombiningPass();
100 //===----------------------------------------------------------------------===//
102 // LICM - This pass is a loop invariant code motion and memory promotion pass.
104 Pass *createLICMPass();
106 //===----------------------------------------------------------------------===//
108 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
109 // a loop's canonical induction variable as one of their indices. It takes an
110 // optional parameter used to consult the target machine whether certain
111 // transformations are profitable.
113 Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
115 //===----------------------------------------------------------------------===//
117 // LoopUnswitch - This pass is a simple loop unswitching pass.
119 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
121 //===----------------------------------------------------------------------===//
123 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
125 Pass *createLoopInstSimplifyPass();
127 //===----------------------------------------------------------------------===//
129 // LoopUnroll - This pass is a simple loop unrolling pass.
131 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1);
133 //===----------------------------------------------------------------------===//
135 // LoopRotate - This pass is a simple loop rotating pass.
137 Pass *createLoopRotatePass();
139 //===----------------------------------------------------------------------===//
141 // LoopIdiom - This pass recognizes and replaces idioms in loops.
143 Pass *createLoopIdiomPass();
145 //===----------------------------------------------------------------------===//
147 // PromoteMemoryToRegister - This pass is used to promote memory references to
148 // be register references. A simple example of the transformation performed by
152 // %X = alloca i32, i32 1 ret i32 42
153 // store i32 42, i32 *%X
157 FunctionPass *createPromoteMemoryToRegisterPass();
159 //===----------------------------------------------------------------------===//
161 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
162 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
165 FunctionPass *createDemoteRegisterToMemoryPass();
166 extern char &DemoteRegisterToMemoryID;
168 //===----------------------------------------------------------------------===//
170 // Reassociate - This pass reassociates commutative expressions in an order that
171 // is designed to promote better constant propagation, GCSE, LICM, PRE...
173 // For example: 4 + (x + 5) -> x + (4 + 5)
175 FunctionPass *createReassociatePass();
177 //===----------------------------------------------------------------------===//
179 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
180 // preds always go to some succ.
182 FunctionPass *createJumpThreadingPass();
184 //===----------------------------------------------------------------------===//
186 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
187 // simplify terminator instructions, etc...
189 FunctionPass *createCFGSimplificationPass();
191 //===----------------------------------------------------------------------===//
193 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
194 // a dummy basic block. This pass may be "required" by passes that cannot deal
195 // with critical edges. For this usage, a pass must call:
197 // AU.addRequiredID(BreakCriticalEdgesID);
199 // This pass obviously invalidates the CFG, but can update forward dominator
200 // (set, immediate dominators, tree, and frontier) information.
202 FunctionPass *createBreakCriticalEdgesPass();
203 extern char &BreakCriticalEdgesID;
205 //===----------------------------------------------------------------------===//
207 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
208 // the module. This pass updates dominator information, loop information, and
209 // does not add critical edges to the CFG.
211 // AU.addRequiredID(LoopSimplifyID);
213 Pass *createLoopSimplifyPass();
214 extern char &LoopSimplifyID;
216 //===----------------------------------------------------------------------===//
218 // TailCallElimination - This pass eliminates call instructions to the current
219 // function which occur immediately before return instructions.
221 FunctionPass *createTailCallEliminationPass();
223 //===----------------------------------------------------------------------===//
225 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
226 // chained binary branch instructions.
228 FunctionPass *createLowerSwitchPass();
229 extern char &LowerSwitchID;
231 //===----------------------------------------------------------------------===//
233 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
234 // exception handling mechanisms. Note that after this pass runs the CFG is not
235 // entirely accurate (exceptional control flow edges are not correct anymore) so
236 // only very simple things should be done after the lowerinvoke pass has run
237 // (like generation of native code). This should *NOT* be used as a general
238 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
241 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
242 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
243 bool useExpensiveEHSupport);
244 extern char &LowerInvokePassID;
246 //===----------------------------------------------------------------------===//
248 // BlockPlacement - This pass reorders basic blocks in order to increase the
249 // number of fall-through conditional branches.
251 FunctionPass *createBlockPlacementPass();
253 //===----------------------------------------------------------------------===//
255 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
258 Pass *createLCSSAPass();
259 extern char &LCSSAID;
261 //===----------------------------------------------------------------------===//
263 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
266 FunctionPass *createEarlyCSEPass();
268 //===----------------------------------------------------------------------===//
270 // GVN - This pass performs global value numbering and redundant load
271 // elimination cotemporaneously.
273 FunctionPass *createGVNPass(bool NoLoads = false);
275 //===----------------------------------------------------------------------===//
277 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
278 // calls and/or combining multiple stores into memset's.
280 FunctionPass *createMemCpyOptPass();
282 //===----------------------------------------------------------------------===//
284 // LoopDeletion - This pass performs DCE of non-infinite loops that it
285 // can prove are dead.
287 Pass *createLoopDeletionPass();
289 //===----------------------------------------------------------------------===//
291 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
292 /// specific well-known (library) functions.
293 FunctionPass *createSimplifyLibCallsPass();
295 //===----------------------------------------------------------------------===//
297 // CodeGenPrepare - This pass prepares a function for instruction selection.
299 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
301 //===----------------------------------------------------------------------===//
303 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
305 FunctionPass *createInstructionNamerPass();
306 extern char &InstructionNamerID;
308 //===----------------------------------------------------------------------===//
310 // GEPSplitter - Split complex GEPs into simple ones
312 FunctionPass *createGEPSplitterPass();
314 //===----------------------------------------------------------------------===//
316 // Sink - Code Sinking
318 FunctionPass *createSinkingPass();
320 //===----------------------------------------------------------------------===//
322 // LowerAtomic - Lower atomic intrinsics to non-atomic form
324 Pass *createLowerAtomicPass();
326 //===----------------------------------------------------------------------===//
328 // ValuePropagation - Propagate CFG-derived value information
330 Pass *createCorrelatedValuePropagationPass();
332 //===----------------------------------------------------------------------===//
334 // ObjCARCExpand - ObjC ARC preliminary simplifications.
336 Pass *createObjCARCExpandPass();
338 //===----------------------------------------------------------------------===//
340 // ObjCARCContract - Late ObjC ARC cleanups.
342 Pass *createObjCARCContractPass();
344 //===----------------------------------------------------------------------===//
346 // ObjCARCOpt - ObjC ARC optimization.
348 Pass *createObjCARCOptPass();
350 //===----------------------------------------------------------------------===//
352 // InstructionSimplifier - Remove redundant instructions.
354 FunctionPass *createInstructionSimplifierPass();
355 extern char &InstructionSimplifierID;
358 //===----------------------------------------------------------------------===//
360 // LowerExpectIntriniscs - Removes llvm.expect intrinsics and creates
361 // "block_weights" metadata.
362 FunctionPass *createLowerExpectIntrinsicPass();
365 } // End llvm namespace