[llvm-exegesis] [NFC] Fixing typo.
[llvm-complete.git] / lib / Transforms / Scalar / Scalar.cpp
blobc91ffda6d9807b82ebcc931af651097b7c777836
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.
13 //===----------------------------------------------------------------------===//
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"
31 using namespace llvm;
33 /// initializeScalarOptsPasses - Initialize all passes linked into the
34 /// ScalarOpts library.
35 void llvm::initializeScalarOpts(PassRegistry &Registry) {
36 initializeADCELegacyPassPass(Registry);
37 initializeBDCELegacyPassPass(Registry);
38 initializeAlignmentFromAssumptionsPass(Registry);
39 initializeCallSiteSplittingLegacyPassPass(Registry);
40 initializeConstantHoistingLegacyPassPass(Registry);
41 initializeConstantPropagationPass(Registry);
42 initializeCorrelatedValuePropagationPass(Registry);
43 initializeDCELegacyPassPass(Registry);
44 initializeDeadInstEliminationPass(Registry);
45 initializeDivRemPairsLegacyPassPass(Registry);
46 initializeScalarizerLegacyPassPass(Registry);
47 initializeDSELegacyPassPass(Registry);
48 initializeGuardWideningLegacyPassPass(Registry);
49 initializeLoopGuardWideningLegacyPassPass(Registry);
50 initializeGVNLegacyPassPass(Registry);
51 initializeNewGVNLegacyPassPass(Registry);
52 initializeEarlyCSELegacyPassPass(Registry);
53 initializeEarlyCSEMemSSALegacyPassPass(Registry);
54 initializeMakeGuardsExplicitLegacyPassPass(Registry);
55 initializeGVNHoistLegacyPassPass(Registry);
56 initializeGVNSinkLegacyPassPass(Registry);
57 initializeFlattenCFGPassPass(Registry);
58 initializeIRCELegacyPassPass(Registry);
59 initializeIndVarSimplifyLegacyPassPass(Registry);
60 initializeInferAddressSpacesPass(Registry);
61 initializeInstSimplifyLegacyPassPass(Registry);
62 initializeJumpThreadingPass(Registry);
63 initializeLegacyLICMPassPass(Registry);
64 initializeLegacyLoopSinkPassPass(Registry);
65 initializeLoopDataPrefetchLegacyPassPass(Registry);
66 initializeLoopDeletionLegacyPassPass(Registry);
67 initializeLoopAccessLegacyAnalysisPass(Registry);
68 initializeLoopInstSimplifyLegacyPassPass(Registry);
69 initializeLoopInterchangePass(Registry);
70 initializeLoopPredicationLegacyPassPass(Registry);
71 initializeLoopRotateLegacyPassPass(Registry);
72 initializeLoopStrengthReducePass(Registry);
73 initializeLoopRerollPass(Registry);
74 initializeLoopUnrollPass(Registry);
75 initializeLoopUnrollAndJamPass(Registry);
76 initializeLoopUnswitchPass(Registry);
77 initializeWarnMissedTransformationsLegacyPass(Registry);
78 initializeLoopVersioningLICMPass(Registry);
79 initializeLoopIdiomRecognizeLegacyPassPass(Registry);
80 initializeLowerAtomicLegacyPassPass(Registry);
81 initializeLowerExpectIntrinsicPass(Registry);
82 initializeLowerGuardIntrinsicLegacyPassPass(Registry);
83 initializeLowerWidenableConditionLegacyPassPass(Registry);
84 initializeMemCpyOptLegacyPassPass(Registry);
85 initializeMergeICmpsPass(Registry);
86 initializeMergedLoadStoreMotionLegacyPassPass(Registry);
87 initializeNaryReassociateLegacyPassPass(Registry);
88 initializePartiallyInlineLibCallsLegacyPassPass(Registry);
89 initializeReassociateLegacyPassPass(Registry);
90 initializeRegToMemPass(Registry);
91 initializeRewriteStatepointsForGCLegacyPassPass(Registry);
92 initializeSCCPLegacyPassPass(Registry);
93 initializeSROALegacyPassPass(Registry);
94 initializeCFGSimplifyPassPass(Registry);
95 initializeStructurizeCFGPass(Registry);
96 initializeSimpleLoopUnswitchLegacyPassPass(Registry);
97 initializeSinkingLegacyPassPass(Registry);
98 initializeTailCallElimPass(Registry);
99 initializeSeparateConstOffsetFromGEPPass(Registry);
100 initializeSpeculativeExecutionLegacyPassPass(Registry);
101 initializeStraightLineStrengthReducePass(Registry);
102 initializePlaceBackedgeSafepointsImplPass(Registry);
103 initializePlaceSafepointsPass(Registry);
104 initializeFloat2IntLegacyPassPass(Registry);
105 initializeLoopDistributeLegacyPass(Registry);
106 initializeLoopLoadEliminationPass(Registry);
107 initializeLoopSimplifyCFGLegacyPassPass(Registry);
108 initializeLoopVersioningPassPass(Registry);
109 initializeEntryExitInstrumenterPass(Registry);
110 initializePostInlineEntryExitInstrumenterPass(Registry);
113 void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM) {
114 unwrap(PM)->add(createLoopSimplifyCFGPass());
117 void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) {
118 initializeScalarOpts(*unwrap(R));
121 void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) {
122 unwrap(PM)->add(createAggressiveDCEPass());
125 void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) {
126 unwrap(PM)->add(createBitTrackingDCEPass());
129 void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM) {
130 unwrap(PM)->add(createAlignmentFromAssumptionsPass());
133 void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) {
134 unwrap(PM)->add(createCFGSimplificationPass(1, false, false, true));
137 void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) {
138 unwrap(PM)->add(createDeadStoreEliminationPass());
141 void LLVMAddScalarizerPass(LLVMPassManagerRef PM) {
142 unwrap(PM)->add(createScalarizerPass());
145 void LLVMAddGVNPass(LLVMPassManagerRef PM) {
146 unwrap(PM)->add(createGVNPass());
149 void LLVMAddNewGVNPass(LLVMPassManagerRef PM) {
150 unwrap(PM)->add(createNewGVNPass());
153 void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM) {
154 unwrap(PM)->add(createMergedLoadStoreMotionPass());
157 void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) {
158 unwrap(PM)->add(createIndVarSimplifyPass());
161 void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) {
162 unwrap(PM)->add(createJumpThreadingPass());
165 void LLVMAddLoopSinkPass(LLVMPassManagerRef PM) {
166 unwrap(PM)->add(createLoopSinkPass());
169 void LLVMAddLICMPass(LLVMPassManagerRef PM) {
170 unwrap(PM)->add(createLICMPass());
173 void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) {
174 unwrap(PM)->add(createLoopDeletionPass());
177 void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) {
178 unwrap(PM)->add(createLoopIdiomPass());
181 void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
182 unwrap(PM)->add(createLoopRotatePass());
185 void LLVMAddLoopRerollPass(LLVMPassManagerRef PM) {
186 unwrap(PM)->add(createLoopRerollPass());
189 void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) {
190 unwrap(PM)->add(createLoopUnrollPass());
193 void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM) {
194 unwrap(PM)->add(createLoopUnrollAndJamPass());
197 void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) {
198 unwrap(PM)->add(createLoopUnswitchPass());
201 void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM) {
202 unwrap(PM)->add(createLowerAtomicPass());
205 void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) {
206 unwrap(PM)->add(createMemCpyOptPass());
209 void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM) {
210 unwrap(PM)->add(createPartiallyInlineLibCallsPass());
213 void LLVMAddReassociatePass(LLVMPassManagerRef PM) {
214 unwrap(PM)->add(createReassociatePass());
217 void LLVMAddSCCPPass(LLVMPassManagerRef PM) {
218 unwrap(PM)->add(createSCCPPass());
221 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) {
222 unwrap(PM)->add(createSROAPass());
225 void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) {
226 unwrap(PM)->add(createSROAPass());
229 void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
230 int Threshold) {
231 unwrap(PM)->add(createSROAPass());
234 void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) {
235 // NOTE: The simplify-libcalls pass has been removed.
238 void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) {
239 unwrap(PM)->add(createTailCallEliminationPass());
242 void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) {
243 unwrap(PM)->add(createConstantPropagationPass());
246 void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
247 unwrap(PM)->add(createDemoteRegisterToMemoryPass());
250 void LLVMAddVerifierPass(LLVMPassManagerRef PM) {
251 unwrap(PM)->add(createVerifierPass());
254 void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) {
255 unwrap(PM)->add(createCorrelatedValuePropagationPass());
258 void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) {
259 unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/));
262 void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM) {
263 unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/));
266 void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM) {
267 unwrap(PM)->add(createGVNHoistPass());
270 void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) {
271 unwrap(PM)->add(createTypeBasedAAWrapperPass());
274 void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM) {
275 unwrap(PM)->add(createScopedNoAliasAAWrapperPass());
278 void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) {
279 unwrap(PM)->add(createBasicAAWrapperPass());
282 void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) {
283 unwrap(PM)->add(createLowerExpectIntrinsicPass());
286 void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM) {
287 unwrap(PM)->add(createUnifyFunctionExitNodesPass());