LLVM  6.0.0svn
Scalar.cpp
Go to the documentation of this file.
1 //===-- Scalar.cpp --------------------------------------------------------===//
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 file implements common infrastructure for libLLVMScalarOpts.a, which
11 // implements several scalar transformations over the LLVM intermediate
12 // representation, including the C bindings for that library.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include "llvm/Transforms/Scalar.h"
17 #include "llvm-c/Initialization.h"
20 #include "llvm/Analysis/Passes.h"
23 #include "llvm/IR/DataLayout.h"
25 #include "llvm/IR/Verifier.h"
26 #include "llvm/InitializePasses.h"
29 
30 using namespace llvm;
31 
32 /// initializeScalarOptsPasses - Initialize all passes linked into the
33 /// ScalarOpts library.
44  initializeScalarizerPass(Registry);
68  initializeLoopRerollPass(Registry);
69  initializeLoopUnrollPass(Registry);
77  initializeMergeICmpsPass(Registry);
82  initializeRegToMemPass(Registry);
103 }
104 
107 }
108 
110  unwrap(PM)->add(createAggressiveDCEPass());
111 }
112 
114  unwrap(PM)->add(createBitTrackingDCEPass());
115 }
116 
119 }
120 
123 }
124 
127 }
128 
131 }
132 
134  unwrap(PM)->add(createScalarizerPass());
135 }
136 
138  unwrap(PM)->add(createGVNPass());
139 }
140 
142  unwrap(PM)->add(createNewGVNPass());
143 }
144 
147 }
148 
150  unwrap(PM)->add(createIndVarSimplifyPass());
151 }
152 
155 }
156 
158  unwrap(PM)->add(createJumpThreadingPass());
159 }
160 
162  unwrap(PM)->add(createLoopSinkPass());
163 }
164 
166  unwrap(PM)->add(createLICMPass());
167 }
168 
170  unwrap(PM)->add(createLoopDeletionPass());
171 }
172 
174  unwrap(PM)->add(createLoopIdiomPass());
175 }
176 
178  unwrap(PM)->add(createLoopRotatePass());
179 }
180 
182  unwrap(PM)->add(createLoopRerollPass());
183 }
184 
186  unwrap(PM)->add(createLoopSimplifyCFGPass());
187 }
188 
190  unwrap(PM)->add(createLoopUnrollPass());
191 }
192 
194  unwrap(PM)->add(createLoopUnswitchPass());
195 }
196 
198  unwrap(PM)->add(createMemCpyOptPass());
199 }
200 
203 }
204 
206  unwrap(PM)->add(createLowerSwitchPass());
207 }
208 
211 }
212 
214  unwrap(PM)->add(createReassociatePass());
215 }
216 
218  unwrap(PM)->add(createSCCPPass());
219 }
220 
222  unwrap(PM)->add(createSROAPass());
223 }
224 
226  unwrap(PM)->add(createSROAPass());
227 }
228 
230  int Threshold) {
231  unwrap(PM)->add(createSROAPass());
232 }
233 
235  // NOTE: The simplify-libcalls pass has been removed.
236 }
237 
240 }
241 
244 }
245 
248 }
249 
251  unwrap(PM)->add(createVerifierPass());
252 }
253 
256 }
257 
259  unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/));
260 }
261 
263  unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/));
264 }
265 
267  unwrap(PM)->add(createGVNHoistPass());
268 }
269 
272 }
273 
276 }
277 
279  unwrap(PM)->add(createBasicAAWrapperPass());
280 }
281 
284 }
void initializeNewGVNLegacyPassPass(PassRegistry &)
void initializeEarlyCSELegacyPassPass(PassRegistry &)
void initializeDCELegacyPassPass(PassRegistry &)
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
Definition: GVN.cpp:2549
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM)
See llvm::createJumpThreadingPass function.
Definition: Scalar.cpp:157
void initializeLoopUnswitchPass(PassRegistry &)
void LLVMAddGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:137
Pass * createLoopRerollPass()
void initializeBDCELegacyPassPass(PassRegistry &)
void initializeLoopAccessLegacyAnalysisPass(PassRegistry &)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
FunctionPass * createLowerSwitchPass()
void initializeConstantHoistingLegacyPassPass(PassRegistry &)
void initializeJumpThreadingPass(PassRegistry &)
void LLVMAddLICMPass(LLVMPassManagerRef PM)
See llvm::createLICMPass function.
Definition: Scalar.cpp:165
void initializeDSELegacyPassPass(PassRegistry &)
Pass * createLoopUnrollPass(int OptLevel=2, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM)
See llvm::createSimplifyLibCallsPass function.
Definition: Scalar.cpp:234
void initializeLoopDeletionLegacyPassPass(PassRegistry &)
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createTypeBasedAliasAnalysisPass function.
Definition: Scalar.cpp:270
void initializeGuardWideningLegacyPassPass(PassRegistry &)
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
This is the interface for a metadata-based scoped no-alias analysis.
FunctionPass * createVerifierPass(bool FatalErrors=true)
Definition: Verifier.cpp:4977
void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:262
void LLVMAddReassociatePass(LLVMPassManagerRef PM)
See llvm::createReassociatePass function.
Definition: Scalar.cpp:213
void initializeScalarOpts(PassRegistry &)
Initialize all passes linked into the ScalarOpts library.
Definition: Scalar.cpp:34
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM)
See llvm::createLowerSwitchPass function.
Definition: Scalar.cpp:205
void initializeLoopStrengthReducePass(PassRegistry &)
void initializePlaceSafepointsPass(PassRegistry &)
void initializeDivRemPairsLegacyPassPass(PassRegistry &)
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:117
void initializeLoopRerollPass(PassRegistry &)
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1206
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM)
See llvm::createConstantPropagationPass function.
Definition: Scalar.cpp:242
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:126
void LLVMAddNewGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:141
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM)
See llvm::createPromoteMemoryToRegisterPass function.
Definition: Scalar.cpp:209
void LLVMAddLoopSinkPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:161
void LLVMAddLateCFGSimplificationPass(LLVMPassManagerRef PM)
See llvm::createLateCFGSimplificationPass function.
Definition: Scalar.cpp:125
ImmutablePass * createScopedNoAliasAAWrapperPass()
FunctionPass * createAlignmentFromAssumptionsPass()
FunctionPass * createJumpThreadingPass(int Threshold=-1)
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM)
See llvm::createLoopUnrollPass function.
Definition: Scalar.cpp:189
void initializeSimpleLoopUnswitchLegacyPassPass(PassRegistry &)
void initializeADCELegacyPassPass(PassRegistry &)
void LLVMAddScalarizerPass(LLVMPassManagerRef PM)
See llvm::createScalarizerPass function.
Definition: Scalar.cpp:133
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:225
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
void initializeSCCPLegacyPassPass(PassRegistry &)
FunctionPass * createConstantPropagationPass()
FunctionPass * createReassociatePass()
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:1707
void initializeStraightLineStrengthReducePass(PassRegistry &)
FunctionPass * createCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
FunctionPass * createPartiallyInlineLibCallsPass()
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM)
See llvm::createMergedLoadStoreMotionPass function.
Definition: Scalar.cpp:145
void initializeConstantPropagationPass(PassRegistry &)
void initializeLoopLoadEliminationPass(PassRegistry &)
void initializeLoopIdiomRecognizeLegacyPassPass(PassRegistry &)
void initializeSpeculativeExecutionLegacyPassPass(PassRegistry &)
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:4137
void initializeLoopUnrollPass(PassRegistry &)
FunctionPass * createInstructionCombiningPass(bool ExpensiveCombines=true)
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM)
See llvm::createScopedNoAliasAAPass function.
Definition: Scalar.cpp:274
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM)
See llvm::createLoopRerollPass function.
Definition: Scalar.cpp:181
void initializeSeparateConstOffsetFromGEPPass(PassRegistry &)
void initializeGVNLegacyPassPass(PassRegistry &)
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry &)
void initializePlaceBackedgeSafepointsImplPass(PassRegistry &)
void initializeIndVarSimplifyLegacyPassPass(PassRegistry &)
void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:185
Pass * createCorrelatedValuePropagationPass()
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM)
See llvm::createDeadStoreEliminationPass function.
Definition: Scalar.cpp:129
void initializeLoopInstSimplifyLegacyPassPass(PassRegistry &)
void initializeLowerExpectIntrinsicPass(PassRegistry &)
This is the interface for a metadata-based TBAA.
FunctionPass * createTailCallEliminationPass()
This file provides the interface for LLVM&#39;s Global Value Numbering pass which eliminates fully redund...
void initializeInductiveRangeCheckEliminationPass(PassRegistry &)
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:106
void initializeLateCFGSimplifyPassPass(PassRegistry &)
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM)
See llvm::createAlignmentFromAssumptionsPass function.
Definition: Scalar.cpp:117
Pass * createLICMPass()
Definition: LICM.cpp:223
FunctionPass * createDeadStoreEliminationPass()
void initializeLowerAtomicLegacyPassPass(PassRegistry &)
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM)
See llvm::createLoopRotatePass function.
Definition: Scalar.cpp:177
void initializeSROALegacyPassPass(PassRegistry &)
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, int Threshold)
See llvm::createSROAPass function.
Definition: Scalar.cpp:229
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:173
void initializeSinkingLegacyPassPass(PassRegistry &)
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM)
See llvm::createLoopDeletionPass function.
Definition: Scalar.cpp:169
Pass * createLoopSinkPass()
void initializeInferAddressSpacesPass(PassRegistry &)
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:258
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:221
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM)
See llvm::createLoopIdiomPass function.
Definition: Scalar.cpp:173
void initializeFloat2IntLegacyPassPass(PassRegistry &)
FunctionPass * createLateCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM)
See llvm::createInstructionCombiningPass function.
Definition: Scalar.cpp:153
void initializeLoopRotateLegacyPassPass(PassRegistry &)
void initializeStructurizeCFGPass(PassRegistry &)
void initializeMemCpyOptLegacyPassPass(PassRegistry &)
void initializeLoopInterchangePass(PassRegistry &)
void initializeRegToMemPass(PassRegistry &)
void initializeLoopVersioningLICMPass(PassRegistry &)
void initializeCorrelatedValuePropagationPass(PassRegistry &)
void LLVMAddSCCPPass(LLVMPassManagerRef PM)
See llvm::createSCCPPass function.
Definition: Scalar.cpp:217
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R)
Definition: Scalar.cpp:105
void LLVMAddVerifierPass(LLVMPassManagerRef PM)
See llvm::createVerifierPass function.
Definition: Scalar.cpp:250
void initializeRewriteStatepointsForGCPass(PassRegistry &)
void initializeLoopDistributeLegacyPass(PassRegistry &)
void initializeScalarizerPass(PassRegistry &)
Pass * createLoopSimplifyCFGPass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:114
void initializeTailCallElimPass(PassRegistry &)
Pass * createLoopDeletionPass()
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM)
See llvm::demotePromoteMemoryToRegisterPass function.
Definition: Scalar.cpp:246
FunctionPass * createBasicAAWrapperPass()
Pass * createLoopUnswitchPass(bool OptimizeForSize=false, bool hasBranchDivergence=false)
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createBasicAliasAnalysisPass function.
Definition: Scalar.cpp:278
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM)
See llvm::createBitTrackingDCEPass function.
Definition: Scalar.cpp:113
void initializeLoopSimplifyCFGLegacyPassPass(PassRegistry &)
Pass * createLoopIdiomPass()
void initializeLoopVersioningPassPass(PassRegistry &)
void initializeGVNHoistLegacyPassPass(PassRegistry &)
void initializeIPSCCPLegacyPassPass(PassRegistry &)
void initializeGVNSinkLegacyPassPass(PassRegistry &)
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM)
See llvm::createCorrelatedValuePropagationPass function.
Definition: Scalar.cpp:254
void initializeAlignmentFromAssumptionsPass(PassRegistry &)
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM)
See llvm::createLowerExpectIntrinsicPass function.
Definition: Scalar.cpp:282
FunctionPass * createSROAPass()
Definition: SROA.cpp:4384
void initializeNaryReassociateLegacyPassPass(PassRegistry &)
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM)
See llvm::createIndVarSimplifyPass function.
Definition: Scalar.cpp:149
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM)
See llvm::createTailCallEliminationPass function.
Definition: Scalar.cpp:238
ImmutablePass * createTypeBasedAAWrapperPass()
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM)
See llvm::createPartiallyInlineLibCallsPass function.
Definition: Scalar.cpp:201
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
void initializeCFGSimplifyPassPass(PassRegistry &)
void initializeLoopPredicationLegacyPassPass(PassRegistry &)
void initializeLegacyLoopSinkPassPass(PassRegistry &)
void initializeReassociateLegacyPassPass(PassRegistry &)
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM)
See llvm::createLoopUnswitchPass function.
Definition: Scalar.cpp:193
void initializeEarlyCSEMemSSALegacyPassPass(PassRegistry &)
void initializeLegacyLICMPassPass(PassRegistry &)
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1134
FunctionPass * createScalarizerPass()
Definition: Scalarizer.cpp:770
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39
void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &)
void initializeMergeICmpsPass(PassRegistry &)
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM)
See llvm::createCFGSimplificationPass function.
Definition: Scalar.cpp:121
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry &)
void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:266
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM)
See llvm::createMemCpyOptPass function.
Definition: Scalar.cpp:197
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM)
See llvm::createAggressiveDCEPass function.
Definition: Scalar.cpp:109
void initializeLowerGuardIntrinsicLegacyPassPass(PassRegistry &)
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
Pass * createIndVarSimplifyPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:728
FunctionPass * createLowerExpectIntrinsicPass()
void initializeDeadInstEliminationPass(PassRegistry &)
void initializeFlattenCFGPassPass(PassRegistry &)