]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Transforms/Scalar.h
Update lldb to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Transforms / Scalar.h
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 <functional>
19
20 namespace llvm {
21
22 class BasicBlockPass;
23 class Function;
24 class FunctionPass;
25 class ModulePass;
26 class Pass;
27 class GetElementPtrInst;
28 class PassInfo;
29 class TerminatorInst;
30 class TargetLowering;
31 class TargetMachine;
32
33 //===----------------------------------------------------------------------===//
34 //
35 // ConstantPropagation - A worklist driven constant propagation pass
36 //
37 FunctionPass *createConstantPropagationPass();
38
39 //===----------------------------------------------------------------------===//
40 //
41 // AlignmentFromAssumptions - Use assume intrinsics to set load/store
42 // alignments.
43 //
44 FunctionPass *createAlignmentFromAssumptionsPass();
45
46 //===----------------------------------------------------------------------===//
47 //
48 // SCCP - Sparse conditional constant propagation.
49 //
50 FunctionPass *createSCCPPass();
51
52 //===----------------------------------------------------------------------===//
53 //
54 // DeadInstElimination - This pass quickly removes trivially dead instructions
55 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
56 // runs efficiently when queued next to other BasicBlockPass's.
57 //
58 Pass *createDeadInstEliminationPass();
59
60 //===----------------------------------------------------------------------===//
61 //
62 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
63 // because it is worklist driven that can potentially revisit instructions when
64 // their other instructions become dead, to eliminate chains of dead
65 // computations.
66 //
67 FunctionPass *createDeadCodeEliminationPass();
68
69 //===----------------------------------------------------------------------===//
70 //
71 // DeadStoreElimination - This pass deletes stores that are post-dominated by
72 // must-aliased stores and are not loaded used between the stores.
73 //
74 FunctionPass *createDeadStoreEliminationPass();
75
76 //===----------------------------------------------------------------------===//
77 //
78 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
79 // algorithm assumes instructions are dead until proven otherwise, which makes
80 // it more successful are removing non-obviously dead instructions.
81 //
82 FunctionPass *createAggressiveDCEPass();
83
84
85 //===----------------------------------------------------------------------===//
86 //
87 // GuardWidening - An optimization over the @llvm.experimental.guard intrinsic
88 // that (optimistically) combines multiple guards into one to have fewer checks
89 // at runtime.
90 //
91 FunctionPass *createGuardWideningPass();
92
93
94 //===----------------------------------------------------------------------===//
95 //
96 // BitTrackingDCE - This pass uses a bit-tracking DCE algorithm in order to
97 // remove computations of dead bits.
98 //
99 FunctionPass *createBitTrackingDCEPass();
100
101 //===----------------------------------------------------------------------===//
102 //
103 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
104 //
105 FunctionPass *createSROAPass();
106
107 //===----------------------------------------------------------------------===//
108 //
109 // InductiveRangeCheckElimination - Transform loops to elide range checks on
110 // linear functions of the induction variable.
111 //
112 Pass *createInductiveRangeCheckEliminationPass();
113
114 //===----------------------------------------------------------------------===//
115 //
116 // InductionVariableSimplify - Transform induction variables in a program to all
117 // use a single canonical induction variable per loop.
118 //
119 Pass *createIndVarSimplifyPass();
120
121 //===----------------------------------------------------------------------===//
122 //
123 // InstructionCombining - Combine instructions to form fewer, simple
124 // instructions. This pass does not modify the CFG, and has a tendency to make
125 // instructions dead, so a subsequent DCE pass is useful.
126 //
127 // This pass combines things like:
128 //    %Y = add int 1, %X
129 //    %Z = add int 1, %Y
130 // into:
131 //    %Z = add int 2, %X
132 //
133 FunctionPass *createInstructionCombiningPass(bool ExpensiveCombines = true);
134
135 //===----------------------------------------------------------------------===//
136 //
137 // LICM - This pass is a loop invariant code motion and memory promotion pass.
138 //
139 Pass *createLICMPass();
140
141 //===----------------------------------------------------------------------===//
142 //
143 // LoopSink - This pass sinks invariants from preheader to loop body where
144 // frequency is lower than loop preheader.
145 //
146 Pass *createLoopSinkPass();
147
148 //===----------------------------------------------------------------------===//
149 //
150 // LoopInterchange - This pass interchanges loops to provide a more
151 // cache-friendly memory access patterns.
152 //
153 Pass *createLoopInterchangePass();
154
155 //===----------------------------------------------------------------------===//
156 //
157 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
158 // a loop's canonical induction variable as one of their indices.
159 //
160 Pass *createLoopStrengthReducePass();
161
162 //===----------------------------------------------------------------------===//
163 //
164 // LoopUnswitch - This pass is a simple loop unswitching pass.
165 //
166 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
167
168 //===----------------------------------------------------------------------===//
169 //
170 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
171 //
172 Pass *createLoopInstSimplifyPass();
173
174 //===----------------------------------------------------------------------===//
175 //
176 // LoopUnroll - This pass is a simple loop unrolling pass.
177 //
178 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1,
179                            int AllowPartial = -1, int Runtime = -1,
180                            int UpperBound = -1);
181 // Create an unrolling pass for full unrolling that uses exact trip count only.
182 Pass *createSimpleLoopUnrollPass();
183
184 //===----------------------------------------------------------------------===//
185 //
186 // LoopReroll - This pass is a simple loop rerolling pass.
187 //
188 Pass *createLoopRerollPass();
189
190 //===----------------------------------------------------------------------===//
191 //
192 // LoopRotate - This pass is a simple loop rotating pass.
193 //
194 Pass *createLoopRotatePass(int MaxHeaderSize = -1);
195
196 //===----------------------------------------------------------------------===//
197 //
198 // LoopIdiom - This pass recognizes and replaces idioms in loops.
199 //
200 Pass *createLoopIdiomPass();
201
202 //===----------------------------------------------------------------------===//
203 //
204 // LoopVersioningLICM - This pass is a loop versioning pass for LICM.
205 //
206 Pass *createLoopVersioningLICMPass();
207
208 //===----------------------------------------------------------------------===//
209 //
210 // PromoteMemoryToRegister - This pass is used to promote memory references to
211 // be register references. A simple example of the transformation performed by
212 // this pass is:
213 //
214 //        FROM CODE                           TO CODE
215 //   %X = alloca i32, i32 1                 ret i32 42
216 //   store i32 42, i32 *%X
217 //   %Y = load i32* %X
218 //   ret i32 %Y
219 //
220 FunctionPass *createPromoteMemoryToRegisterPass();
221
222 //===----------------------------------------------------------------------===//
223 //
224 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
225 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
226 // hacking easier.
227 //
228 FunctionPass *createDemoteRegisterToMemoryPass();
229 extern char &DemoteRegisterToMemoryID;
230
231 //===----------------------------------------------------------------------===//
232 //
233 // Reassociate - This pass reassociates commutative expressions in an order that
234 // is designed to promote better constant propagation, GCSE, LICM, PRE...
235 //
236 // For example:  4 + (x + 5)  ->  x + (4 + 5)
237 //
238 FunctionPass *createReassociatePass();
239
240 //===----------------------------------------------------------------------===//
241 //
242 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
243 // preds always go to some succ. Thresholds other than minus one override the
244 // internal BB duplication default threshold.
245 //
246 FunctionPass *createJumpThreadingPass(int Threshold = -1);
247
248 //===----------------------------------------------------------------------===//
249 //
250 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
251 // simplify terminator instructions, etc...
252 //
253 FunctionPass *createCFGSimplificationPass(
254     int Threshold = -1, std::function<bool(const Function &)> Ftor = nullptr);
255
256 //===----------------------------------------------------------------------===//
257 //
258 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
259 // parallel-and and parallel-or mode, etc...
260 //
261 FunctionPass *createFlattenCFGPass();
262
263 //===----------------------------------------------------------------------===//
264 //
265 // CFG Structurization - Remove irreducible control flow
266 //
267 ///
268 /// When \p SkipUniformRegions is true the structizer will not structurize
269 /// regions that only contain uniform branches.
270 Pass *createStructurizeCFGPass(bool SkipUniformRegions = false);
271
272 //===----------------------------------------------------------------------===//
273 //
274 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
275 // a dummy basic block. This pass may be "required" by passes that cannot deal
276 // with critical edges. For this usage, a pass must call:
277 //
278 //   AU.addRequiredID(BreakCriticalEdgesID);
279 //
280 // This pass obviously invalidates the CFG, but can update forward dominator
281 // (set, immediate dominators, tree, and frontier) information.
282 //
283 FunctionPass *createBreakCriticalEdgesPass();
284 extern char &BreakCriticalEdgesID;
285
286 //===----------------------------------------------------------------------===//
287 //
288 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
289 // the module.  This pass updates dominator information, loop information, and
290 // does not add critical edges to the CFG.
291 //
292 //   AU.addRequiredID(LoopSimplifyID);
293 //
294 Pass *createLoopSimplifyPass();
295 extern char &LoopSimplifyID;
296
297 //===----------------------------------------------------------------------===//
298 //
299 // TailCallElimination - This pass eliminates call instructions to the current
300 // function which occur immediately before return instructions.
301 //
302 FunctionPass *createTailCallEliminationPass();
303
304 //===----------------------------------------------------------------------===//
305 //
306 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
307 // chained binary branch instructions.
308 //
309 FunctionPass *createLowerSwitchPass();
310 extern char &LowerSwitchID;
311
312 //===----------------------------------------------------------------------===//
313 //
314 // LowerInvoke - This pass removes invoke instructions, converting them to call
315 // instructions.
316 //
317 FunctionPass *createLowerInvokePass();
318 extern char &LowerInvokePassID;
319
320 //===----------------------------------------------------------------------===//
321 //
322 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
323 // optimizations.
324 //
325 Pass *createLCSSAPass();
326 extern char &LCSSAID;
327
328 //===----------------------------------------------------------------------===//
329 //
330 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
331 // tree.
332 //
333 FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false);
334
335 //===----------------------------------------------------------------------===//
336 //
337 // GVNHoist - This pass performs a simple and fast GVN pass over the dominator
338 // tree to hoist common expressions from sibling branches.
339 //
340 FunctionPass *createGVNHoistPass();
341
342 //===----------------------------------------------------------------------===//
343 //
344 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
345 // are hoisted into the header, while stores sink into the footer.
346 //
347 FunctionPass *createMergedLoadStoreMotionPass();
348
349 //===----------------------------------------------------------------------===//
350 //
351 // GVN - This pass performs global value numbering and redundant load
352 // elimination cotemporaneously.
353 //
354 FunctionPass *createNewGVNPass();
355
356 //===----------------------------------------------------------------------===//
357 //
358 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
359 // calls and/or combining multiple stores into memset's.
360 //
361 FunctionPass *createMemCpyOptPass();
362
363 //===----------------------------------------------------------------------===//
364 //
365 // LoopDeletion - This pass performs DCE of non-infinite loops that it
366 // can prove are dead.
367 //
368 Pass *createLoopDeletionPass();
369
370 //===----------------------------------------------------------------------===//
371 //
372 // ConstantHoisting - This pass prepares a function for expensive constants.
373 //
374 FunctionPass *createConstantHoistingPass();
375
376 //===----------------------------------------------------------------------===//
377 //
378 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
379 //
380 FunctionPass *createInstructionNamerPass();
381 extern char &InstructionNamerID;
382
383 //===----------------------------------------------------------------------===//
384 //
385 // Sink - Code Sinking
386 //
387 FunctionPass *createSinkingPass();
388
389 //===----------------------------------------------------------------------===//
390 //
391 // LowerAtomic - Lower atomic intrinsics to non-atomic form
392 //
393 Pass *createLowerAtomicPass();
394
395 //===----------------------------------------------------------------------===//
396 //
397 // LowerGuardIntrinsic - Lower guard intrinsics to normal control flow.
398 //
399 Pass *createLowerGuardIntrinsicPass();
400
401 //===----------------------------------------------------------------------===//
402 //
403 // ValuePropagation - Propagate CFG-derived value information
404 //
405 Pass *createCorrelatedValuePropagationPass();
406
407 //===----------------------------------------------------------------------===//
408 //
409 // InstructionSimplifier - Remove redundant instructions.
410 //
411 FunctionPass *createInstructionSimplifierPass();
412 extern char &InstructionSimplifierID;
413
414 //===----------------------------------------------------------------------===//
415 //
416 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
417 // "block_weights" metadata.
418 FunctionPass *createLowerExpectIntrinsicPass();
419
420 //===----------------------------------------------------------------------===//
421 //
422 // PartiallyInlineLibCalls - Tries to inline the fast path of library
423 // calls such as sqrt.
424 //
425 FunctionPass *createPartiallyInlineLibCallsPass();
426
427 //===----------------------------------------------------------------------===//
428 //
429 // ScalarizerPass - Converts vector operations into scalar operations
430 //
431 FunctionPass *createScalarizerPass();
432
433 //===----------------------------------------------------------------------===//
434 //
435 // AddDiscriminators - Add DWARF path discriminators to the IR.
436 FunctionPass *createAddDiscriminatorsPass();
437
438 //===----------------------------------------------------------------------===//
439 //
440 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
441 //
442 FunctionPass *
443 createSeparateConstOffsetFromGEPPass(const TargetMachine *TM = nullptr,
444                                      bool LowerGEP = false);
445
446 //===----------------------------------------------------------------------===//
447 //
448 // SpeculativeExecution - Aggressively hoist instructions to enable
449 // speculative execution on targets where branches are expensive.
450 //
451 FunctionPass *createSpeculativeExecutionPass();
452
453 // Same as createSpeculativeExecutionPass, but does nothing unless
454 // TargetTransformInfo::hasBranchDivergence() is true.
455 FunctionPass *createSpeculativeExecutionIfHasBranchDivergencePass();
456
457 //===----------------------------------------------------------------------===//
458 //
459 // LoadCombine - Combine loads into bigger loads.
460 //
461 BasicBlockPass *createLoadCombinePass();
462
463 //===----------------------------------------------------------------------===//
464 //
465 // StraightLineStrengthReduce - This pass strength-reduces some certain
466 // instruction patterns in straight-line code.
467 //
468 FunctionPass *createStraightLineStrengthReducePass();
469
470 //===----------------------------------------------------------------------===//
471 //
472 // PlaceSafepoints - Rewrite any IR calls to gc.statepoints and insert any
473 // safepoint polls (method entry, backedge) that might be required.  This pass
474 // does not generate explicit relocation sequences - that's handled by
475 // RewriteStatepointsForGC which can be run at an arbitrary point in the pass
476 // order following this pass.
477 //
478 FunctionPass *createPlaceSafepointsPass();
479
480 //===----------------------------------------------------------------------===//
481 //
482 // RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
483 // explicit relocations to include explicit relocations.
484 //
485 ModulePass *createRewriteStatepointsForGCPass();
486
487 //===----------------------------------------------------------------------===//
488 //
489 // StripGCRelocates - Remove GC relocates that have been inserted by
490 // RewriteStatepointsForGC. The resulting IR is incorrect, but this is useful
491 // for manual inspection.
492 FunctionPass *createStripGCRelocatesPass();
493
494 //===----------------------------------------------------------------------===//
495 //
496 // Float2Int - Demote floats to ints where possible.
497 //
498 FunctionPass *createFloat2IntPass();
499
500 //===----------------------------------------------------------------------===//
501 //
502 // NaryReassociate - Simplify n-ary operations by reassociation.
503 //
504 FunctionPass *createNaryReassociatePass();
505
506 //===----------------------------------------------------------------------===//
507 //
508 // LoopDistribute - Distribute loops.
509 //
510 FunctionPass *createLoopDistributePass();
511
512 //===----------------------------------------------------------------------===//
513 //
514 // LoopLoadElimination - Perform loop-aware load elimination.
515 //
516 FunctionPass *createLoopLoadEliminationPass();
517
518 //===----------------------------------------------------------------------===//
519 //
520 // LoopSimplifyCFG - This pass performs basic CFG simplification on loops,
521 // primarily to help other loop passes.
522 //
523 Pass *createLoopSimplifyCFGPass();
524
525 //===----------------------------------------------------------------------===//
526 //
527 // LoopVersioning - Perform loop multi-versioning.
528 //
529 FunctionPass *createLoopVersioningPass();
530
531 //===----------------------------------------------------------------------===//
532 //
533 // LoopDataPrefetch - Perform data prefetching in loops.
534 //
535 FunctionPass *createLoopDataPrefetchPass();
536
537 ///===---------------------------------------------------------------------===//
538 ModulePass *createNameAnonGlobalPass();
539
540 //===----------------------------------------------------------------------===//
541 //
542 // LibCallsShrinkWrap - Shrink-wraps a call to function if the result is not
543 // used.
544 //
545 FunctionPass *createLibCallsShrinkWrapPass();
546 } // End llvm namespace
547
548 #endif