LLVM 17.0.0git
Scalar.h
Go to the documentation of this file.
1//===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This header file defines prototypes for accessor functions that expose passes
10// in the Scalar transformations library.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TRANSFORMS_SCALAR_H
15#define LLVM_TRANSFORMS_SCALAR_H
16
18#include <functional>
19
20namespace llvm {
21
22class Function;
23class FunctionPass;
24class ModulePass;
25class Pass;
26
27//===----------------------------------------------------------------------===//
28//
29// RedundantDbgInstElimination - This pass removes redundant dbg intrinsics
30// without modifying the CFG of the function. It is a FunctionPass.
31//
33
34//===----------------------------------------------------------------------===//
35//
36// DeadCodeElimination - This pass is more powerful than DeadInstElimination,
37// because it is worklist driven that can potentially revisit instructions when
38// their other instructions become dead, to eliminate chains of dead
39// computations.
40//
42
43
44//===----------------------------------------------------------------------===//
45//
46// CallSiteSplitting - This pass split call-site based on its known argument
47// values.
49
50//===----------------------------------------------------------------------===//
51//
52// GuardWidening - An optimization over the @llvm.experimental.guard intrinsic
53// that (optimistically) combines multiple guards into one to have fewer checks
54// at runtime.
55//
57
58
59//===----------------------------------------------------------------------===//
60//
61// LoopGuardWidening - Analogous to the GuardWidening pass, but restricted to a
62// single loop at a time for use within a LoopPassManager. Desired effect is
63// to widen guards into preheader or a single guard within loop if that's not
64// possible.
65//
67
68
69//===----------------------------------------------------------------------===//
70//
71// SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
72//
74
75//===----------------------------------------------------------------------===//
76//
77// LICM - This pass is a loop invariant code motion and memory promotion pass.
78//
80Pass *createLICMPass(unsigned LicmMssaOptCap,
81 unsigned LicmMssaNoAccForPromotionCap,
82 bool AllowSpeculation);
83
84//===----------------------------------------------------------------------===//
85//
86// LoopSink - This pass sinks invariants from preheader to loop body where
87// frequency is lower than loop preheader.
88//
90
91//===----------------------------------------------------------------------===//
92//
93// LoopPredication - This pass does loop predication on guards.
94//
96
97//===----------------------------------------------------------------------===//
98//
99// LoopStrengthReduce - This pass is strength reduces GEP instructions that use
100// a loop's canonical induction variable as one of their indices.
101//
103
104//===----------------------------------------------------------------------===//
105//
106// LoopInstSimplify - This pass simplifies instructions in a loop's body.
107//
109
110//===----------------------------------------------------------------------===//
111//
112// LoopUnroll - This pass is a simple loop unrolling pass.
113//
114Pass *createLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
115 bool ForgetAllSCEV = false, int Threshold = -1,
116 int Count = -1, int AllowPartial = -1,
117 int Runtime = -1, int UpperBound = -1,
118 int AllowPeeling = -1);
119// Create an unrolling pass for full unrolling that uses exact trip count only
120// and also does peeling.
121Pass *createSimpleLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
122 bool ForgetAllSCEV = false);
123
124//===----------------------------------------------------------------------===//
125//
126// LoopRotate - This pass is a simple loop rotating pass.
127//
128Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
129
130//===----------------------------------------------------------------------===//
131//
132// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
133// references. In basically undoes the PromoteMemoryToRegister pass to make cfg
134// hacking easier.
135//
137extern char &DemoteRegisterToMemoryID;
138
139//===----------------------------------------------------------------------===//
140//
141// Reassociate - This pass reassociates commutative expressions in an order that
142// is designed to promote better constant propagation, GCSE, LICM, PRE...
143//
144// For example: 4 + (x + 5) -> x + (4 + 5)
145//
147
148//===----------------------------------------------------------------------===//
149//
150// CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
151// simplify terminator instructions, convert switches to lookup tables, etc.
152//
155 std::function<bool(const Function &)> Ftor = nullptr);
156
157//===----------------------------------------------------------------------===//
158//
159// FlattenCFG - flatten CFG, reduce number of conditional branches by using
160// parallel-and and parallel-or mode, etc...
161//
163
164//===----------------------------------------------------------------------===//
165//
166// CFG Structurization - Remove irreducible control flow
167//
168///
169/// When \p SkipUniformRegions is true the structizer will not structurize
170/// regions that only contain uniform branches.
171Pass *createStructurizeCFGPass(bool SkipUniformRegions = false);
172
173//===----------------------------------------------------------------------===//
174//
175// TailCallElimination - This pass eliminates call instructions to the current
176// function which occur immediately before return instructions.
177//
179
180//===----------------------------------------------------------------------===//
181//
182// EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
183// tree.
184//
185FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false);
186
187//===----------------------------------------------------------------------===//
188//
189// MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
190// are hoisted into the header, while stores sink into the footer.
191//
192FunctionPass *createMergedLoadStoreMotionPass(bool SplitFooterBB = false);
193
194//===----------------------------------------------------------------------===//
195//
196// ConstantHoisting - This pass prepares a function for expensive constants.
197//
199
200//===----------------------------------------------------------------------===//
201//
202// Sink - Code Sinking
203//
205
206//===----------------------------------------------------------------------===//
207//
208// LowerAtomic - Lower atomic intrinsics to non-atomic form
209//
211
212//===----------------------------------------------------------------------===//
213//
214// LowerGuardIntrinsic - Lower guard intrinsics to normal control flow.
215//
217
218//===----------------------------------------------------------------------===//
219//
220// LowerMatrixIntrinsics - Lower matrix intrinsics to vector operations.
221//
223
224//===----------------------------------------------------------------------===//
225//
226// LowerMatrixIntrinsicsMinimal - Lower matrix intrinsics to vector operations
227// (lightweight, does not require extra analysis)
228//
230
231//===----------------------------------------------------------------------===//
232//
233// LowerWidenableCondition - Lower widenable condition to i1 true.
234//
236
237//===----------------------------------------------------------------------===//
238//
239// MergeICmps - Merge integer comparison chains into a memcmp
240//
242
243//===----------------------------------------------------------------------===//
244//
245// InferAddressSpaces - Modify users of addrspacecast instructions with values
246// in the source address space if using the destination address space is slower
247// on the target. If AddressSpace is left to its default value, it will be
248// obtained from the TargetTransformInfo.
249//
251extern char &InferAddressSpacesID;
252
253//===----------------------------------------------------------------------===//
254//
255// LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
256// "block_weights" metadata.
258
259//===----------------------------------------------------------------------===//
260//
261// TLSVariableHoist - This pass reduce duplicated TLS address call.
262//
264
265//===----------------------------------------------------------------------===//
266//
267// LowerConstantIntrinsicss - Expand any remaining llvm.objectsize and
268// llvm.is.constant intrinsic calls, even for the unknown cases.
269//
271
272//===----------------------------------------------------------------------===//
273//
274// PartiallyInlineLibCalls - Tries to inline the fast path of library
275// calls such as sqrt.
276//
278
279//===----------------------------------------------------------------------===//
280//
281// SeparateConstOffsetFromGEP - Split GEPs for better CSE
282//
284
285//===----------------------------------------------------------------------===//
286//
287// SpeculativeExecution - Aggressively hoist instructions to enable
288// speculative execution on targets where branches are expensive.
289//
291
292// Same as createSpeculativeExecutionPass, but does nothing unless
293// TargetTransformInfo::hasBranchDivergence() is true.
295
296//===----------------------------------------------------------------------===//
297//
298// StraightLineStrengthReduce - This pass strength-reduces some certain
299// instruction patterns in straight-line code.
300//
302
303//===----------------------------------------------------------------------===//
304//
305// PlaceSafepoints - Rewrite any IR calls to gc.statepoints and insert any
306// safepoint polls (method entry, backedge) that might be required. This pass
307// does not generate explicit relocation sequences - that's handled by
308// RewriteStatepointsForGC which can be run at an arbitrary point in the pass
309// order following this pass.
310//
312
313//===----------------------------------------------------------------------===//
314//
315// RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
316// explicit relocations to include explicit relocations.
317//
319
320//===----------------------------------------------------------------------===//
321//
322// NaryReassociate - Simplify n-ary operations by reassociation.
323//
325
326//===----------------------------------------------------------------------===//
327//
328// LoopDataPrefetch - Perform data prefetching in loops.
329//
331
332//===----------------------------------------------------------------------===//
333//
334// LoopSimplifyCFG - This pass performs basic CFG simplification on loops,
335// primarily to help other loop passes.
336//
338
339//===----------------------------------------------------------------------===//
340//
341// This pass does instruction simplification on each
342// instruction in a function.
343//
345
346
347//===----------------------------------------------------------------------===//
348//
349// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
350// and scatter intrinsics with scalar code when target doesn't support them.
351//
353} // End llvm namespace
354
355#endif
static LVOptions Options
Definition: LVOptions.cpp:25
print lazy value Lazy Value Info Printer Pass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:311
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:251
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FunctionPass * createGuardWideningPass()
FunctionPass * createFlattenCFGPass()
FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:140
Pass * createRedundantDbgInstEliminationPass()
FunctionPass * createTailCallEliminationPass()
FunctionPass * createTLSVariableHoistPass()
FunctionPass * createLowerExpectIntrinsicPass()
Pass * createLoopRotatePass(int MaxHeaderSize=-1, bool PrepareForLTO=false)
FunctionPass * createConstantHoistingPass()
@ Runtime
Detect stack use after return if not disabled runtime with (ASAN_OPTIONS=detect_stack_use_after_retur...
FunctionPass * createDeadCodeEliminationPass()
Definition: DCE.cpp:178
AddressSpace
Definition: NVPTXBaseInfo.h:21
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
Pass * createLowerGuardIntrinsicPass()
FunctionPass * createNaryReassociatePass()
FunctionPass * createScalarizeMaskedMemIntrinLegacyPass()
Pass * createStructurizeCFGPass(bool SkipUniformRegions=false)
When SkipUniformRegions is true the structizer will not structurize regions that only contain uniform...
Pass * createLICMPass()
Definition: LICM.cpp:362
Pass * createLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, bool ForgetAllSCEV=false, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
FunctionPass * createReassociatePass()
Pass * createLoopPredicationPass()
char & InferAddressSpacesID
FunctionPass * createSinkingPass()
Definition: Sink.cpp:277
char & DemoteRegisterToMemoryID
Definition: Reg2Mem.cpp:139
FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createSpeculativeExecutionPass()
Pass * createLowerMatrixIntrinsicsPass()
Pass * createLowerAtomicPass()
ModulePass * createRewriteStatepointsForGCLegacyPass()
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
Pass * createMergeICmpsLegacyPass()
Definition: MergeICmps.cpp:955
FunctionPass * createMergedLoadStoreMotionPass(bool SplitFooterBB=false)
createMergedLoadStoreMotionPass - The public interface to this file.
Pass * createLoopStrengthReducePass()
FunctionPass * createPlaceSafepointsPass()
Pass * createLoopSimplifyCFGPass()
FunctionPass * createInferAddressSpacesPass(unsigned AddressSpace=~0u)
FunctionPass * createLowerConstantIntrinsicsPass()
FunctionPass * createPartiallyInlineLibCallsPass()
Pass * createLoopSinkPass()
Pass * createLoopInstSimplifyPass()
FunctionPass * createStraightLineStrengthReducePass()
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1815
FunctionPass * createSROAPass(bool PreserveCFG=true)
Definition: SROA.cpp:5207
Pass * createLowerMatrixIntrinsicsMinimalPass()
FunctionPass * createCallSiteSplittingPass()
FunctionPass * createInstSimplifyLegacyPass()
Pass * createLowerWidenableConditionPass()
Pass * createSimpleLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, bool ForgetAllSCEV=false)
Pass * createLoopGuardWideningPass()