• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- IPO.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 the common infrastructure (including C bindings) for
11 // libLLVMIPO.a, which implements several transformations over the LLVM
12 // intermediate representation.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include "llvm-c/Initialization.h"
17 #include "llvm-c/Transforms/IPO.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/PassManager.h"
20 #include "llvm/Transforms/IPO.h"
21 
22 using namespace llvm;
23 
initializeIPO(PassRegistry & Registry)24 void llvm::initializeIPO(PassRegistry &Registry) {
25   initializeArgPromotionPass(Registry);
26   initializeConstantMergePass(Registry);
27   initializeDAEPass(Registry);
28   initializeDAHPass(Registry);
29   initializeFunctionAttrsPass(Registry);
30   initializeGlobalDCEPass(Registry);
31   initializeGlobalOptPass(Registry);
32   initializeIPCPPass(Registry);
33   initializeAlwaysInlinerPass(Registry);
34   initializeSimpleInlinerPass(Registry);
35   initializeInternalizePassPass(Registry);
36   initializeLoopExtractorPass(Registry);
37   initializeBlockExtractorPassPass(Registry);
38   initializeSingleLoopExtractorPass(Registry);
39   initializeMergeFunctionsPass(Registry);
40   initializePartialInlinerPass(Registry);
41   initializePruneEHPass(Registry);
42   initializeStripDeadPrototypesPassPass(Registry);
43   initializeStripSymbolsPass(Registry);
44   initializeStripDebugDeclarePass(Registry);
45   initializeStripDeadDebugInfoPass(Registry);
46   initializeStripNonDebugSymbolsPass(Registry);
47   initializeBarrierNoopPass(Registry);
48 }
49 
LLVMInitializeIPO(LLVMPassRegistryRef R)50 void LLVMInitializeIPO(LLVMPassRegistryRef R) {
51   initializeIPO(*unwrap(R));
52 }
53 
LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM)54 void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) {
55   unwrap(PM)->add(createArgumentPromotionPass());
56 }
57 
LLVMAddConstantMergePass(LLVMPassManagerRef PM)58 void LLVMAddConstantMergePass(LLVMPassManagerRef PM) {
59   unwrap(PM)->add(createConstantMergePass());
60 }
61 
LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM)62 void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) {
63   unwrap(PM)->add(createDeadArgEliminationPass());
64 }
65 
LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM)66 void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) {
67   unwrap(PM)->add(createFunctionAttrsPass());
68 }
69 
LLVMAddFunctionInliningPass(LLVMPassManagerRef PM)70 void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) {
71   unwrap(PM)->add(createFunctionInliningPass());
72 }
73 
LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM)74 void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) {
75   unwrap(PM)->add(llvm::createAlwaysInlinerPass());
76 }
77 
LLVMAddGlobalDCEPass(LLVMPassManagerRef PM)78 void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
79   unwrap(PM)->add(createGlobalDCEPass());
80 }
81 
LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM)82 void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
83   unwrap(PM)->add(createGlobalOptimizerPass());
84 }
85 
LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM)86 void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) {
87   unwrap(PM)->add(createIPConstantPropagationPass());
88 }
89 
LLVMAddPruneEHPass(LLVMPassManagerRef PM)90 void LLVMAddPruneEHPass(LLVMPassManagerRef PM) {
91   unwrap(PM)->add(createPruneEHPass());
92 }
93 
LLVMAddIPSCCPPass(LLVMPassManagerRef PM)94 void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
95   unwrap(PM)->add(createIPSCCPPass());
96 }
97 
LLVMAddInternalizePass(LLVMPassManagerRef PM,unsigned AllButMain)98 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
99   std::vector<const char *> Export;
100   if (AllButMain)
101     Export.push_back("main");
102   unwrap(PM)->add(createInternalizePass(Export));
103 }
104 
LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM)105 void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
106   unwrap(PM)->add(createStripDeadPrototypesPass());
107 }
108 
LLVMAddStripSymbolsPass(LLVMPassManagerRef PM)109 void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
110   unwrap(PM)->add(createStripSymbolsPass());
111 }
112