LLVM 18.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 Pass;
25
26//===----------------------------------------------------------------------===//
27//
28// RedundantDbgInstElimination - This pass removes redundant dbg intrinsics
29// without modifying the CFG of the function. It is a FunctionPass.
30//
32
33//===----------------------------------------------------------------------===//
34//
35// DeadCodeElimination - This pass is more powerful than DeadInstElimination,
36// because it is worklist driven that can potentially revisit instructions when
37// their other instructions become dead, to eliminate chains of dead
38// computations.
39//
41
42
43//===----------------------------------------------------------------------===//
44//
45// GuardWidening - An optimization over the @llvm.experimental.guard intrinsic
46// that (optimistically) combines multiple guards into one to have fewer checks
47// at runtime.
48//
50
51
52//===----------------------------------------------------------------------===//
53//
54// LoopGuardWidening - Analogous to the GuardWidening pass, but restricted to a
55// single loop at a time for use within a LoopPassManager. Desired effect is
56// to widen guards into preheader or a single guard within loop if that's not
57// possible.
58//
60
61
62//===----------------------------------------------------------------------===//
63//
64// SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
65//
67
68//===----------------------------------------------------------------------===//
69//
70// LICM - This pass is a loop invariant code motion and memory promotion pass.
71//
73
74//===----------------------------------------------------------------------===//
75//
76// LoopSink - This pass sinks invariants from preheader to loop body where
77// frequency is lower than loop preheader.
78//
80
81//===----------------------------------------------------------------------===//
82//
83// LoopPredication - This pass does loop predication on guards.
84//
86
87//===----------------------------------------------------------------------===//
88//
89// LoopStrengthReduce - This pass is strength reduces GEP instructions that use
90// a loop's canonical induction variable as one of their indices.
91//
93
94//===----------------------------------------------------------------------===//
95//
96// LoopInstSimplify - This pass simplifies instructions in a loop's body.
97//
99
100//===----------------------------------------------------------------------===//
101//
102// LoopUnroll - This pass is a simple loop unrolling pass.
103//
104Pass *createLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
105 bool ForgetAllSCEV = false, int Threshold = -1,
106 int Count = -1, int AllowPartial = -1,
107 int Runtime = -1, int UpperBound = -1,
108 int AllowPeeling = -1);
109
110//===----------------------------------------------------------------------===//
111//
112// LoopRotate - This pass is a simple loop rotating pass.
113//
114Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
115
116//===----------------------------------------------------------------------===//
117//
118// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
119// references. In basically undoes the PromoteMemoryToRegister pass to make cfg
120// hacking easier.
121//
123extern char &DemoteRegisterToMemoryID;
124
125//===----------------------------------------------------------------------===//
126//
127// Reassociate - This pass reassociates commutative expressions in an order that
128// is designed to promote better constant propagation, GCSE, LICM, PRE...
129//
130// For example: 4 + (x + 5) -> x + (4 + 5)
131//
133
134//===----------------------------------------------------------------------===//
135//
136// CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
137// simplify terminator instructions, convert switches to lookup tables, etc.
138//
141 std::function<bool(const Function &)> Ftor = nullptr);
142
143//===----------------------------------------------------------------------===//
144//
145// FlattenCFG - flatten CFG, reduce number of conditional branches by using
146// parallel-and and parallel-or mode, etc...
147//
149
150//===----------------------------------------------------------------------===//
151//
152// CFG Structurization - Remove irreducible control flow
153//
154///
155/// When \p SkipUniformRegions is true the structizer will not structurize
156/// regions that only contain uniform branches.
157Pass *createStructurizeCFGPass(bool SkipUniformRegions = false);
158
159//===----------------------------------------------------------------------===//
160//
161// TailCallElimination - This pass eliminates call instructions to the current
162// function which occur immediately before return instructions.
163//
165
166//===----------------------------------------------------------------------===//
167//
168// EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
169// tree.
170//
171FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false);
172
173//===----------------------------------------------------------------------===//
174//
175// MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
176// are hoisted into the header, while stores sink into the footer.
177//
178FunctionPass *createMergedLoadStoreMotionPass(bool SplitFooterBB = false);
179
180//===----------------------------------------------------------------------===//
181//
182// ConstantHoisting - This pass prepares a function for expensive constants.
183//
185
186//===----------------------------------------------------------------------===//
187//
188// Sink - Code Sinking
189//
191
192//===----------------------------------------------------------------------===//
193//
194// LowerAtomic - Lower atomic intrinsics to non-atomic form
195//
197
198//===----------------------------------------------------------------------===//
199//
200// LowerWidenableCondition - Lower widenable condition to i1 true.
201//
203
204//===----------------------------------------------------------------------===//
205//
206// MergeICmps - Merge integer comparison chains into a memcmp
207//
209
210//===----------------------------------------------------------------------===//
211//
212// InferAddressSpaces - Modify users of addrspacecast instructions with values
213// in the source address space if using the destination address space is slower
214// on the target. If AddressSpace is left to its default value, it will be
215// obtained from the TargetTransformInfo.
216//
218extern char &InferAddressSpacesID;
219
220//===----------------------------------------------------------------------===//
221//
222// LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
223// "block_weights" metadata.
225
226//===----------------------------------------------------------------------===//
227//
228// TLSVariableHoist - This pass reduce duplicated TLS address call.
229//
231
232//===----------------------------------------------------------------------===//
233//
234// LowerConstantIntrinsicss - Expand any remaining llvm.objectsize and
235// llvm.is.constant intrinsic calls, even for the unknown cases.
236//
238
239//===----------------------------------------------------------------------===//
240//
241// PartiallyInlineLibCalls - Tries to inline the fast path of library
242// calls such as sqrt.
243//
245
246//===----------------------------------------------------------------------===//
247//
248// SeparateConstOffsetFromGEP - Split GEPs for better CSE
249//
251
252//===----------------------------------------------------------------------===//
253//
254// SpeculativeExecution - Aggressively hoist instructions to enable
255// speculative execution on targets where branches are expensive.
256//
258
259// Same as createSpeculativeExecutionPass, but does nothing unless
260// TargetTransformInfo::hasBranchDivergence() is true.
262
263//===----------------------------------------------------------------------===//
264//
265// StraightLineStrengthReduce - This pass strength-reduces some certain
266// instruction patterns in straight-line code.
267//
269
270//===----------------------------------------------------------------------===//
271//
272// NaryReassociate - Simplify n-ary operations by reassociation.
273//
275
276//===----------------------------------------------------------------------===//
277//
278// LoopDataPrefetch - Perform data prefetching in loops.
279//
281
282//===----------------------------------------------------------------------===//
283//
284// LoopSimplifyCFG - This pass performs basic CFG simplification on loops,
285// primarily to help other loop passes.
286//
288
289//===----------------------------------------------------------------------===//
290//
291// This pass does instruction simplification on each
292// instruction in a function.
293//
295
296
297//===----------------------------------------------------------------------===//
298//
299// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
300// and scatter intrinsics with scalar code when target doesn't support them.
301//
303} // End llvm namespace
304
305#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
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()
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:370
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:276
char & DemoteRegisterToMemoryID
Definition: Reg2Mem.cpp:139
FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createSpeculativeExecutionPass()
Pass * createLowerAtomicPass()
FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
Pass * createMergeICmpsLegacyPass()
Definition: MergeICmps.cpp:913
FunctionPass * createMergedLoadStoreMotionPass(bool SplitFooterBB=false)
createMergedLoadStoreMotionPass - The public interface to this file.
Pass * createLoopStrengthReducePass()
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:1931
FunctionPass * createSROAPass(bool PreserveCFG=true)
Definition: SROA.cpp:5197
FunctionPass * createInstSimplifyLegacyPass()
Pass * createLowerWidenableConditionPass()
Pass * createLoopGuardWideningPass()