Craig Topper | c74b600 | 2012-10-16 02:21:30 +0000 | [diff] [blame] | 1 | //===-- IPO.cpp -----------------------------------------------------------===// |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 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 | // |
Justin Bogner | 48f1f88 | 2015-10-30 23:02:38 +0000 | [diff] [blame] | 10 | // This file implements the common infrastructure (including C bindings) for |
| 11 | // libLLVMIPO.a, which implements several transformations over the LLVM |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 12 | // intermediate representation. |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Benjamin Kramer | 5a656883 | 2011-08-19 01:36:54 +0000 | [diff] [blame] | 16 | #include "llvm-c/Initialization.h" |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 17 | #include "llvm-c/Transforms/IPO.h" |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 18 | #include "llvm/InitializePasses.h" |
Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 19 | #include "llvm/IR/LegacyPassManager.h" |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 20 | #include "llvm/Transforms/IPO.h" |
| 21 | |
| 22 | using namespace llvm; |
| 23 | |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 24 | void llvm::initializeIPO(PassRegistry &Registry) { |
| 25 | initializeArgPromotionPass(Registry); |
| 26 | initializeConstantMergePass(Registry); |
Evgeniy Stepanov | 67849d5 | 2015-12-15 23:00:08 +0000 | [diff] [blame] | 27 | initializeCrossDSOCFIPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 28 | initializeDAEPass(Registry); |
| 29 | initializeDAHPass(Registry); |
Chandler Carruth | f49f1a87 | 2015-12-27 08:13:45 +0000 | [diff] [blame] | 30 | initializeForceFunctionAttrsLegacyPassPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 31 | initializeFunctionAttrsPass(Registry); |
| 32 | initializeGlobalDCEPass(Registry); |
| 33 | initializeGlobalOptPass(Registry); |
| 34 | initializeIPCPPass(Registry); |
| 35 | initializeAlwaysInlinerPass(Registry); |
| 36 | initializeSimpleInlinerPass(Registry); |
Chandler Carruth | 3a040e6 | 2015-12-27 08:41:34 +0000 | [diff] [blame^] | 37 | initializeInferFunctionAttrsLegacyPassPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 38 | initializeInternalizePassPass(Registry); |
| 39 | initializeLoopExtractorPass(Registry); |
| 40 | initializeBlockExtractorPassPass(Registry); |
| 41 | initializeSingleLoopExtractorPass(Registry); |
Peter Collingbourne | e6909c8 | 2015-02-20 20:30:47 +0000 | [diff] [blame] | 42 | initializeLowerBitSetsPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 43 | initializeMergeFunctionsPass(Registry); |
| 44 | initializePartialInlinerPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 45 | initializePruneEHPass(Registry); |
Justin Bogner | 21e1537 | 2015-10-30 23:28:12 +0000 | [diff] [blame] | 46 | initializeStripDeadPrototypesLegacyPassPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 47 | initializeStripSymbolsPass(Registry); |
| 48 | initializeStripDebugDeclarePass(Registry); |
| 49 | initializeStripDeadDebugInfoPass(Registry); |
| 50 | initializeStripNonDebugSymbolsPass(Registry); |
Hal Finkel | 26fc4c2 | 2013-12-12 20:45:08 +0000 | [diff] [blame] | 51 | initializeBarrierNoopPass(Registry); |
Rafael Espindola | 237c3a6 | 2015-07-13 14:18:22 +0000 | [diff] [blame] | 52 | initializeEliminateAvailableExternallyPass(Registry); |
Diego Novillo | 4d71113 | 2015-08-25 15:25:11 +0000 | [diff] [blame] | 53 | initializeSampleProfileLoaderPass(Registry); |
Mehdi Amini | 42418ab | 2015-11-24 06:07:49 +0000 | [diff] [blame] | 54 | initializeFunctionImportPassPass(Registry); |
Owen Anderson | bf70a03 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void LLVMInitializeIPO(LLVMPassRegistryRef R) { |
| 58 | initializeIPO(*unwrap(R)); |
| 59 | } |
| 60 | |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 61 | void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) { |
| 62 | unwrap(PM)->add(createArgumentPromotionPass()); |
| 63 | } |
| 64 | |
| 65 | void LLVMAddConstantMergePass(LLVMPassManagerRef PM) { |
| 66 | unwrap(PM)->add(createConstantMergePass()); |
| 67 | } |
| 68 | |
| 69 | void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) { |
| 70 | unwrap(PM)->add(createDeadArgEliminationPass()); |
| 71 | } |
| 72 | |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 73 | void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) { |
| 74 | unwrap(PM)->add(createFunctionAttrsPass()); |
| 75 | } |
| 76 | |
| 77 | void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) { |
| 78 | unwrap(PM)->add(createFunctionInliningPass()); |
| 79 | } |
| 80 | |
Rafael Espindola | b84dc6b | 2011-07-26 15:23:23 +0000 | [diff] [blame] | 81 | void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) { |
| 82 | unwrap(PM)->add(llvm::createAlwaysInlinerPass()); |
| 83 | } |
| 84 | |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 85 | void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) { |
| 86 | unwrap(PM)->add(createGlobalDCEPass()); |
| 87 | } |
| 88 | |
| 89 | void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) { |
| 90 | unwrap(PM)->add(createGlobalOptimizerPass()); |
| 91 | } |
| 92 | |
| 93 | void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) { |
| 94 | unwrap(PM)->add(createIPConstantPropagationPass()); |
| 95 | } |
| 96 | |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 97 | void LLVMAddPruneEHPass(LLVMPassManagerRef PM) { |
| 98 | unwrap(PM)->add(createPruneEHPass()); |
| 99 | } |
| 100 | |
Wesley Peck | a2ca3fa | 2010-04-09 20:43:20 +0000 | [diff] [blame] | 101 | void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) { |
| 102 | unwrap(PM)->add(createIPSCCPPass()); |
| 103 | } |
| 104 | |
| 105 | void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) { |
Rafael Espindola | 4253bd8 | 2012-10-26 18:47:48 +0000 | [diff] [blame] | 106 | std::vector<const char *> Export; |
| 107 | if (AllButMain) |
| 108 | Export.push_back("main"); |
Rafael Espindola | 282a470 | 2013-10-31 20:51:58 +0000 | [diff] [blame] | 109 | unwrap(PM)->add(createInternalizePass(Export)); |
Wesley Peck | a2ca3fa | 2010-04-09 20:43:20 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Chris Lattner | e48f897 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 112 | void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) { |
| 113 | unwrap(PM)->add(createStripDeadPrototypesPass()); |
| 114 | } |
| 115 | |
| 116 | void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) { |
| 117 | unwrap(PM)->add(createStripSymbolsPass()); |
| 118 | } |