LLVM 17.0.0git
Scalar.cpp
Go to the documentation of this file.
1//===-- Scalar.cpp --------------------------------------------------------===//
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 file implements common infrastructure for libLLVMScalarOpts.a, which
10// implements several scalar transformations over the LLVM intermediate
11// representation, including the C bindings for that library.
12//
13//===----------------------------------------------------------------------===//
14
22#include "llvm/IR/Verifier.h"
27
28using namespace llvm;
29
30/// initializeScalarOptsPasses - Initialize all passes linked into the
31/// ScalarOpts library.
112}
113
116}
117
120}
121
124}
125
128}
129
132}
133
136}
137
140}
141
144}
145
147 unwrap(PM)->add(createScalarizerPass());
148}
149
151 unwrap(PM)->add(createGVNPass());
152}
153
155 unwrap(PM)->add(createNewGVNPass());
156}
157
160}
161
164}
165
168}
169
172}
173
175 unwrap(PM)->add(createLoopSinkPass());
176}
177
179 unwrap(PM)->add(createLICMPass());
180}
181
183 unwrap(PM)->add(createLoopDeletionPass());
184}
185
187 unwrap(PM)->add(createLoopFlattenPass());
188}
189
191 unwrap(PM)->add(createLoopIdiomPass());
192}
193
195 unwrap(PM)->add(createLoopRotatePass());
196}
197
199 unwrap(PM)->add(createLoopRerollPass());
200}
201
203 unwrap(PM)->add(createLoopUnrollPass());
204}
205
208}
209
211 unwrap(PM)->add(createLowerAtomicPass());
212}
213
215 unwrap(PM)->add(createMemCpyOptPass());
216}
217
220}
221
223 unwrap(PM)->add(createReassociatePass());
224}
225
227 unwrap(PM)->add(createSCCPPass());
228}
229
231 unwrap(PM)->add(createSROAPass());
232}
233
235 unwrap(PM)->add(createSROAPass());
236}
237
239 int Threshold) {
240 unwrap(PM)->add(createSROAPass());
241}
242
244 // NOTE: The simplify-libcalls pass has been removed.
245}
246
249}
250
253}
254
256 unwrap(PM)->add(createVerifierPass());
257}
258
261}
262
264 unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/));
265}
266
268 unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/));
269}
270
272 unwrap(PM)->add(createGVNHoistPass());
273}
274
277}
278
281}
282
285}
286
289}
290
293}
294
297}
This is the interface for LLVM's primary stateless and local alias analysis.
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
void LLVMAddLoopSinkPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:174
void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:271
void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:114
void LLVMAddLoopFlattenPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:186
This pass converts vector operations into scalar operations, in order to expose optimization opportun...
This is the interface for a metadata-based scoped no-alias analysis.
This is the interface for a metadata-based TBAA.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R)
Definition: Scalar.cpp:118
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:127
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:130
void LLVMAddVerifierPass(LLVMPassManagerRef PM)
See llvm::createVerifierPass function.
Definition: Scalar.cpp:255
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:263
void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM)
See llvm::createLoopUnrollAndJamPass function.
Definition: Scalar.cpp:206
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:230
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM)
See llvm::createLoopUnrollPass function.
Definition: Scalar.cpp:202
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM)
See llvm::createLoopRotatePass function.
Definition: Scalar.cpp:194
void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM)
See llvm::createLowerAtomicPass function.
Definition: Scalar.cpp:210
void LLVMAddSCCPPass(LLVMPassManagerRef PM)
See llvm::createSCCPPass function.
Definition: Scalar.cpp:226
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM)
See llvm::demotePromoteMemoryToRegisterPass function.
Definition: Scalar.cpp:251
void LLVMAddNewGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:154
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM)
See llvm::createCFGSimplificationPass function.
Definition: Scalar.cpp:138
void LLVMAddDCEPass(LLVMPassManagerRef PM)
See llvm::createDeadCodeEliminationPass function.
Definition: Scalar.cpp:126
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM)
See llvm::createTailCallEliminationPass function.
Definition: Scalar.cpp:247
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM)
See llvm::createSimplifyLibCallsPass function.
Definition: Scalar.cpp:243
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM)
See llvm::createLowerExpectIntrinsicPass function.
Definition: Scalar.cpp:291
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, int Threshold)
See llvm::createSROAPass function.
Definition: Scalar.cpp:238
void LLVMAddScalarizerPass(LLVMPassManagerRef PM)
See llvm::createScalarizerPass function.
Definition: Scalar.cpp:146
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM)
See llvm::createCorrelatedValuePropagationPass function.
Definition: Scalar.cpp:259
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM)
See llvm::createAggressiveDCEPass function.
Definition: Scalar.cpp:122
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM)
See llvm::createScopedNoAliasAAPass function.
Definition: Scalar.cpp:279
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM)
See llvm::createLoopRerollPass function.
Definition: Scalar.cpp:198
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM)
See llvm::createMemCpyOptPass function.
Definition: Scalar.cpp:214
void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM)
See llvm::createInstSimplifyLegacyPass function.
Definition: Scalar.cpp:166
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM)
See llvm::createBitTrackingDCEPass function.
Definition: Scalar.cpp:130
void LLVMAddReassociatePass(LLVMPassManagerRef PM)
See llvm::createReassociatePass function.
Definition: Scalar.cpp:222
void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:267
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createTypeBasedAliasAnalysisPass function.
Definition: Scalar.cpp:275
void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM)
See llvm::createUnifyFunctionExitNodesPass function.
Definition: Scalar.cpp:295
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM)
See llvm::createAlignmentFromAssumptionsPass function.
Definition: Scalar.cpp:134
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createBasicAliasAnalysisPass function.
Definition: Scalar.cpp:283
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM)
See llvm::createDeadStoreEliminationPass function.
Definition: Scalar.cpp:142
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM)
See llvm::createJumpThreadingPass function.
Definition: Scalar.cpp:170
void LLVMAddLICMPass(LLVMPassManagerRef PM)
See llvm::createLICMPass function.
Definition: Scalar.cpp:178
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM)
See llvm::createLoopDeletionPass function.
Definition: Scalar.cpp:182
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:234
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM)
See llvm::createPartiallyInlineLibCallsPass function.
Definition: Scalar.cpp:218
void LLVMAddGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:150
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM)
See llvm::createMergedLoadStoreMotionPass function.
Definition: Scalar.cpp:158
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM)
See llvm::createIndVarSimplifyPass function.
Definition: Scalar.cpp:162
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM)
See llvm::createLoopIdiomPass function.
Definition: Scalar.cpp:190
void LLVMAddLowerConstantIntrinsicsPass(LLVMPassManagerRef PM)
See llvm::createLowerConstantIntrinsicsPass function.
Definition: Scalar.cpp:287
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeRegToMemLegacyPass(PassRegistry &)
FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:140
void initializeNewGVNLegacyPassPass(PassRegistry &)
FunctionPass * createTailCallEliminationPass()
void initializeFloat2IntLegacyPassPass(PassRegistry &)
void initializeSinkingLegacyPassPass(PassRegistry &)
void initializeLoopGuardWideningLegacyPassPass(PassRegistry &)
void initializeMemCpyOptLegacyPassPass(PassRegistry &)
FunctionPass * createLowerExpectIntrinsicPass()
void initializeLoopVersioningLICMLegacyPassPass(PassRegistry &)
void initializeLoopInterchangeLegacyPassPass(PassRegistry &)
void initializeLoopUnrollPass(PassRegistry &)
Pass * createLoopRotatePass(int MaxHeaderSize=-1, bool PrepareForLTO=false)
void initializePlaceSafepointsPass(PassRegistry &)
void initializeMergeICmpsLegacyPassPass(PassRegistry &)
void initializeWarnMissedTransformationsLegacyPass(PassRegistry &)
Pass * createLoopIdiomPass()
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:206
FunctionPass * createDeadStoreEliminationPass()
FunctionPass * createDeadCodeEliminationPass()
Definition: DCE.cpp:178
void initializeTailCallElimPass(PassRegistry &)
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:188
void initializeLegacyLICMPassPass(PassRegistry &)
void initializeMakeGuardsExplicitLegacyPassPass(PassRegistry &)
void initializeGVNSinkLegacyPassPass(PassRegistry &)
void initializeScalarOpts(PassRegistry &)
Initialize all passes linked into the ScalarOpts library.
Definition: Scalar.cpp:32
void initializeGVNHoistLegacyPassPass(PassRegistry &)
void initializeInferAddressSpacesPass(PassRegistry &)
void initializeAlignmentFromAssumptionsPass(PassRegistry &)
void initializeLoopUnrollAndJamPass(PassRegistry &)
void initializeLowerConstantIntrinsicsPass(PassRegistry &)
void initializeLoopSimplifyCFGLegacyPassPass(PassRegistry &)
FunctionPass * createJumpThreadingPass(int Threshold=-1)
void initializeEarlyCSEMemSSALegacyPassPass(PassRegistry &)
void initializeLowerMatrixIntrinsicsLegacyPassPass(PassRegistry &)
FunctionPass * createMemCpyOptPass()
The public interface to this file...
Pass * createUnifyFunctionExitNodesPass()
void initializeNaryReassociateLegacyPassPass(PassRegistry &)
void initializeLoopAccessLegacyAnalysisPass(PassRegistry &)
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:4264
void initializeLoopFuseLegacyPass(PassRegistry &)
void initializeSpeculativeExecutionLegacyPassPass(PassRegistry &)
void initializeStraightLineStrengthReduceLegacyPassPass(PassRegistry &)
Pass * createLICMPass()
Definition: LICM.cpp:353
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()
void initializeStructurizeCFGLegacyPassPass(PassRegistry &)
void initializeGVNLegacyPassPass(PassRegistry &)
void initializeReassociateLegacyPassPass(PassRegistry &)
FunctionPass * createAlignmentFromAssumptionsPass()
void initializeBDCELegacyPassPass(PassRegistry &)
void initializeIRCELegacyPassPass(PassRegistry &)
void initializeLoopDeletionLegacyPassPass(PassRegistry &)
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry &)
FunctionPass * createScalarizerPass()
Create a legacy pass manager instance of the Scalarizer pass.
Definition: Scalarizer.cpp:362
void initializeJumpThreadingPass(PassRegistry &)
void initializeDivRemPairsLegacyPassPass(PassRegistry &)
void initializeLoopFlattenLegacyPassPass(PassRegistry &)
void initializeCFGSimplifyPassPass(PassRegistry &)
Pass * createCorrelatedValuePropagationPass()
ImmutablePass * createScopedNoAliasAAWrapperPass()
void initializeIndVarSimplifyLegacyPassPass(PassRegistry &)
void initializeDFAJumpThreadingLegacyPassPass(PassRegistry &)
void initializeScalarizeMaskedMemIntrinLegacyPassPass(PassRegistry &)
void initializeSeparateConstOffsetFromGEPLegacyPassPass(PassRegistry &)
void initializeLoopIdiomRecognizeLegacyPassPass(PassRegistry &)
FunctionPass * createLoopFlattenPass()
Pass * createLowerAtomicPass()
FunctionPass * createBasicAAWrapperPass()
void initializeDSELegacyPassPass(PassRegistry &)
void initializeLegacyLoopSinkPassPass(PassRegistry &)
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:760
void initializeLowerExpectIntrinsicPass(PassRegistry &)
void initializeEarlyCSELegacyPassPass(PassRegistry &)
void initializeSimpleLoopUnswitchLegacyPassPass(PassRegistry &)
void initializeLoopInstSimplifyLegacyPassPass(PassRegistry &)
void initializeLowerMatrixIntrinsicsMinimalLegacyPassPass(PassRegistry &)
Pass * createLoopDeletionPass()
void initializeDCELegacyPassPass(PassRegistry &)
void initializeLowerGuardIntrinsicLegacyPassPass(PassRegistry &)
void initializeCorrelatedValuePropagationPass(PassRegistry &)
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:285
void initializeFlattenCFGLegacyPassPass(PassRegistry &)
void initializeInstSimplifyLegacyPassPass(PassRegistry &)
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry &)
Pass * createLoopUnrollAndJamPass(int OptLevel=2)
ImmutablePass * createTypeBasedAAWrapperPass()
void initializeSROALegacyPassPass(PassRegistry &)
FunctionPass * createVerifierPass(bool FatalErrors=true)
Definition: Verifier.cpp:6851
FunctionPass * createMergedLoadStoreMotionPass(bool SplitFooterBB=false)
createMergedLoadStoreMotionPass - The public interface to this file.
void initializeLowerWidenableConditionLegacyPassPass(PassRegistry &)
void initializeLoopDistributeLegacyPass(PassRegistry &)
void initializeADCELegacyPassPass(PassRegistry &)
void initializeGuardWideningLegacyPassPass(PassRegistry &)
FunctionPass * createGVNPass(bool NoMemDepAnalysis=false)
Create a legacy GVN pass.
Definition: GVN.cpp:3211
Pass * createLoopSimplifyCFGPass()
void initializeRewriteStatepointsForGCLegacyPassPass(PassRegistry &)
void initializeLoopStrengthReducePass(PassRegistry &)
void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &)
void initializeLoopRotateLegacyPassPass(PassRegistry &)
FunctionPass * createLowerConstantIntrinsicsPass()
void initializeRedundantDbgInstEliminationPass(PassRegistry &)
void initializeLowerAtomicLegacyPassPass(PassRegistry &)
FunctionPass * createPartiallyInlineLibCallsPass()
void initializeCallSiteSplittingLegacyPassPass(PassRegistry &)
void initializeSCCPLegacyPassPass(PassRegistry &)
Pass * createLoopSinkPass()
Pass * createIndVarSimplifyPass()
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1267
void initializePlaceBackedgeSafepointsImplPass(PassRegistry &)
void initializeLoopPredicationLegacyPassPass(PassRegistry &)
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1793
Pass * createLoopRerollPass()
FunctionPass * createSROAPass(bool PreserveCFG=true)
Definition: SROA.cpp:5021
void initializeLoopRerollLegacyPassPass(PassRegistry &)
void initializeScalarizerLegacyPassPass(PassRegistry &)
void initializeLoopVersioningLegacyPassPass(PassRegistry &)
void initializeTLSVariableHoistLegacyPassPass(PassRegistry &)
void initializeLoopLoadEliminationPass(PassRegistry &)
void initializeConstantHoistingLegacyPassPass(PassRegistry &)
FunctionPass * createInstSimplifyLegacyPass()