LLVM  3.7.0
Transforms/Scalar.h
Go to the documentation of this file.
1 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header file defines prototypes for accessor functions that expose passes
11 // in the Scalar transformations library.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TRANSFORMS_SCALAR_H
16 #define LLVM_TRANSFORMS_SCALAR_H
17 
18 #include "llvm/ADT/StringRef.h"
19 #include <functional>
20 
21 namespace llvm {
22 
23 class BasicBlockPass;
24 class Function;
25 class FunctionPass;
26 class ModulePass;
27 class Pass;
28 class GetElementPtrInst;
29 class PassInfo;
30 class TerminatorInst;
31 class TargetLowering;
32 class TargetMachine;
33 
34 //===----------------------------------------------------------------------===//
35 //
36 // ConstantPropagation - A worklist driven constant propagation pass
37 //
38 FunctionPass *createConstantPropagationPass();
39 
40 //===----------------------------------------------------------------------===//
41 //
42 // AlignmentFromAssumptions - Use assume intrinsics to set load/store
43 // alignments.
44 //
46 
47 //===----------------------------------------------------------------------===//
48 //
49 // SCCP - Sparse conditional constant propagation.
50 //
51 FunctionPass *createSCCPPass();
52 
53 //===----------------------------------------------------------------------===//
54 //
55 // DeadInstElimination - This pass quickly removes trivially dead instructions
56 // without modifying the CFG of the function. It is a BasicBlockPass, so it
57 // runs efficiently when queued next to other BasicBlockPass's.
58 //
60 
61 //===----------------------------------------------------------------------===//
62 //
63 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
64 // because it is worklist driven that can potentially revisit instructions when
65 // their other instructions become dead, to eliminate chains of dead
66 // computations.
67 //
68 FunctionPass *createDeadCodeEliminationPass();
69 
70 //===----------------------------------------------------------------------===//
71 //
72 // DeadStoreElimination - This pass deletes stores that are post-dominated by
73 // must-aliased stores and are not loaded used between the stores.
74 //
75 FunctionPass *createDeadStoreEliminationPass();
76 
77 //===----------------------------------------------------------------------===//
78 //
79 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
80 // algorithm assumes instructions are dead until proven otherwise, which makes
81 // it more successful are removing non-obviously dead instructions.
82 //
83 FunctionPass *createAggressiveDCEPass();
84 
85 //===----------------------------------------------------------------------===//
86 //
87 // BitTrackingDCE - This pass uses a bit-tracking DCE algorithm in order to
88 // remove computations of dead bits.
89 //
90 FunctionPass *createBitTrackingDCEPass();
91 
92 //===----------------------------------------------------------------------===//
93 //
94 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
95 //
96 FunctionPass *createSROAPass(bool RequiresDomTree = true);
97 
98 //===----------------------------------------------------------------------===//
99 //
100 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
101 // if possible.
102 //
103 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
104  bool UseDomTree = true,
105  signed StructMemberThreshold = -1,
106  signed ArrayElementThreshold = -1,
107  signed ScalarLoadThreshold = -1);
108 
109 //===----------------------------------------------------------------------===//
110 //
111 // InductiveRangeCheckElimination - Transform loops to elide range checks on
112 // linear functions of the induction variable.
113 //
115 
116 //===----------------------------------------------------------------------===//
117 //
118 // InductionVariableSimplify - Transform induction variables in a program to all
119 // use a single canonical induction variable per loop.
120 //
122 
123 //===----------------------------------------------------------------------===//
124 //
125 // InstructionCombining - Combine instructions to form fewer, simple
126 // instructions. This pass does not modify the CFG, and has a tendency to make
127 // instructions dead, so a subsequent DCE pass is useful.
128 //
129 // This pass combines things like:
130 // %Y = add int 1, %X
131 // %Z = add int 1, %Y
132 // into:
133 // %Z = add int 2, %X
134 //
135 FunctionPass *createInstructionCombiningPass();
136 
137 //===----------------------------------------------------------------------===//
138 //
139 // LICM - This pass is a loop invariant code motion and memory promotion pass.
140 //
142 
143 //===----------------------------------------------------------------------===//
144 //
145 // LoopInterchange - This pass interchanges loops to provide a more
146 // cache-friendly memory access patterns.
147 //
149 
150 //===----------------------------------------------------------------------===//
151 //
152 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
153 // a loop's canonical induction variable as one of their indices.
154 //
156 
157 //===----------------------------------------------------------------------===//
158 //
159 // GlobalMerge - This pass merges internal (by default) globals into structs
160 // to enable reuse of a base pointer by indexed addressing modes.
161 // It can also be configured to focus on size optimizations only.
162 //
163 Pass *createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset,
164  bool OnlyOptimizeForSize = false);
165 
166 //===----------------------------------------------------------------------===//
167 //
168 // LoopUnswitch - This pass is a simple loop unswitching pass.
169 //
170 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
171 
172 //===----------------------------------------------------------------------===//
173 //
174 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
175 //
177 
178 //===----------------------------------------------------------------------===//
179 //
180 // LoopUnroll - This pass is a simple loop unrolling pass.
181 //
182 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1,
183  int AllowPartial = -1, int Runtime = -1);
184 // Create an unrolling pass for full unrolling only.
186 
187 //===----------------------------------------------------------------------===//
188 //
189 // LoopReroll - This pass is a simple loop rerolling pass.
190 //
192 
193 //===----------------------------------------------------------------------===//
194 //
195 // LoopRotate - This pass is a simple loop rotating pass.
196 //
197 Pass *createLoopRotatePass(int MaxHeaderSize = -1);
198 
199 //===----------------------------------------------------------------------===//
200 //
201 // LoopIdiom - This pass recognizes and replaces idioms in loops.
202 //
204 
205 //===----------------------------------------------------------------------===//
206 //
207 // PromoteMemoryToRegister - This pass is used to promote memory references to
208 // be register references. A simple example of the transformation performed by
209 // this pass is:
210 //
211 // FROM CODE TO CODE
212 // %X = alloca i32, i32 1 ret i32 42
213 // store i32 42, i32 *%X
214 // %Y = load i32* %X
215 // ret i32 %Y
216 //
217 FunctionPass *createPromoteMemoryToRegisterPass();
218 
219 //===----------------------------------------------------------------------===//
220 //
221 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
222 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
223 // hacking easier.
224 //
225 FunctionPass *createDemoteRegisterToMemoryPass();
226 extern char &DemoteRegisterToMemoryID;
227 
228 //===----------------------------------------------------------------------===//
229 //
230 // Reassociate - This pass reassociates commutative expressions in an order that
231 // is designed to promote better constant propagation, GCSE, LICM, PRE...
232 //
233 // For example: 4 + (x + 5) -> x + (4 + 5)
234 //
235 FunctionPass *createReassociatePass();
236 
237 //===----------------------------------------------------------------------===//
238 //
239 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
240 // preds always go to some succ. Thresholds other than minus one override the
241 // internal BB duplication default threshold.
242 //
243 FunctionPass *createJumpThreadingPass(int Threshold = -1);
244 
245 //===----------------------------------------------------------------------===//
246 //
247 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
248 // simplify terminator instructions, etc...
249 //
250 FunctionPass *createCFGSimplificationPass(
251  int Threshold = -1, std::function<bool(const Function &)> Ftor = nullptr);
252 
253 //===----------------------------------------------------------------------===//
254 //
255 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
256 // parallel-and and parallel-or mode, etc...
257 //
258 FunctionPass *createFlattenCFGPass();
259 
260 //===----------------------------------------------------------------------===//
261 //
262 // CFG Structurization - Remove irreducible control flow
263 //
265 
266 //===----------------------------------------------------------------------===//
267 //
268 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
269 // a dummy basic block. This pass may be "required" by passes that cannot deal
270 // with critical edges. For this usage, a pass must call:
271 //
272 // AU.addRequiredID(BreakCriticalEdgesID);
273 //
274 // This pass obviously invalidates the CFG, but can update forward dominator
275 // (set, immediate dominators, tree, and frontier) information.
276 //
277 FunctionPass *createBreakCriticalEdgesPass();
278 extern char &BreakCriticalEdgesID;
279 
280 //===----------------------------------------------------------------------===//
281 //
282 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
283 // the module. This pass updates dominator information, loop information, and
284 // does not add critical edges to the CFG.
285 //
286 // AU.addRequiredID(LoopSimplifyID);
287 //
289 extern char &LoopSimplifyID;
290 
291 //===----------------------------------------------------------------------===//
292 //
293 // TailCallElimination - This pass eliminates call instructions to the current
294 // function which occur immediately before return instructions.
295 //
296 FunctionPass *createTailCallEliminationPass();
297 
298 //===----------------------------------------------------------------------===//
299 //
300 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
301 // chained binary branch instructions.
302 //
303 FunctionPass *createLowerSwitchPass();
304 extern char &LowerSwitchID;
305 
306 //===----------------------------------------------------------------------===//
307 //
308 // LowerInvoke - This pass removes invoke instructions, converting them to call
309 // instructions.
310 //
311 FunctionPass *createLowerInvokePass();
312 extern char &LowerInvokePassID;
313 
314 //===----------------------------------------------------------------------===//
315 //
316 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
317 // optimizations.
318 //
320 extern char &LCSSAID;
321 
322 //===----------------------------------------------------------------------===//
323 //
324 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
325 // tree.
326 //
327 FunctionPass *createEarlyCSEPass();
328 
329 //===----------------------------------------------------------------------===//
330 //
331 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
332 // are hoisted into the header, while stores sink into the footer.
333 //
334 FunctionPass *createMergedLoadStoreMotionPass();
335 
336 //===----------------------------------------------------------------------===//
337 //
338 // GVN - This pass performs global value numbering and redundant load
339 // elimination cotemporaneously.
340 //
341 FunctionPass *createGVNPass(bool NoLoads = false);
342 
343 //===----------------------------------------------------------------------===//
344 //
345 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
346 // calls and/or combining multiple stores into memset's.
347 //
348 FunctionPass *createMemCpyOptPass();
349 
350 //===----------------------------------------------------------------------===//
351 //
352 // LoopDeletion - This pass performs DCE of non-infinite loops that it
353 // can prove are dead.
354 //
356 
357 //===----------------------------------------------------------------------===//
358 //
359 // ConstantHoisting - This pass prepares a function for expensive constants.
360 //
361 FunctionPass *createConstantHoistingPass();
362 
363 //===----------------------------------------------------------------------===//
364 //
365 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
366 //
367 FunctionPass *createInstructionNamerPass();
368 extern char &InstructionNamerID;
369 
370 //===----------------------------------------------------------------------===//
371 //
372 // Sink - Code Sinking
373 //
374 FunctionPass *createSinkingPass();
375 
376 //===----------------------------------------------------------------------===//
377 //
378 // LowerAtomic - Lower atomic intrinsics to non-atomic form
379 //
381 
382 //===----------------------------------------------------------------------===//
383 //
384 // ValuePropagation - Propagate CFG-derived value information
385 //
387 
388 //===----------------------------------------------------------------------===//
389 //
390 // InstructionSimplifier - Remove redundant instructions.
391 //
392 FunctionPass *createInstructionSimplifierPass();
393 extern char &InstructionSimplifierID;
394 
395 //===----------------------------------------------------------------------===//
396 //
397 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
398 // "block_weights" metadata.
399 FunctionPass *createLowerExpectIntrinsicPass();
400 
401 //===----------------------------------------------------------------------===//
402 //
403 // PartiallyInlineLibCalls - Tries to inline the fast path of library
404 // calls such as sqrt.
405 //
406 FunctionPass *createPartiallyInlineLibCallsPass();
407 
408 //===----------------------------------------------------------------------===//
409 //
410 // SampleProfilePass - Loads sample profile data from disk and generates
411 // IR metadata to reflect the profile.
412 FunctionPass *createSampleProfileLoaderPass();
413 FunctionPass *createSampleProfileLoaderPass(StringRef Name);
414 
415 //===----------------------------------------------------------------------===//
416 //
417 // ScalarizerPass - Converts vector operations into scalar operations
418 //
419 FunctionPass *createScalarizerPass();
420 
421 //===----------------------------------------------------------------------===//
422 //
423 // AddDiscriminators - Add DWARF path discriminators to the IR.
424 FunctionPass *createAddDiscriminatorsPass();
425 
426 //===----------------------------------------------------------------------===//
427 //
428 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
429 //
430 FunctionPass *
431 createSeparateConstOffsetFromGEPPass(const TargetMachine *TM = nullptr,
432  bool LowerGEP = false);
433 
434 //===----------------------------------------------------------------------===//
435 //
436 // SpeculativeExecution - Aggressively hoist instructions to enable
437 // speculative execution on targets where branches are expensive.
438 //
439 FunctionPass *createSpeculativeExecutionPass();
440 
441 //===----------------------------------------------------------------------===//
442 //
443 // LoadCombine - Combine loads into bigger loads.
444 //
445 BasicBlockPass *createLoadCombinePass();
446 
447 //===----------------------------------------------------------------------===//
448 //
449 // StraightLineStrengthReduce - This pass strength-reduces some certain
450 // instruction patterns in straight-line code.
451 //
453 
454 //===----------------------------------------------------------------------===//
455 //
456 // PlaceSafepoints - Rewrite any IR calls to gc.statepoints and insert any
457 // safepoint polls (method entry, backedge) that might be required. This pass
458 // does not generate explicit relocation sequences - that's handled by
459 // RewriteStatepointsForGC which can be run at an arbitrary point in the pass
460 // order following this pass.
461 //
462 FunctionPass *createPlaceSafepointsPass();
463 
464 //===----------------------------------------------------------------------===//
465 //
466 // RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
467 // explicit relocations to include explicit relocations.
468 //
470 
471 //===----------------------------------------------------------------------===//
472 //
473 // Float2Int - Demote floats to ints where possible.
474 //
475 FunctionPass *createFloat2IntPass();
476 
477 //===----------------------------------------------------------------------===//
478 //
479 // NaryReassociate - Simplify n-ary operations by reassociation.
480 //
481 FunctionPass *createNaryReassociatePass();
482 
483 //===----------------------------------------------------------------------===//
484 //
485 // LoopDistribute - Distribute loops.
486 //
487 FunctionPass *createLoopDistributePass();
488 
489 } // End llvm namespace
490 
491 #endif
FunctionPass * createSpeculativeExecutionPass()
FunctionPass * createStraightLineStrengthReducePass()
FunctionPass * createGVNPass(bool NoLoads=false)
Definition: GVN.cpp:732
Pass * createLoopRerollPass()
Pass * createLoopSimplifyPass()
Pass * createLoopStrengthReducePass()
FunctionPass * createLowerSwitchPass()
FunctionPass * createScalarReplAggregatesPass(signed Threshold=-1, bool UseDomTree=true, signed StructMemberThreshold=-1, signed ArrayElementThreshold=-1, signed ScalarLoadThreshold=-1)
Pass * createDeadInstEliminationPass()
char & DemoteRegisterToMemoryID
Definition: Reg2Mem.cpp:130
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:537
char & LowerSwitchID
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:131
FunctionPass * createAlignmentFromAssumptionsPass()
FunctionPass * createJumpThreadingPass(int Threshold=-1)
FunctionPass * createSROAPass(bool RequiresDomTree=true)
Definition: SROA.cpp:1275
FunctionPass * createConstantPropagationPass()
FunctionPass * createReassociatePass()
FunctionPass * createSinkingPass()
Definition: Sink.cpp:72
char & InstructionSimplifierID
FunctionPass * createDeadCodeEliminationPass()
Definition: DCE.cpp:139
FunctionPass * createLoopDistributePass()
Pass * createLoopUnswitchPass(bool OptimizeForSize=false)
Pass * createLoopInstSimplifyPass()
Pass * createLoopUnrollPass(int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1)
FunctionPass * createInstructionCombiningPass()
Pass * createCorrelatedValuePropagationPass()
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
FunctionPass * createSeparateConstOffsetFromGEPPass(const TargetMachine *TM=nullptr, bool LowerGEP=false)
FunctionPass * createPlaceSafepointsPass()
FunctionPass * createFlattenCFGPass()
FunctionPass * createTailCallEliminationPass()
char & BreakCriticalEdgesID
FunctionPass * createBreakCriticalEdgesPass()
char & LCSSAID
Definition: LCSSA.cpp:312
FunctionPass * createCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createMemCpyOptPass()
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:407
FunctionPass * createEarlyCSEPass()
Definition: EarlyCSE.cpp:771
aarch64 type AArch64 Type Promotion Pass
char & LowerInvokePassID
char & LoopSimplifyID
Pass * createLCSSAPass()
Definition: LCSSA.cpp:311
BasicBlockPass * createLoadCombinePass()
Pass * createLoopInterchangePass()
FunctionPass * createDeadStoreEliminationPass()
Pass * createLowerAtomicPass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
Pass * createLoopDeletionPass()
Pass * createLICMPass()
Definition: LICM.cpp:172
Pass * createLoopIdiomPass()
FunctionPass * createSampleProfileLoaderPass()
FunctionPass * createSCCPPass()
FunctionPass * createPartiallyInlineLibCallsPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:97
FunctionPass * createLowerInvokePass()
char & InstructionNamerID
FunctionPass * createInstructionNamerPass()
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:94
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
Pass * createSimpleLoopUnrollPass()
ModulePass * createRewriteStatepointsForGCPass()
FunctionPass * createAddDiscriminatorsPass()
Pass * createStructurizeCFGPass()
Create the pass.
print Print MemDeps of function
FunctionPass * createScalarizerPass()
Definition: Scalarizer.cpp:674
FunctionPass * createInstructionSimplifierPass()
Pass * createIndVarSimplifyPass()
Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false)
Pass * createInductiveRangeCheckEliminationPass()
FunctionPass * createLowerExpectIntrinsicPass()
FunctionPass * createConstantHoistingPass()
FunctionPass * createNaryReassociatePass()