[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Transforms / Scalar / Scalar.cpp
bloba041af0d70d00038bc3ab050651812f173e60daa
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 initializeAnnotationRemarksLegacyPass(Registry);
38 initializeBDCELegacyPassPass(Registry);
39 initializeAlignmentFromAssumptionsPass(Registry);
40 initializeCallSiteSplittingLegacyPassPass(Registry);
41 initializeConstantHoistingLegacyPassPass(Registry);
42 initializeConstraintEliminationPass(Registry);
43 initializeCorrelatedValuePropagationPass(Registry);
44 initializeDCELegacyPassPass(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 initializeDFAJumpThreadingLegacyPassPass(Registry);
64 initializeLegacyLICMPassPass(Registry);
65 initializeLegacyLoopSinkPassPass(Registry);
66 initializeLoopFuseLegacyPass(Registry);
67 initializeLoopDataPrefetchLegacyPassPass(Registry);
68 initializeLoopDeletionLegacyPassPass(Registry);
69 initializeLoopAccessLegacyAnalysisPass(Registry);
70 initializeLoopInstSimplifyLegacyPassPass(Registry);
71 initializeLoopInterchangeLegacyPassPass(Registry);
72 initializeLoopFlattenLegacyPassPass(Registry);
73 initializeLoopPredicationLegacyPassPass(Registry);
74 initializeLoopRotateLegacyPassPass(Registry);
75 initializeLoopStrengthReducePass(Registry);
76 initializeLoopRerollLegacyPassPass(Registry);
77 initializeLoopUnrollPass(Registry);
78 initializeLoopUnrollAndJamPass(Registry);
79 initializeLoopUnswitchPass(Registry);
80 initializeWarnMissedTransformationsLegacyPass(Registry);
81 initializeLoopVersioningLICMLegacyPassPass(Registry);
82 initializeLoopIdiomRecognizeLegacyPassPass(Registry);
83 initializeLowerAtomicLegacyPassPass(Registry);
84 initializeLowerConstantIntrinsicsPass(Registry);
85 initializeLowerExpectIntrinsicPass(Registry);
86 initializeLowerGuardIntrinsicLegacyPassPass(Registry);
87 initializeLowerMatrixIntrinsicsLegacyPassPass(Registry);
88 initializeLowerMatrixIntrinsicsMinimalLegacyPassPass(Registry);
89 initializeLowerWidenableConditionLegacyPassPass(Registry);
90 initializeMemCpyOptLegacyPassPass(Registry);
91 initializeMergeICmpsLegacyPassPass(Registry);
92 initializeMergedLoadStoreMotionLegacyPassPass(Registry);
93 initializeNaryReassociateLegacyPassPass(Registry);
94 initializePartiallyInlineLibCallsLegacyPassPass(Registry);
95 initializeReassociateLegacyPassPass(Registry);
96 initializeRedundantDbgInstEliminationPass(Registry);
97 initializeRegToMemLegacyPass(Registry);
98 initializeRewriteStatepointsForGCLegacyPassPass(Registry);
99 initializeScalarizeMaskedMemIntrinLegacyPassPass(Registry);
100 initializeSCCPLegacyPassPass(Registry);
101 initializeSROALegacyPassPass(Registry);
102 initializeCFGSimplifyPassPass(Registry);
103 initializeStructurizeCFGLegacyPassPass(Registry);
104 initializeSimpleLoopUnswitchLegacyPassPass(Registry);
105 initializeSinkingLegacyPassPass(Registry);
106 initializeTailCallElimPass(Registry);
107 initializeSeparateConstOffsetFromGEPLegacyPassPass(Registry);
108 initializeSpeculativeExecutionLegacyPassPass(Registry);
109 initializeStraightLineStrengthReduceLegacyPassPass(Registry);
110 initializePlaceBackedgeSafepointsImplPass(Registry);
111 initializePlaceSafepointsPass(Registry);
112 initializeFloat2IntLegacyPassPass(Registry);
113 initializeLoopDistributeLegacyPass(Registry);
114 initializeLoopLoadEliminationPass(Registry);
115 initializeLoopSimplifyCFGLegacyPassPass(Registry);
116 initializeLoopVersioningLegacyPassPass(Registry);
117 initializeEntryExitInstrumenterPass(Registry);
118 initializePostInlineEntryExitInstrumenterPass(Registry);
121 void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM) {
122 unwrap(PM)->add(createLoopSimplifyCFGPass());
125 void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) {
126 initializeScalarOpts(*unwrap(R));
129 void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) {
130 unwrap(PM)->add(createAggressiveDCEPass());
133 void LLVMAddDCEPass(LLVMPassManagerRef PM) {
134 unwrap(PM)->add(createDeadCodeEliminationPass());
137 void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) {
138 unwrap(PM)->add(createBitTrackingDCEPass());
141 void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM) {
142 unwrap(PM)->add(createAlignmentFromAssumptionsPass());
145 void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) {
146 unwrap(PM)->add(createCFGSimplificationPass());
149 void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) {
150 unwrap(PM)->add(createDeadStoreEliminationPass());
153 void LLVMAddScalarizerPass(LLVMPassManagerRef PM) {
154 unwrap(PM)->add(createScalarizerPass());
157 void LLVMAddGVNPass(LLVMPassManagerRef PM) {
158 unwrap(PM)->add(createGVNPass());
161 void LLVMAddNewGVNPass(LLVMPassManagerRef PM) {
162 unwrap(PM)->add(createNewGVNPass());
165 void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM) {
166 unwrap(PM)->add(createMergedLoadStoreMotionPass());
169 void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) {
170 unwrap(PM)->add(createIndVarSimplifyPass());
173 void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM) {
174 unwrap(PM)->add(createInstSimplifyLegacyPass());
177 void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) {
178 unwrap(PM)->add(createJumpThreadingPass());
181 void LLVMAddLoopSinkPass(LLVMPassManagerRef PM) {
182 unwrap(PM)->add(createLoopSinkPass());
185 void LLVMAddLICMPass(LLVMPassManagerRef PM) {
186 unwrap(PM)->add(createLICMPass());
189 void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) {
190 unwrap(PM)->add(createLoopDeletionPass());
193 void LLVMAddLoopFlattenPass(LLVMPassManagerRef PM) {
194 unwrap(PM)->add(createLoopFlattenPass());
197 void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) {
198 unwrap(PM)->add(createLoopIdiomPass());
201 void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
202 unwrap(PM)->add(createLoopRotatePass());
205 void LLVMAddLoopRerollPass(LLVMPassManagerRef PM) {
206 unwrap(PM)->add(createLoopRerollPass());
209 void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) {
210 unwrap(PM)->add(createLoopUnrollPass());
213 void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM) {
214 unwrap(PM)->add(createLoopUnrollAndJamPass());
217 void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) {
218 unwrap(PM)->add(createLoopUnswitchPass());
221 void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM) {
222 unwrap(PM)->add(createLowerAtomicPass());
225 void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) {
226 unwrap(PM)->add(createMemCpyOptPass());
229 void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM) {
230 unwrap(PM)->add(createPartiallyInlineLibCallsPass());
233 void LLVMAddReassociatePass(LLVMPassManagerRef PM) {
234 unwrap(PM)->add(createReassociatePass());
237 void LLVMAddSCCPPass(LLVMPassManagerRef PM) {
238 unwrap(PM)->add(createSCCPPass());
241 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) {
242 unwrap(PM)->add(createSROAPass());
245 void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) {
246 unwrap(PM)->add(createSROAPass());
249 void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
250 int Threshold) {
251 unwrap(PM)->add(createSROAPass());
254 void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) {
255 // NOTE: The simplify-libcalls pass has been removed.
258 void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) {
259 unwrap(PM)->add(createTailCallEliminationPass());
262 void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
263 unwrap(PM)->add(createDemoteRegisterToMemoryPass());
266 void LLVMAddVerifierPass(LLVMPassManagerRef PM) {
267 unwrap(PM)->add(createVerifierPass());
270 void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) {
271 unwrap(PM)->add(createCorrelatedValuePropagationPass());
274 void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) {
275 unwrap(PM)->add(createEarlyCSEPass(false/*=UseMemorySSA*/));
278 void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM) {
279 unwrap(PM)->add(createEarlyCSEPass(true/*=UseMemorySSA*/));
282 void LLVMAddGVNHoistLegacyPass(LLVMPassManagerRef PM) {
283 unwrap(PM)->add(createGVNHoistPass());
286 void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) {
287 unwrap(PM)->add(createTypeBasedAAWrapperPass());
290 void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM) {
291 unwrap(PM)->add(createScopedNoAliasAAWrapperPass());
294 void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) {
295 unwrap(PM)->add(createBasicAAWrapperPass());
298 void LLVMAddLowerConstantIntrinsicsPass(LLVMPassManagerRef PM) {
299 unwrap(PM)->add(createLowerConstantIntrinsicsPass());
302 void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) {
303 unwrap(PM)->add(createLowerExpectIntrinsicPass());
306 void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM) {
307 unwrap(PM)->add(createUnifyFunctionExitNodesPass());