]>
git.proxmox.com Git - rustc.git/blob - src/llvm/include/llvm/Transforms/Scalar.h
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
18 #include "llvm/ADT/StringRef.h"
25 class GetElementPtrInst
;
31 //===----------------------------------------------------------------------===//
33 // ConstantPropagation - A worklist driven constant propagation pass
35 FunctionPass
*createConstantPropagationPass();
37 //===----------------------------------------------------------------------===//
39 // AlignmentFromAssumptions - Use assume intrinsics to set load/store
42 FunctionPass
*createAlignmentFromAssumptionsPass();
44 //===----------------------------------------------------------------------===//
46 // SCCP - Sparse conditional constant propagation.
48 FunctionPass
*createSCCPPass();
50 //===----------------------------------------------------------------------===//
52 // DeadInstElimination - This pass quickly removes trivially dead instructions
53 // without modifying the CFG of the function. It is a BasicBlockPass, so it
54 // runs efficiently when queued next to other BasicBlockPass's.
56 Pass
*createDeadInstEliminationPass();
58 //===----------------------------------------------------------------------===//
60 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
61 // because it is worklist driven that can potentially revisit instructions when
62 // their other instructions become dead, to eliminate chains of dead
65 FunctionPass
*createDeadCodeEliminationPass();
67 //===----------------------------------------------------------------------===//
69 // DeadStoreElimination - This pass deletes stores that are post-dominated by
70 // must-aliased stores and are not loaded used between the stores.
72 FunctionPass
*createDeadStoreEliminationPass();
74 //===----------------------------------------------------------------------===//
76 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
77 // algorithm assumes instructions are dead until proven otherwise, which makes
78 // it more successful are removing non-obviously dead instructions.
80 FunctionPass
*createAggressiveDCEPass();
82 //===----------------------------------------------------------------------===//
84 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
86 FunctionPass
*createSROAPass(bool RequiresDomTree
= true);
88 //===----------------------------------------------------------------------===//
90 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
93 FunctionPass
*createScalarReplAggregatesPass(signed Threshold
= -1,
94 bool UseDomTree
= true,
95 signed StructMemberThreshold
= -1,
96 signed ArrayElementThreshold
= -1,
97 signed ScalarLoadThreshold
= -1);
99 //===----------------------------------------------------------------------===//
101 // InductionVariableSimplify - Transform induction variables in a program to all
102 // use a single canonical induction variable per loop.
104 Pass
*createIndVarSimplifyPass();
106 //===----------------------------------------------------------------------===//
108 // InstructionCombining - Combine instructions to form fewer, simple
109 // instructions. This pass does not modify the CFG, and has a tendency to make
110 // instructions dead, so a subsequent DCE pass is useful.
112 // This pass combines things like:
113 // %Y = add int 1, %X
114 // %Z = add int 1, %Y
116 // %Z = add int 2, %X
118 FunctionPass
*createInstructionCombiningPass();
120 //===----------------------------------------------------------------------===//
122 // LICM - This pass is a loop invariant code motion and memory promotion pass.
124 Pass
*createLICMPass();
126 //===----------------------------------------------------------------------===//
128 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
129 // a loop's canonical induction variable as one of their indices.
131 Pass
*createLoopStrengthReducePass();
133 Pass
*createGlobalMergePass(const TargetMachine
*TM
= nullptr);
135 //===----------------------------------------------------------------------===//
137 // LoopUnswitch - This pass is a simple loop unswitching pass.
139 Pass
*createLoopUnswitchPass(bool OptimizeForSize
= false);
141 //===----------------------------------------------------------------------===//
143 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
145 Pass
*createLoopInstSimplifyPass();
147 //===----------------------------------------------------------------------===//
149 // LoopUnroll - This pass is a simple loop unrolling pass.
151 Pass
*createLoopUnrollPass(int Threshold
= -1, int Count
= -1,
152 int AllowPartial
= -1, int Runtime
= -1);
153 // Create an unrolling pass for full unrolling only.
154 Pass
*createSimpleLoopUnrollPass();
156 //===----------------------------------------------------------------------===//
158 // LoopReroll - This pass is a simple loop rerolling pass.
160 Pass
*createLoopRerollPass();
162 //===----------------------------------------------------------------------===//
164 // LoopRotate - This pass is a simple loop rotating pass.
166 Pass
*createLoopRotatePass(int MaxHeaderSize
= -1);
168 //===----------------------------------------------------------------------===//
170 // LoopIdiom - This pass recognizes and replaces idioms in loops.
172 Pass
*createLoopIdiomPass();
174 //===----------------------------------------------------------------------===//
176 // PromoteMemoryToRegister - This pass is used to promote memory references to
177 // be register references. A simple example of the transformation performed by
181 // %X = alloca i32, i32 1 ret i32 42
182 // store i32 42, i32 *%X
186 FunctionPass
*createPromoteMemoryToRegisterPass();
188 //===----------------------------------------------------------------------===//
190 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
191 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
194 FunctionPass
*createDemoteRegisterToMemoryPass();
195 extern char &DemoteRegisterToMemoryID
;
197 //===----------------------------------------------------------------------===//
199 // Reassociate - This pass reassociates commutative expressions in an order that
200 // is designed to promote better constant propagation, GCSE, LICM, PRE...
202 // For example: 4 + (x + 5) -> x + (4 + 5)
204 FunctionPass
*createReassociatePass();
206 //===----------------------------------------------------------------------===//
208 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
209 // preds always go to some succ. Thresholds other than minus one override the
210 // internal BB duplication default threshold.
212 FunctionPass
*createJumpThreadingPass(int Threshold
= -1);
214 //===----------------------------------------------------------------------===//
216 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
217 // simplify terminator instructions, etc...
219 FunctionPass
*createCFGSimplificationPass(int Threshold
= -1);
221 //===----------------------------------------------------------------------===//
223 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
224 // parallel-and and parallel-or mode, etc...
226 FunctionPass
*createFlattenCFGPass();
228 //===----------------------------------------------------------------------===//
230 // CFG Structurization - Remove irreducible control flow
232 Pass
*createStructurizeCFGPass();
234 //===----------------------------------------------------------------------===//
236 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
237 // a dummy basic block. This pass may be "required" by passes that cannot deal
238 // with critical edges. For this usage, a pass must call:
240 // AU.addRequiredID(BreakCriticalEdgesID);
242 // This pass obviously invalidates the CFG, but can update forward dominator
243 // (set, immediate dominators, tree, and frontier) information.
245 FunctionPass
*createBreakCriticalEdgesPass();
246 extern char &BreakCriticalEdgesID
;
248 //===----------------------------------------------------------------------===//
250 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
251 // the module. This pass updates dominator information, loop information, and
252 // does not add critical edges to the CFG.
254 // AU.addRequiredID(LoopSimplifyID);
256 Pass
*createLoopSimplifyPass();
257 extern char &LoopSimplifyID
;
259 //===----------------------------------------------------------------------===//
261 // TailCallElimination - This pass eliminates call instructions to the current
262 // function which occur immediately before return instructions.
264 FunctionPass
*createTailCallEliminationPass();
266 //===----------------------------------------------------------------------===//
268 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
269 // chained binary branch instructions.
271 FunctionPass
*createLowerSwitchPass();
272 extern char &LowerSwitchID
;
274 //===----------------------------------------------------------------------===//
276 // LowerInvoke - This pass removes invoke instructions, converting them to call
279 FunctionPass
*createLowerInvokePass();
280 extern char &LowerInvokePassID
;
282 //===----------------------------------------------------------------------===//
284 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
287 Pass
*createLCSSAPass();
288 extern char &LCSSAID
;
290 //===----------------------------------------------------------------------===//
292 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
295 FunctionPass
*createEarlyCSEPass();
297 //===----------------------------------------------------------------------===//
299 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
300 // are hoisted into the header, while stores sink into the footer.
302 FunctionPass
*createMergedLoadStoreMotionPass();
304 //===----------------------------------------------------------------------===//
306 // GVN - This pass performs global value numbering and redundant load
307 // elimination cotemporaneously.
309 FunctionPass
*createGVNPass(bool NoLoads
= false);
311 //===----------------------------------------------------------------------===//
313 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
314 // calls and/or combining multiple stores into memset's.
316 FunctionPass
*createMemCpyOptPass();
318 //===----------------------------------------------------------------------===//
320 // LoopDeletion - This pass performs DCE of non-infinite loops that it
321 // can prove are dead.
323 Pass
*createLoopDeletionPass();
325 //===----------------------------------------------------------------------===//
327 // ConstantHoisting - This pass prepares a function for expensive constants.
329 FunctionPass
*createConstantHoistingPass();
331 //===----------------------------------------------------------------------===//
333 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
335 FunctionPass
*createInstructionNamerPass();
336 extern char &InstructionNamerID
;
338 //===----------------------------------------------------------------------===//
340 // Sink - Code Sinking
342 FunctionPass
*createSinkingPass();
344 //===----------------------------------------------------------------------===//
346 // LowerAtomic - Lower atomic intrinsics to non-atomic form
348 Pass
*createLowerAtomicPass();
350 //===----------------------------------------------------------------------===//
352 // ValuePropagation - Propagate CFG-derived value information
354 Pass
*createCorrelatedValuePropagationPass();
356 //===----------------------------------------------------------------------===//
358 // InstructionSimplifier - Remove redundant instructions.
360 FunctionPass
*createInstructionSimplifierPass();
361 extern char &InstructionSimplifierID
;
363 //===----------------------------------------------------------------------===//
365 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
366 // "block_weights" metadata.
367 FunctionPass
*createLowerExpectIntrinsicPass();
369 //===----------------------------------------------------------------------===//
371 // PartiallyInlineLibCalls - Tries to inline the fast path of library
372 // calls such as sqrt.
374 FunctionPass
*createPartiallyInlineLibCallsPass();
376 //===----------------------------------------------------------------------===//
378 // SampleProfilePass - Loads sample profile data from disk and generates
379 // IR metadata to reflect the profile.
380 FunctionPass
*createSampleProfileLoaderPass();
381 FunctionPass
*createSampleProfileLoaderPass(StringRef Name
);
383 //===----------------------------------------------------------------------===//
385 // ScalarizerPass - Converts vector operations into scalar operations
387 FunctionPass
*createScalarizerPass();
389 //===----------------------------------------------------------------------===//
391 // AddDiscriminators - Add DWARF path discriminators to the IR.
392 FunctionPass
*createAddDiscriminatorsPass();
394 //===----------------------------------------------------------------------===//
396 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
399 createSeparateConstOffsetFromGEPPass(const TargetMachine
*TM
= nullptr,
400 bool LowerGEP
= false);
402 //===----------------------------------------------------------------------===//
404 // LoadCombine - Combine loads into bigger loads.
406 BasicBlockPass
*createLoadCombinePass();
408 // Specific to the rust-lang llvm branch:
409 //===----------------------------------------------------------------------===//
411 // NullCheckElimination - Eliminate null checks.
413 FunctionPass
*createNullCheckEliminationPass();
415 } // End llvm namespace