/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Transforms/Scalar/Scalar.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
15 | | #include "llvm/Transforms/Scalar.h" |
16 | | #include "llvm-c/Initialization.h" |
17 | | #include "llvm-c/Transforms/Scalar.h" |
18 | | #include "llvm/Analysis/BasicAliasAnalysis.h" |
19 | | #include "llvm/Analysis/Passes.h" |
20 | | #include "llvm/Analysis/ScopedNoAliasAA.h" |
21 | | #include "llvm/Analysis/TypeBasedAliasAnalysis.h" |
22 | | #include "llvm/IR/DataLayout.h" |
23 | | #include "llvm/IR/LegacyPassManager.h" |
24 | | #include "llvm/IR/Verifier.h" |
25 | | #include "llvm/InitializePasses.h" |
26 | | #include "llvm/Transforms/Scalar/GVN.h" |
27 | | #include "llvm/Transforms/Scalar/Scalarizer.h" |
28 | | #include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h" |
29 | | #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" |
30 | | |
31 | | using namespace llvm; |
32 | | |
33 | | /// initializeScalarOptsPasses - Initialize all passes linked into the |
34 | | /// ScalarOpts library. |
35 | 36.0k | void llvm::initializeScalarOpts(PassRegistry &Registry) { |
36 | 36.0k | initializeADCELegacyPassPass(Registry); |
37 | 36.0k | initializeBDCELegacyPassPass(Registry); |
38 | 36.0k | initializeAlignmentFromAssumptionsPass(Registry); |
39 | 36.0k | initializeCallSiteSplittingLegacyPassPass(Registry); |
40 | 36.0k | initializeConstantHoistingLegacyPassPass(Registry); |
41 | 36.0k | initializeConstantPropagationPass(Registry); |
42 | 36.0k | initializeCorrelatedValuePropagationPass(Registry); |
43 | 36.0k | initializeDCELegacyPassPass(Registry); |
44 | 36.0k | initializeDeadInstEliminationPass(Registry); |
45 | 36.0k | initializeDivRemPairsLegacyPassPass(Registry); |
46 | 36.0k | initializeScalarizerLegacyPassPass(Registry); |
47 | 36.0k | initializeDSELegacyPassPass(Registry); |
48 | 36.0k | initializeGuardWideningLegacyPassPass(Registry); |
49 | 36.0k | initializeLoopGuardWideningLegacyPassPass(Registry); |
50 | 36.0k | initializeGVNLegacyPassPass(Registry); |
51 | 36.0k | initializeNewGVNLegacyPassPass(Registry); |
52 | 36.0k | initializeEarlyCSELegacyPassPass(Registry); |
53 | 36.0k | initializeEarlyCSEMemSSALegacyPassPass(Registry); |
54 | 36.0k | initializeMakeGuardsExplicitLegacyPassPass(Registry); |
55 | 36.0k | initializeGVNHoistLegacyPassPass(Registry); |
56 | 36.0k | initializeGVNSinkLegacyPassPass(Registry); |
57 | 36.0k | initializeFlattenCFGPassPass(Registry); |
58 | 36.0k | initializeIRCELegacyPassPass(Registry); |
59 | 36.0k | initializeIndVarSimplifyLegacyPassPass(Registry); |
60 | 36.0k | initializeInferAddressSpacesPass(Registry); |
61 | 36.0k | initializeInstSimplifyLegacyPassPass(Registry); |
62 | 36.0k | initializeJumpThreadingPass(Registry); |
63 | 36.0k | initializeLegacyLICMPassPass(Registry); |
64 | 36.0k | initializeLegacyLoopSinkPassPass(Registry); |
65 | 36.0k | initializeLoopFuseLegacyPass(Registry); |
66 | 36.0k | initializeLoopDataPrefetchLegacyPassPass(Registry); |
67 | 36.0k | initializeLoopDeletionLegacyPassPass(Registry); |
68 | 36.0k | initializeLoopAccessLegacyAnalysisPass(Registry); |
69 | 36.0k | initializeLoopInstSimplifyLegacyPassPass(Registry); |
70 | 36.0k | initializeLoopInterchangePass(Registry); |
71 | 36.0k | initializeLoopPredicationLegacyPassPass(Registry); |
72 | 36.0k | initializeLoopRotateLegacyPassPass(Registry); |
73 | 36.0k | initializeLoopStrengthReducePass(Registry); |
74 | 36.0k | initializeLoopRerollPass(Registry); |
75 | 36.0k | initializeLoopUnrollPass(Registry); |
76 | 36.0k | initializeLoopUnrollAndJamPass(Registry); |
77 | 36.0k | initializeLoopUnswitchPass(Registry); |
78 | 36.0k | initializeWarnMissedTransformationsLegacyPass(Registry); |
79 | 36.0k | initializeLoopVersioningLICMPass(Registry); |
80 | 36.0k | initializeLoopIdiomRecognizeLegacyPassPass(Registry); |
81 | 36.0k | initializeLowerAtomicLegacyPassPass(Registry); |
82 | 36.0k | initializeLowerExpectIntrinsicPass(Registry); |
83 | 36.0k | initializeLowerGuardIntrinsicLegacyPassPass(Registry); |
84 | 36.0k | initializeLowerWidenableConditionLegacyPassPass(Registry); |
85 | 36.0k | initializeMemCpyOptLegacyPassPass(Registry); |
86 | 36.0k | initializeMergeICmpsLegacyPassPass(Registry); |
87 | 36.0k | initializeMergedLoadStoreMotionLegacyPassPass(Registry); |
88 | 36.0k | initializeNaryReassociateLegacyPassPass(Registry); |
89 | 36.0k | initializePartiallyInlineLibCallsLegacyPassPass(Registry); |
90 | 36.0k | initializeReassociateLegacyPassPass(Registry); |
91 | 36.0k | initializeRegToMemPass(Registry); |
92 | 36.0k | initializeRewriteStatepointsForGCLegacyPassPass(Registry); |
93 | 36.0k | initializeSCCPLegacyPassPass(Registry); |
94 | 36.0k | initializeSROALegacyPassPass(Registry); |
95 | 36.0k | initializeCFGSimplifyPassPass(Registry); |
96 | 36.0k | initializeStructurizeCFGPass(Registry); |
97 | 36.0k | initializeSimpleLoopUnswitchLegacyPassPass(Registry); |
98 | 36.0k | initializeSinkingLegacyPassPass(Registry); |
99 | 36.0k | initializeTailCallElimPass(Registry); |
100 | 36.0k | initializeSeparateConstOffsetFromGEPPass(Registry); |
101 | 36.0k | initializeSpeculativeExecutionLegacyPassPass(Registry); |
102 | 36.0k | initializeStraightLineStrengthReducePass(Registry); |
103 | 36.0k | initializePlaceBackedgeSafepointsImplPass(Registry); |
104 | 36.0k | initializePlaceSafepointsPass(Registry); |
105 | 36.0k | initializeFloat2IntLegacyPassPass(Registry); |
106 | 36.0k | initializeLoopDistributeLegacyPass(Registry); |
107 | 36.0k | initializeLoopLoadEliminationPass(Registry); |
108 | 36.0k | initializeLoopSimplifyCFGLegacyPassPass(Registry); |
109 | 36.0k | initializeLoopVersioningPassPass(Registry); |
110 | 36.0k | initializeEntryExitInstrumenterPass(Registry); |
111 | 36.0k | initializePostInlineEntryExitInstrumenterPass(Registry); |
112 | 36.0k | } |
113 | | |
114 | 0 | void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM) { |
115 | 0 | unwrap(PM)->add(createLoopSimplifyCFGPass()); |
116 | 0 | } |
117 | | |
118 | 0 | void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { |
119 | 0 | initializeScalarOpts(*unwrap(R)); |
120 | 0 | } |
121 | | |
122 | 0 | void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { |
123 | 0 | unwrap(PM)->add(createAggressiveDCEPass()); |
124 | 0 | } |
125 | | |
126 | 0 | void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) { |
127 | 0 | unwrap(PM)->add(createBitTrackingDCEPass()); |
128 | 0 | } |
129 | | |
130 | 0 | void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM) { |
131 | 0 | unwrap(PM)->add(createAlignmentFromAssumptionsPass()); |
132 | 0 | } |
133 | | |
134 | 0 | void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { |
135 | 0 | unwrap(PM)->add(createCFGSimplificationPass(1, false, false, true)); |
136 | 0 | } |
137 | | |
138 | 0 | void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { |
139 | 0 | unwrap(PM)->add(createDeadStoreEliminationPass()); |
140 | 0 | } |
141 | | |
142 | 0 | void LLVMAddScalarizerPass(LLVMPassManagerRef PM) { |
143 | 0 | unwrap(PM)->add(createScalarizerPass()); |
144 | 0 | } |
145 | | |
146 | 0 | void LLVMAddGVNPass(LLVMPassManagerRef PM) { |
147 | 0 | unwrap(PM)->add(createGVNPass()); |
148 | 0 | } |
149 | | |
150 | 0 | void LLVMAddNewGVNPass(LLVMPassManagerRef PM) { |
151 | 0 | unwrap(PM)->add(createNewGVNPass()); |
152 | 0 | } |
153 | | |
154 | 0 | void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM) { |
155 | 0 | unwrap(PM)->add(createMergedLoadStoreMotionPass()); |
156 | 0 | } |
157 | | |
158 | 0 | void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { |
159 | 0 | unwrap(PM)->add(createIndVarSimplifyPass()); |
160 | 0 | } |
161 | | |
162 | 0 | void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { |
163 | 0 | unwrap(PM)->add(createJumpThreadingPass()); |
164 | 0 | } |
165 | | |
166 | 0 | void LLVMAddLoopSinkPass(LLVMPassManagerRef PM) { |
167 | 0 | unwrap(PM)->add(createLoopSinkPass()); |
168 | 0 | } |
169 | | |
170 | 0 | void LLVMAddLICMPass(LLVMPassManagerRef PM) { |
171 | 0 | unwrap(PM)->add(createLICMPass()); |
172 | 0 | } |
173 | | |
174 | 0 | void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { |
175 | 0 | unwrap(PM)->add(createLoopDeletionPass()); |
176 | 0 | } |
177 | | |
178 | 0 | void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) { |
179 | 0 | unwrap(PM)->add(createLoopIdiomPass()); |
180 | 0 | } |
181 | | |
182 | 0 | void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { |
183 | 0 | unwrap(PM)->add(createLoopRotatePass()); |
184 | 0 | } |
185 | | |
186 | 0 | void LLVMAddLoopRerollPass(LLVMPassManagerRef PM) { |
187 | 0 | unwrap(PM)->add(createLoopRerollPass()); |
188 | 0 | } |
189 | | |
190 | 0 | void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { |
191 | 0 | unwrap(PM)->add(createLoopUnrollPass()); |
192 | 0 | } |
193 | | |
194 | 0 | void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM) { |
195 | 0 | unwrap(PM)->add(createLoopUnrollAndJamPass()); |
196 | 0 | } |
197 | | |
198 | 0 | void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { |
199 | 0 | unwrap(PM)->add(createLoopUnswitchPass()); |
200 | 0 | } |
201 | | |
202 | 0 | void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM) { |
203 | 0 | unwrap(PM)->add(createLowerAtomicPass()); |
204 | 0 | } |
205 | | |
206 | 0 | void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { |
207 | 0 | unwrap(PM)->add(createMemCpyOptPass()); |
208 | 0 | } |
209 | | |
210 | 0 | void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM) { |
211 | 0 | unwrap(PM)->add(createPartiallyInlineLibCallsPass()); |
212 | 0 | } |
213 | | |
214 | 0 | void LLVMAddReassociatePass(LLVMPassManagerRef PM) { |
215 | 0 | unwrap(PM)->add(createReassociatePass()); |
216 | 0 | } |
217 | | |
218 | 0 | void LLVMAddSCCPPass(LLVMPassManagerRef PM) { |
219 | 0 | unwrap(PM)->add(createSCCPPass()); |
220 | 0 | } |
221 | | |
222 | 0 | void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { |
223 | 0 | unwrap(PM)->add(createSROAPass()); |
224 | 0 | } |
225 | | |
226 | 0 | void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) { |
227 | 0 | unwrap(PM)->add(createSROAPass()); |
228 | 0 | } |
229 | | |
230 | | void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, |
231 | 0 | int Threshold) { |
232 | 0 | unwrap(PM)->add(createSROAPass()); |
233 | 0 | } |
234 | | |
235 | 0 | void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { |
236 | 0 | // NOTE: The simplify-libcalls pass has been removed. |
237 | 0 | } |
238 | | |
239 | 0 | void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { |
240 | 0 | unwrap(PM)->add(createTailCallEliminationPass()); |
241 | 0 | } |
242 | | |
243 | 7 | void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { |
244 | 7 | unwrap(PM)->add(createConstantPropagationPass()); |
245 | 7 | } |
246 | | |
247 | 0 | void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { |
248 | 0 | unwrap(PM)->add(createDemoteRegisterToMemoryPass()); |
249 | 0 | } |
250 | | |
251 | 0 | void LLVMAddVerifierPass(LLVMPassManagerRef PM) { |
252 | 0 | unwrap(PM)->add(createVerifierPass()); |
253 | 0 | } |
254 | | |
255 | 0 | void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) { |
256 | 0 | unwrap(PM)->add(createCorrelatedValuePropagationPass()); |
257 | 0 | } |
258 | | |
259 | 0 | void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) { |
260 | 0 | unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/)); |
261 | 0 | } |
262 | | |
263 | 0 | void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM) { |
264 | 0 | unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/)); |
265 | 0 | } |
266 | | |
267 | 0 | void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM) { |
268 | 0 | unwrap(PM)->add(createGVNHoistPass()); |
269 | 0 | } |
270 | | |
271 | 0 | void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) { |
272 | 0 | unwrap(PM)->add(createTypeBasedAAWrapperPass()); |
273 | 0 | } |
274 | | |
275 | 0 | void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM) { |
276 | 0 | unwrap(PM)->add(createScopedNoAliasAAWrapperPass()); |
277 | 0 | } |
278 | | |
279 | 0 | void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) { |
280 | 0 | unwrap(PM)->add(createBasicAAWrapperPass()); |
281 | 0 | } |
282 | | |
283 | 0 | void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) { |
284 | 0 | unwrap(PM)->add(createLowerExpectIntrinsicPass()); |
285 | 0 | } |
286 | | |
287 | 0 | void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM) { |
288 | 0 | unwrap(PM)->add(createUnifyFunctionExitNodesPass()); |
289 | 0 | } |