• 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 }
48 
LLVMInitializeIPO(LLVMPassRegistryRef R)49 void LLVMInitializeIPO(LLVMPassRegistryRef R) {
50   initializeIPO(*unwrap(R));
51 }
52 
LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM)53 void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) {
54   unwrap(PM)->add(createArgumentPromotionPass());
55 }
56 
LLVMAddConstantMergePass(LLVMPassManagerRef PM)57 void LLVMAddConstantMergePass(LLVMPassManagerRef PM) {
58   unwrap(PM)->add(createConstantMergePass());
59 }
60 
LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM)61 void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) {
62   unwrap(PM)->add(createDeadArgEliminationPass());
63 }
64 
LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM)65 void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) {
66   unwrap(PM)->add(createFunctionAttrsPass());
67 }
68 
LLVMAddFunctionInliningPass(LLVMPassManagerRef PM)69 void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) {
70   unwrap(PM)->add(createFunctionInliningPass());
71 }
72 
LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM)73 void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) {
74   unwrap(PM)->add(llvm::createAlwaysInlinerPass());
75 }
76 
LLVMAddGlobalDCEPass(LLVMPassManagerRef PM)77 void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
78   unwrap(PM)->add(createGlobalDCEPass());
79 }
80 
LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM)81 void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
82   unwrap(PM)->add(createGlobalOptimizerPass());
83 }
84 
LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM)85 void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) {
86   unwrap(PM)->add(createIPConstantPropagationPass());
87 }
88 
LLVMAddPruneEHPass(LLVMPassManagerRef PM)89 void LLVMAddPruneEHPass(LLVMPassManagerRef PM) {
90   unwrap(PM)->add(createPruneEHPass());
91 }
92 
LLVMAddIPSCCPPass(LLVMPassManagerRef PM)93 void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
94   unwrap(PM)->add(createIPSCCPPass());
95 }
96 
LLVMAddInternalizePass(LLVMPassManagerRef PM,unsigned AllButMain)97 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
98   std::vector<const char *> Export;
99   if (AllButMain)
100     Export.push_back("main");
101   unwrap(PM)->add(createInternalizePass(Export));
102 }
103 
LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM)104 void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
105   unwrap(PM)->add(createStripDeadPrototypesPass());
106 }
107 
LLVMAddStripSymbolsPass(LLVMPassManagerRef PM)108 void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
109   unwrap(PM)->add(createStripSymbolsPass());
110 }
111