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