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