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