[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Transforms / IPO / IPO.cpp
blobde1c1d37950229140a053b315220d73d74623155
1 //===-- IPO.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 the common infrastructure (including C bindings) for
10 // libLLVMIPO.a, which implements several transformations over the LLVM
11 // intermediate representation.
13 //===----------------------------------------------------------------------===//
15 #include "llvm-c/Transforms/IPO.h"
16 #include "llvm-c/Initialization.h"
17 #include "llvm/IR/LegacyPassManager.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/Transforms/IPO.h"
20 #include "llvm/Transforms/IPO/AlwaysInliner.h"
21 #include "llvm/Transforms/IPO/FunctionAttrs.h"
23 using namespace llvm;
25 void llvm::initializeIPO(PassRegistry &Registry) {
26 initializeOpenMPOptCGSCCLegacyPassPass(Registry);
27 initializeArgPromotionPass(Registry);
28 initializeAnnotation2MetadataLegacyPass(Registry);
29 initializeCalledValuePropagationLegacyPassPass(Registry);
30 initializeConstantMergeLegacyPassPass(Registry);
31 initializeCrossDSOCFIPass(Registry);
32 initializeDAEPass(Registry);
33 initializeDAHPass(Registry);
34 initializeForceFunctionAttrsLegacyPassPass(Registry);
35 initializeFunctionSpecializationLegacyPassPass(Registry);
36 initializeGlobalDCELegacyPassPass(Registry);
37 initializeGlobalOptLegacyPassPass(Registry);
38 initializeGlobalSplitPass(Registry);
39 initializeHotColdSplittingLegacyPassPass(Registry);
40 initializeIROutlinerLegacyPassPass(Registry);
41 initializeAlwaysInlinerLegacyPassPass(Registry);
42 initializeSimpleInlinerPass(Registry);
43 initializeInferFunctionAttrsLegacyPassPass(Registry);
44 initializeInternalizeLegacyPassPass(Registry);
45 initializeLoopExtractorLegacyPassPass(Registry);
46 initializeBlockExtractorLegacyPassPass(Registry);
47 initializeSingleLoopExtractorPass(Registry);
48 initializeLowerTypeTestsPass(Registry);
49 initializeMergeFunctionsLegacyPassPass(Registry);
50 initializePartialInlinerLegacyPassPass(Registry);
51 initializeAttributorLegacyPassPass(Registry);
52 initializeAttributorCGSCCLegacyPassPass(Registry);
53 initializePostOrderFunctionAttrsLegacyPassPass(Registry);
54 initializeReversePostOrderFunctionAttrsLegacyPassPass(Registry);
55 initializePruneEHPass(Registry);
56 initializeIPSCCPLegacyPassPass(Registry);
57 initializeStripDeadPrototypesLegacyPassPass(Registry);
58 initializeStripSymbolsPass(Registry);
59 initializeStripDebugDeclarePass(Registry);
60 initializeStripDeadDebugInfoPass(Registry);
61 initializeStripNonDebugSymbolsPass(Registry);
62 initializeBarrierNoopPass(Registry);
63 initializeEliminateAvailableExternallyLegacyPassPass(Registry);
64 initializeSampleProfileLoaderLegacyPassPass(Registry);
65 initializeFunctionImportLegacyPassPass(Registry);
66 initializeWholeProgramDevirtPass(Registry);
69 void LLVMInitializeIPO(LLVMPassRegistryRef R) {
70 initializeIPO(*unwrap(R));
73 void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) {
74 unwrap(PM)->add(createArgumentPromotionPass());
77 void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM) {
78 unwrap(PM)->add(createCalledValuePropagationPass());
81 void LLVMAddConstantMergePass(LLVMPassManagerRef PM) {
82 unwrap(PM)->add(createConstantMergePass());
85 void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) {
86 unwrap(PM)->add(createDeadArgEliminationPass());
89 void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) {
90 unwrap(PM)->add(createPostOrderFunctionAttrsLegacyPass());
93 void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) {
94 unwrap(PM)->add(createFunctionInliningPass());
97 void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) {
98 unwrap(PM)->add(llvm::createAlwaysInlinerLegacyPass());
101 void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
102 unwrap(PM)->add(createGlobalDCEPass());
105 void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
106 unwrap(PM)->add(createGlobalOptimizerPass());
109 void LLVMAddPruneEHPass(LLVMPassManagerRef PM) {
110 unwrap(PM)->add(createPruneEHPass());
113 void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
114 unwrap(PM)->add(createIPSCCPPass());
117 void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM) {
118 unwrap(PM)->add(createMergeFunctionsPass());
121 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
122 auto PreserveMain = [=](const GlobalValue &GV) {
123 return AllButMain && GV.getName() == "main";
125 unwrap(PM)->add(createInternalizePass(PreserveMain));
128 void LLVMAddInternalizePassWithMustPreservePredicate(
129 LLVMPassManagerRef PM,
130 void *Context,
131 LLVMBool (*Pred)(LLVMValueRef, void *)) {
132 unwrap(PM)->add(createInternalizePass([=](const GlobalValue &GV) {
133 return Pred(wrap(&GV), Context) == 0 ? false : true;
134 }));
137 void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
138 unwrap(PM)->add(createStripDeadPrototypesPass());
141 void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
142 unwrap(PM)->add(createStripSymbolsPass());