LLVM  7.0.0svn
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 <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 //
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 //
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 //
79 // CallSiteSplitting - This pass split call-site based on its known argument
80 // values.
81 FunctionPass *createCallSiteSplittingPass();
82 
83 
84 //===----------------------------------------------------------------------===//
85 //
86 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
87 // algorithm assumes instructions are dead until proven otherwise, which makes
88 // it more successful are removing non-obviously dead instructions.
89 //
90 FunctionPass *createAggressiveDCEPass();
91 
92 
93 //===----------------------------------------------------------------------===//
94 //
95 // GuardWidening - An optimization over the @llvm.experimental.guard intrinsic
96 // that (optimistically) combines multiple guards into one to have fewer checks
97 // at runtime.
98 //
99 FunctionPass *createGuardWideningPass();
100 
101 
102 //===----------------------------------------------------------------------===//
103 //
104 // BitTrackingDCE - This pass uses a bit-tracking DCE algorithm in order to
105 // remove computations of dead bits.
106 //
107 FunctionPass *createBitTrackingDCEPass();
108 
109 //===----------------------------------------------------------------------===//
110 //
111 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
112 //
113 FunctionPass *createSROAPass();
114 
115 //===----------------------------------------------------------------------===//
116 //
117 // InductiveRangeCheckElimination - Transform loops to elide range checks on
118 // linear functions of the induction variable.
119 //
121 
122 //===----------------------------------------------------------------------===//
123 //
124 // InductionVariableSimplify - Transform induction variables in a program to all
125 // use a single canonical induction variable per loop.
126 //
128 
129 //===----------------------------------------------------------------------===//
130 //
131 // InstructionCombining - Combine instructions to form fewer, simple
132 // instructions. This pass does not modify the CFG, and has a tendency to make
133 // instructions dead, so a subsequent DCE pass is useful.
134 //
135 // This pass combines things like:
136 // %Y = add int 1, %X
137 // %Z = add int 1, %Y
138 // into:
139 // %Z = add int 2, %X
140 //
141 FunctionPass *createInstructionCombiningPass(bool ExpensiveCombines = true);
142 
143 //===----------------------------------------------------------------------===//
144 //
145 // AggressiveInstCombiner - Combine expression patterns to form expressions with
146 // fewer, simple instructions. This pass does not modify the CFG.
147 //
148 FunctionPass *createAggressiveInstCombinerPass();
149 
150 //===----------------------------------------------------------------------===//
151 //
152 // LICM - This pass is a loop invariant code motion and memory promotion pass.
153 //
155 
156 //===----------------------------------------------------------------------===//
157 //
158 // LoopSink - This pass sinks invariants from preheader to loop body where
159 // frequency is lower than loop preheader.
160 //
162 
163 //===----------------------------------------------------------------------===//
164 //
165 // LoopPredication - This pass does loop predication on guards.
166 //
168 
169 //===----------------------------------------------------------------------===//
170 //
171 // LoopInterchange - This pass interchanges loops to provide a more
172 // cache-friendly memory access patterns.
173 //
175 
176 //===----------------------------------------------------------------------===//
177 //
178 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
179 // a loop's canonical induction variable as one of their indices.
180 //
182 
183 //===----------------------------------------------------------------------===//
184 //
185 // LoopUnswitch - This pass is a simple loop unswitching pass.
186 //
187 Pass *createLoopUnswitchPass(bool OptimizeForSize = false,
188  bool hasBranchDivergence = false);
189 
190 //===----------------------------------------------------------------------===//
191 //
192 // LoopUnroll - This pass is a simple loop unrolling pass.
193 //
194 Pass *createLoopUnrollPass(int OptLevel = 2, int Threshold = -1, int Count = -1,
195  int AllowPartial = -1, int Runtime = -1,
196  int UpperBound = -1, int AllowPeeling = -1);
197 // Create an unrolling pass for full unrolling that uses exact trip count only.
198 Pass *createSimpleLoopUnrollPass(int OptLevel = 2);
199 
200 //===----------------------------------------------------------------------===//
201 //
202 // LoopReroll - This pass is a simple loop rerolling pass.
203 //
205 
206 //===----------------------------------------------------------------------===//
207 //
208 // LoopRotate - This pass is a simple loop rotating pass.
209 //
210 Pass *createLoopRotatePass(int MaxHeaderSize = -1);
211 
212 //===----------------------------------------------------------------------===//
213 //
214 // LoopIdiom - This pass recognizes and replaces idioms in loops.
215 //
217 
218 //===----------------------------------------------------------------------===//
219 //
220 // LoopVersioningLICM - This pass is a loop versioning pass for LICM.
221 //
223 
224 //===----------------------------------------------------------------------===//
225 //
226 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
227 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
228 // hacking easier.
229 //
230 FunctionPass *createDemoteRegisterToMemoryPass();
231 extern char &DemoteRegisterToMemoryID;
232 
233 //===----------------------------------------------------------------------===//
234 //
235 // Reassociate - This pass reassociates commutative expressions in an order that
236 // is designed to promote better constant propagation, GCSE, LICM, PRE...
237 //
238 // For example: 4 + (x + 5) -> x + (4 + 5)
239 //
240 FunctionPass *createReassociatePass();
241 
242 //===----------------------------------------------------------------------===//
243 //
244 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
245 // preds always go to some succ. Thresholds other than minus one override the
246 // internal BB duplication default threshold.
247 //
248 FunctionPass *createJumpThreadingPass(int Threshold = -1);
249 
250 //===----------------------------------------------------------------------===//
251 //
252 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
253 // simplify terminator instructions, convert switches to lookup tables, etc.
254 //
255 FunctionPass *createCFGSimplificationPass(
256  unsigned Threshold = 1, bool ForwardSwitchCond = false,
257  bool ConvertSwitch = false, bool KeepLoops = true, bool SinkCommon = false,
258  std::function<bool(const Function &)> Ftor = nullptr);
259 
260 //===----------------------------------------------------------------------===//
261 //
262 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
263 // parallel-and and parallel-or mode, etc...
264 //
265 FunctionPass *createFlattenCFGPass();
266 
267 //===----------------------------------------------------------------------===//
268 //
269 // CFG Structurization - Remove irreducible control flow
270 //
271 ///
272 /// When \p SkipUniformRegions is true the structizer will not structurize
273 /// regions that only contain uniform branches.
274 Pass *createStructurizeCFGPass(bool SkipUniformRegions = false);
275 
276 //===----------------------------------------------------------------------===//
277 //
278 // TailCallElimination - This pass eliminates call instructions to the current
279 // function which occur immediately before return instructions.
280 //
281 FunctionPass *createTailCallEliminationPass();
282 
283 //===----------------------------------------------------------------------===//
284 //
285 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
286 // tree.
287 //
288 FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false);
289 
290 //===----------------------------------------------------------------------===//
291 //
292 // GVNHoist - This pass performs a simple and fast GVN pass over the dominator
293 // tree to hoist common expressions from sibling branches.
294 //
295 FunctionPass *createGVNHoistPass();
296 
297 //===----------------------------------------------------------------------===//
298 //
299 // GVNSink - This pass uses an "inverted" value numbering to decide the
300 // similarity of expressions and sinks similar expressions into successors.
301 //
302 FunctionPass *createGVNSinkPass();
303 
304 //===----------------------------------------------------------------------===//
305 //
306 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
307 // are hoisted into the header, while stores sink into the footer.
308 //
309 FunctionPass *createMergedLoadStoreMotionPass();
310 
311 //===----------------------------------------------------------------------===//
312 //
313 // GVN - This pass performs global value numbering and redundant load
314 // elimination cotemporaneously.
315 //
316 FunctionPass *createNewGVNPass();
317 
318 //===----------------------------------------------------------------------===//
319 //
320 // DivRemPairs - Hoist/decompose integer division and remainder instructions.
321 //
322 FunctionPass *createDivRemPairsPass();
323 
324 //===----------------------------------------------------------------------===//
325 //
326 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
327 // calls and/or combining multiple stores into memset's.
328 //
329 FunctionPass *createMemCpyOptPass();
330 
331 //===----------------------------------------------------------------------===//
332 //
333 // LoopDeletion - This pass performs DCE of non-infinite loops that it
334 // can prove are dead.
335 //
337 
338 //===----------------------------------------------------------------------===//
339 //
340 // ConstantHoisting - This pass prepares a function for expensive constants.
341 //
342 FunctionPass *createConstantHoistingPass();
343 
344 //===----------------------------------------------------------------------===//
345 //
346 // Sink - Code Sinking
347 //
348 FunctionPass *createSinkingPass();
349 
350 //===----------------------------------------------------------------------===//
351 //
352 // LowerAtomic - Lower atomic intrinsics to non-atomic form
353 //
355 
356 //===----------------------------------------------------------------------===//
357 //
358 // LowerGuardIntrinsic - Lower guard intrinsics to normal control flow.
359 //
361 
362 //===----------------------------------------------------------------------===//
363 //
364 // MergeICmps - Merge integer comparison chains into a memcmp
365 //
367 
368 //===----------------------------------------------------------------------===//
369 //
370 // ValuePropagation - Propagate CFG-derived value information
371 //
373 
374 //===----------------------------------------------------------------------===//
375 //
376 // InferAddressSpaces - Modify users of addrspacecast instructions with values
377 // in the source address space if using the destination address space is slower
378 // on the target.
379 //
380 FunctionPass *createInferAddressSpacesPass();
381 extern char &InferAddressSpacesID;
382 
383 //===----------------------------------------------------------------------===//
384 //
385 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
386 // "block_weights" metadata.
387 FunctionPass *createLowerExpectIntrinsicPass();
388 
389 //===----------------------------------------------------------------------===//
390 //
391 // PartiallyInlineLibCalls - Tries to inline the fast path of library
392 // calls such as sqrt.
393 //
394 FunctionPass *createPartiallyInlineLibCallsPass();
395 
396 //===----------------------------------------------------------------------===//
397 //
398 // ScalarizerPass - Converts vector operations into scalar operations
399 //
400 FunctionPass *createScalarizerPass();
401 
402 //===----------------------------------------------------------------------===//
403 //
404 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
405 //
406 FunctionPass *createSeparateConstOffsetFromGEPPass(bool LowerGEP = false);
407 
408 //===----------------------------------------------------------------------===//
409 //
410 // SpeculativeExecution - Aggressively hoist instructions to enable
411 // speculative execution on targets where branches are expensive.
412 //
413 FunctionPass *createSpeculativeExecutionPass();
414 
415 // Same as createSpeculativeExecutionPass, but does nothing unless
416 // TargetTransformInfo::hasBranchDivergence() is true.
418 
419 //===----------------------------------------------------------------------===//
420 //
421 // StraightLineStrengthReduce - This pass strength-reduces some certain
422 // instruction patterns in straight-line code.
423 //
425 
426 //===----------------------------------------------------------------------===//
427 //
428 // PlaceSafepoints - Rewrite any IR calls to gc.statepoints and insert any
429 // safepoint polls (method entry, backedge) that might be required. This pass
430 // does not generate explicit relocation sequences - that's handled by
431 // RewriteStatepointsForGC which can be run at an arbitrary point in the pass
432 // order following this pass.
433 //
434 FunctionPass *createPlaceSafepointsPass();
435 
436 //===----------------------------------------------------------------------===//
437 //
438 // RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
439 // explicit relocations to include explicit relocations.
440 //
442 
443 //===----------------------------------------------------------------------===//
444 //
445 // Float2Int - Demote floats to ints where possible.
446 //
447 FunctionPass *createFloat2IntPass();
448 
449 //===----------------------------------------------------------------------===//
450 //
451 // NaryReassociate - Simplify n-ary operations by reassociation.
452 //
453 FunctionPass *createNaryReassociatePass();
454 
455 //===----------------------------------------------------------------------===//
456 //
457 // LoopDistribute - Distribute loops.
458 //
459 FunctionPass *createLoopDistributePass();
460 
461 //===----------------------------------------------------------------------===//
462 //
463 // LoopLoadElimination - Perform loop-aware load elimination.
464 //
465 FunctionPass *createLoopLoadEliminationPass();
466 
467 //===----------------------------------------------------------------------===//
468 //
469 // LoopVersioning - Perform loop multi-versioning.
470 //
471 FunctionPass *createLoopVersioningPass();
472 
473 //===----------------------------------------------------------------------===//
474 //
475 // LoopDataPrefetch - Perform data prefetching in loops.
476 //
477 FunctionPass *createLoopDataPrefetchPass();
478 
479 ///===---------------------------------------------------------------------===//
480 ModulePass *createNameAnonGlobalPass();
481 
482 //===----------------------------------------------------------------------===//
483 //
484 // LibCallsShrinkWrap - Shrink-wraps a call to function if the result is not
485 // used.
486 //
487 FunctionPass *createLibCallsShrinkWrapPass();
488 
489 //===----------------------------------------------------------------------===//
490 //
491 // LoopSimplifyCFG - This pass performs basic CFG simplification on loops,
492 // primarily to help other loop passes.
493 //
495 } // End llvm namespace
496 
497 #endif
FunctionPass * createSpeculativeExecutionPass()
FunctionPass * createStraightLineStrengthReducePass()
ModulePass * createNameAnonGlobalPass()
===------------------------------------------------------------------—===//
Pass * createLoopRerollPass()
Pass * createLoopStrengthReducePass()
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Pass * createDeadInstEliminationPass()
Pass * createLoopUnrollPass(int OptLevel=2, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
char & DemoteRegisterToMemoryID
Definition: Reg2Mem.cpp:126
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:514
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1208
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:127
FunctionPass * createAlignmentFromAssumptionsPass()
FunctionPass * createJumpThreadingPass(int Threshold=-1)
FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createCFGSimplificationPass(unsigned Threshold=1, bool ForwardSwitchCond=false, bool ConvertSwitch=false, bool KeepLoops=true, bool SinkCommon=false, std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createConstantPropagationPass()
FunctionPass * createReassociatePass()
Pass * createSimpleLoopUnrollPass(int OptLevel=2)
FunctionPass * createSinkingPass()
Definition: Sink.cpp:306
Pass * createMergeICmpsPass()
Definition: MergeICmps.cpp:790
FunctionPass * createAggressiveInstCombinerPass()
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:1828
FunctionPass * createPartiallyInlineLibCallsPass()
FunctionPass * createDeadCodeEliminationPass()
Definition: DCE.cpp:164
static cl::opt< bool > SinkCommon("simplifycfg-sink-common", cl::Hidden, cl::init(true), cl::desc("Sink common instructions down to the end block"))
ModulePass * createRewriteStatepointsForGCLegacyPass()
FunctionPass * createInstructionCombiningPass(bool ExpensiveCombines=true)
Pass * createCorrelatedValuePropagationPass()
FunctionPass * createPlaceSafepointsPass()
FunctionPass * createFlattenCFGPass()
FunctionPass * createTailCallEliminationPass()
Pass * createLICMPass()
Definition: LICM.cpp:237
FunctionPass * createDivRemPairsPass()
FunctionPass * createDeadStoreEliminationPass()
Pass * createLoopPredicationPass()
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:172
Pass * createLoopSinkPass()
Pass * createLoopVersioningLICMPass()
Pass * createLowerGuardIntrinsicPass()
print lazy value Lazy Value Info Printer Pass
FunctionPass * createLoopVersioningPass()
Pass * createLoopInterchangePass()
FunctionPass * createLoopLoadEliminationPass()
Pass * createLoopSimplifyCFGPass()
Pass * createLowerAtomicPass()
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
FunctionPass * createLibCallsShrinkWrapPass()
Pass * createLoopDeletionPass()
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
Pass * createLoopUnswitchPass(bool OptimizeForSize=false, bool hasBranchDivergence=false)
Pass * createLoopIdiomPass()
char & InferAddressSpacesID
FunctionPass * createInferAddressSpacesPass()
FunctionPass * createGVNSinkPass()
Definition: GVNSink.cpp:922
FunctionPass * createSROAPass()
Definition: SROA.cpp:4486
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
FunctionPass * createGuardWideningPass()
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1266
print Print MemDeps of function
FunctionPass * createScalarizerPass()
Definition: Scalarizer.cpp:800
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:4260
Pass * createStructurizeCFGPass(bool SkipUniformRegions=false)
When SkipUniformRegions is true the structizer will not structurize regions that only contain uniform...
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
Pass * createIndVarSimplifyPass()
Pass * createInductiveRangeCheckEliminationPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:730
FunctionPass * createLoopDistributePass()
FunctionPass * createLowerExpectIntrinsicPass()
FunctionPass * createConstantHoistingPass()
FunctionPass * createNaryReassociatePass()
FunctionPass * createCallSiteSplittingPass()