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 24 void llvm::initializeIPO(PassRegistry &Registry) { 25 initializeArgPromotionPass(Registry); 26 initializeConstantMergePass(Registry); 27 initializeCrossDSOCFIPass(Registry); 28 initializeDAEPass(Registry); 29 initializeDAHPass(Registry); 30 initializeFunctionAttrsPass(Registry); 31 initializeGlobalDCEPass(Registry); 32 initializeGlobalOptPass(Registry); 33 initializeIPCPPass(Registry); 34 initializeAlwaysInlinerPass(Registry); 35 initializeSimpleInlinerPass(Registry); 36 initializeInternalizePassPass(Registry); 37 initializeLoopExtractorPass(Registry); 38 initializeBlockExtractorPassPass(Registry); 39 initializeSingleLoopExtractorPass(Registry); 40 initializeLowerBitSetsPass(Registry); 41 initializeMergeFunctionsPass(Registry); 42 initializePartialInlinerPass(Registry); 43 initializePruneEHPass(Registry); 44 initializeStripDeadPrototypesLegacyPassPass(Registry); 45 initializeStripSymbolsPass(Registry); 46 initializeStripDebugDeclarePass(Registry); 47 initializeStripDeadDebugInfoPass(Registry); 48 initializeStripNonDebugSymbolsPass(Registry); 49 initializeBarrierNoopPass(Registry); 50 initializeEliminateAvailableExternallyPass(Registry); 51 initializeSampleProfileLoaderPass(Registry); 52 initializeFunctionImportPassPass(Registry); 53 } 54 55 void LLVMInitializeIPO(LLVMPassRegistryRef R) { 56 initializeIPO(*unwrap(R)); 57 } 58 59 void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) { 60 unwrap(PM)->add(createArgumentPromotionPass()); 61 } 62 63 void LLVMAddConstantMergePass(LLVMPassManagerRef PM) { 64 unwrap(PM)->add(createConstantMergePass()); 65 } 66 67 void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) { 68 unwrap(PM)->add(createDeadArgEliminationPass()); 69 } 70 71 void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) { 72 unwrap(PM)->add(createFunctionAttrsPass()); 73 } 74 75 void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) { 76 unwrap(PM)->add(createFunctionInliningPass()); 77 } 78 79 void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) { 80 unwrap(PM)->add(llvm::createAlwaysInlinerPass()); 81 } 82 83 void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) { 84 unwrap(PM)->add(createGlobalDCEPass()); 85 } 86 87 void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) { 88 unwrap(PM)->add(createGlobalOptimizerPass()); 89 } 90 91 void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) { 92 unwrap(PM)->add(createIPConstantPropagationPass()); 93 } 94 95 void LLVMAddPruneEHPass(LLVMPassManagerRef PM) { 96 unwrap(PM)->add(createPruneEHPass()); 97 } 98 99 void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) { 100 unwrap(PM)->add(createIPSCCPPass()); 101 } 102 103 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) { 104 std::vector<const char *> Export; 105 if (AllButMain) 106 Export.push_back("main"); 107 unwrap(PM)->add(createInternalizePass(Export)); 108 } 109 110 void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) { 111 unwrap(PM)->add(createStripDeadPrototypesPass()); 112 } 113 114 void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) { 115 unwrap(PM)->add(createStripSymbolsPass()); 116 } 117