LLVM  4.0.0
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"
24 #include "llvm/IR/DataLayout.h"
25 #include "llvm/IR/Verifier.h"
26 #include "llvm/InitializePasses.h"
28 
29 using namespace llvm;
30 
31 /// initializeScalarOptsPasses - Initialize all passes linked into the
32 /// ScalarOpts library.
42  initializeScalarizerPass(Registry);
46  initializeNewGVNPass(Registry);
63  initializeLoopRerollPass(Registry);
64  initializeLoopUnrollPass(Registry);
76  initializeRegToMemPass(Registry);
88  initializeLoadCombinePass(Registry);
96 }
97 
100 }
101 
103  unwrap(PM)->add(createAggressiveDCEPass());
104 }
105 
107  unwrap(PM)->add(createBitTrackingDCEPass());
108 }
109 
112 }
113 
116 }
117 
120 }
121 
123  unwrap(PM)->add(createScalarizerPass());
124 }
125 
127  unwrap(PM)->add(createGVNPass());
128 }
129 
131  unwrap(PM)->add(createNewGVNPass());
132 }
133 
136 }
137 
139  unwrap(PM)->add(createIndVarSimplifyPass());
140 }
141 
144 }
145 
147  unwrap(PM)->add(createJumpThreadingPass());
148 }
149 
151  unwrap(PM)->add(createLoopSinkPass());
152 }
153 
155  unwrap(PM)->add(createLICMPass());
156 }
157 
159  unwrap(PM)->add(createLoopDeletionPass());
160 }
161 
163  unwrap(PM)->add(createLoopIdiomPass());
164 }
165 
167  unwrap(PM)->add(createLoopRotatePass());
168 }
169 
171  unwrap(PM)->add(createLoopRerollPass());
172 }
173 
175  unwrap(PM)->add(createLoopSimplifyCFGPass());
176 }
177 
179  unwrap(PM)->add(createLoopUnrollPass());
180 }
181 
183  unwrap(PM)->add(createLoopUnswitchPass());
184 }
185 
187  unwrap(PM)->add(createMemCpyOptPass());
188 }
189 
192 }
193 
195  unwrap(PM)->add(createLowerSwitchPass());
196 }
197 
200 }
201 
203  unwrap(PM)->add(createReassociatePass());
204 }
205 
207  unwrap(PM)->add(createSCCPPass());
208 }
209 
211  unwrap(PM)->add(createSROAPass());
212 }
213 
215  unwrap(PM)->add(createSROAPass());
216 }
217 
219  int Threshold) {
220  unwrap(PM)->add(createSROAPass());
221 }
222 
224  // NOTE: The simplify-libcalls pass has been removed.
225 }
226 
229 }
230 
233 }
234 
237 }
238 
240  unwrap(PM)->add(createVerifierPass());
241 }
242 
245 }
246 
248  unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/));
249 }
250 
252  unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/));
253 }
254 
256  unwrap(PM)->add(createGVNHoistPass());
257 }
258 
261 }
262 
265 }
266 
268  unwrap(PM)->add(createBasicAAWrapperPass());
269 }
270 
273 }
void initializeEarlyCSELegacyPassPass(PassRegistry &)
void initializeDCELegacyPassPass(PassRegistry &)
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
Definition: GVN.cpp:2797
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM)
See llvm::createJumpThreadingPass function.
Definition: Scalar.cpp:146
void initializeLoopUnswitchPass(PassRegistry &)
void LLVMAddGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:126
Pass * createLoopRerollPass()
void initializeBDCELegacyPassPass(PassRegistry &)
void initializeLoopAccessLegacyAnalysisPass(PassRegistry &)
FunctionPass * createLowerSwitchPass()
void initializeConstantHoistingLegacyPassPass(PassRegistry &)
void initializeJumpThreadingPass(PassRegistry &)
void LLVMAddLICMPass(LLVMPassManagerRef PM)
See llvm::createLICMPass function.
Definition: Scalar.cpp:154
void initializeDSELegacyPassPass(PassRegistry &)
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM)
See llvm::createSimplifyLibCallsPass function.
Definition: Scalar.cpp:223
void initializeLoopDeletionLegacyPassPass(PassRegistry &)
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createTypeBasedAliasAnalysisPass function.
Definition: Scalar.cpp:259
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:4791
void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:251
void LLVMAddReassociatePass(LLVMPassManagerRef PM)
See llvm::createReassociatePass function.
Definition: Scalar.cpp:202
void initializeScalarOpts(PassRegistry &)
Initialize all passes linked into the ScalarOpts library.
Definition: Scalar.cpp:33
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM)
See llvm::createLowerSwitchPass function.
Definition: Scalar.cpp:194
void initializeLoopStrengthReducePass(PassRegistry &)
void initializePlaceSafepointsPass(PassRegistry &)
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: c/Types.h:103
void initializeLoopRerollPass(PassRegistry &)
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1001
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM)
See llvm::createConstantPropagationPass function.
Definition: Scalar.cpp:231
FunctionPass * createDemoteRegisterToMemoryPass()
Definition: Reg2Mem.cpp:126
void LLVMAddNewGVNPass(LLVMPassManagerRef PM)
See llvm::createGVNPass function.
Definition: Scalar.cpp:130
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM)
See llvm::createPromoteMemoryToRegisterPass function.
Definition: Scalar.cpp:198
void LLVMAddLoopSinkPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:150
ImmutablePass * createScopedNoAliasAAWrapperPass()
FunctionPass * createAlignmentFromAssumptionsPass()
FunctionPass * createJumpThreadingPass(int Threshold=-1)
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM)
See llvm::createLoopUnrollPass function.
Definition: Scalar.cpp:178
void initializeLoadCombinePass(PassRegistry &)
void initializeADCELegacyPassPass(PassRegistry &)
void LLVMAddScalarizerPass(LLVMPassManagerRef PM)
See llvm::createScalarizerPass function.
Definition: Scalar.cpp:122
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:214
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:191
void initializeSCCPLegacyPassPass(PassRegistry &)
FunctionPass * createConstantPropagationPass()
FunctionPass * createReassociatePass()
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:1646
void initializeStraightLineStrengthReducePass(PassRegistry &)
FunctionPass * createPartiallyInlineLibCallsPass()
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM)
See llvm::createMergedLoadStoreMotionPass function.
Definition: Scalar.cpp:134
Pass * createLoopUnswitchPass(bool OptimizeForSize=false)
void initializeConstantPropagationPass(PassRegistry &)
void initializeLoopLoadEliminationPass(PassRegistry &)
void initializeLoopIdiomRecognizeLegacyPassPass(PassRegistry &)
void initializeSpeculativeExecutionLegacyPassPass(PassRegistry &)
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:372
void initializeLoopUnrollPass(PassRegistry &)
FunctionPass * createInstructionCombiningPass(bool ExpensiveCombines=true)
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM)
See llvm::createScopedNoAliasAAPass function.
Definition: Scalar.cpp:263
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM)
See llvm::createLoopRerollPass function.
Definition: Scalar.cpp:170
void initializeSeparateConstOffsetFromGEPPass(PassRegistry &)
void initializeGVNLegacyPassPass(PassRegistry &)
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry &)
void initializePlaceBackedgeSafepointsImplPass(PassRegistry &)
void initializeIndVarSimplifyLegacyPassPass(PassRegistry &)
void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:174
Pass * createCorrelatedValuePropagationPass()
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM)
See llvm::createDeadStoreEliminationPass function.
Definition: Scalar.cpp:118
void initializeLoopInstSimplifyLegacyPassPass(PassRegistry &)
void initializeLowerExpectIntrinsicPass(PassRegistry &)
This is the interface for a metadata-based TBAA.
FunctionPass * createTailCallEliminationPass()
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
void initializeInductiveRangeCheckEliminationPass(PassRegistry &)
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:105
FunctionPass * createCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM)
See llvm::createAlignmentFromAssumptionsPass function.
Definition: Scalar.cpp:110
Pass * createLICMPass()
Definition: LICM.cpp:217
FunctionPass * createDeadStoreEliminationPass()
void initializeLowerAtomicLegacyPassPass(PassRegistry &)
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM)
See llvm::createLoopRotatePass function.
Definition: Scalar.cpp:166
void initializeSROALegacyPassPass(PassRegistry &)
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, int Threshold)
See llvm::createSROAPass function.
Definition: Scalar.cpp:218
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:118
void initializeSinkingLegacyPassPass(PassRegistry &)
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM)
See llvm::createLoopDeletionPass function.
Definition: Scalar.cpp:158
Pass * createLoopSinkPass()
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM)
See llvm::createEarlyCSEPass function.
Definition: Scalar.cpp:247
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM)
See llvm::createSROAPass function.
Definition: Scalar.cpp:210
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM)
See llvm::createLoopIdiomPass function.
Definition: Scalar.cpp:162
void initializeFloat2IntLegacyPassPass(PassRegistry &)
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM)
See llvm::createInstructionCombiningPass function.
Definition: Scalar.cpp:142
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:206
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R)
Definition: Scalar.cpp:98
void LLVMAddVerifierPass(LLVMPassManagerRef PM)
See llvm::createVerifierPass function.
Definition: Scalar.cpp:239
void initializeRewriteStatepointsForGCPass(PassRegistry &)
void initializeLoopDistributeLegacyPass(PassRegistry &)
void initializeScalarizerPass(PassRegistry &)
void initializeNewGVNPass(PassRegistry &)
Pass * createLoopUnrollPass(int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1)
Pass * createLoopSimplifyCFGPass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: c/Types.h:100
void initializeTailCallElimPass(PassRegistry &)
Pass * createLoopDeletionPass()
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM)
See llvm::demotePromoteMemoryToRegisterPass function.
Definition: Scalar.cpp:235
FunctionPass * createBasicAAWrapperPass()
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM)
See llvm::createBasicAliasAnalysisPass function.
Definition: Scalar.cpp:267
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM)
See llvm::createBitTrackingDCEPass function.
Definition: Scalar.cpp:106
void initializeLoopSimplifyCFGLegacyPassPass(PassRegistry &)
Pass * createLoopIdiomPass()
void initializeLoopVersioningPassPass(PassRegistry &)
void initializeGVNHoistLegacyPassPass(PassRegistry &)
void initializeIPSCCPLegacyPassPass(PassRegistry &)
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM)
See llvm::createCorrelatedValuePropagationPass function.
Definition: Scalar.cpp:243
void initializeAlignmentFromAssumptionsPass(PassRegistry &)
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM)
See llvm::createLowerExpectIntrinsicPass function.
Definition: Scalar.cpp:271
FunctionPass * createSROAPass()
Definition: SROA.cpp:4283
void initializeNaryReassociateLegacyPassPass(PassRegistry &)
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM)
See llvm::createIndVarSimplifyPass function.
Definition: Scalar.cpp:138
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM)
See llvm::createTailCallEliminationPass function.
Definition: Scalar.cpp:227
ImmutablePass * createTypeBasedAAWrapperPass()
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM)
See llvm::createPartiallyInlineLibCallsPass function.
Definition: Scalar.cpp:190
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
void initializeCFGSimplifyPassPass(PassRegistry &)
void initializeLegacyLoopSinkPassPass(PassRegistry &)
void initializeReassociateLegacyPassPass(PassRegistry &)
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM)
See llvm::createLoopUnswitchPass function.
Definition: Scalar.cpp:182
void initializeEarlyCSEMemSSALegacyPassPass(PassRegistry &)
void initializeLegacyLICMPassPass(PassRegistry &)
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1050
FunctionPass * createScalarizerPass()
Definition: Scalarizer.cpp:757
This is the interface for LLVM's primary stateless and local alias analysis.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:40
void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &)
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM)
See llvm::createCFGSimplificationPass function.
Definition: Scalar.cpp:114
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry &)
void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM)
Definition: Scalar.cpp:255
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM)
See llvm::createMemCpyOptPass function.
Definition: Scalar.cpp:186
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM)
See llvm::createAggressiveDCEPass function.
Definition: Scalar.cpp:102
void initializeLowerGuardIntrinsicLegacyPassPass(PassRegistry &)
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
Pass * createIndVarSimplifyPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:683
FunctionPass * createLowerExpectIntrinsicPass()
void initializeDeadInstEliminationPass(PassRegistry &)
void initializeFlattenCFGPassPass(PassRegistry &)