2012-10-16 10:21:30 +08:00
|
|
|
//===-- IPO.cpp -----------------------------------------------------------===//
|
2009-03-07 00:52:18 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2015-10-31 07:02:38 +08:00
|
|
|
// This file implements the common infrastructure (including C bindings) for
|
|
|
|
// libLLVMIPO.a, which implements several transformations over the LLVM
|
2010-10-08 02:09:59 +08:00
|
|
|
// intermediate representation.
|
2009-03-07 00:52:18 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-08-19 09:36:54 +08:00
|
|
|
#include "llvm-c/Initialization.h"
|
2009-03-07 00:52:18 +08:00
|
|
|
#include "llvm-c/Transforms/IPO.h"
|
2010-10-08 02:09:59 +08:00
|
|
|
#include "llvm/InitializePasses.h"
|
2015-02-13 18:01:29 +08:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2009-03-07 00:52:18 +08:00
|
|
|
#include "llvm/Transforms/IPO.h"
|
2016-02-18 19:03:11 +08:00
|
|
|
#include "llvm/Transforms/IPO/FunctionAttrs.h"
|
2009-03-07 00:52:18 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-10-08 02:09:59 +08:00
|
|
|
void llvm::initializeIPO(PassRegistry &Registry) {
|
|
|
|
initializeArgPromotionPass(Registry);
|
|
|
|
initializeConstantMergePass(Registry);
|
2015-12-16 07:00:08 +08:00
|
|
|
initializeCrossDSOCFIPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializeDAEPass(Registry);
|
|
|
|
initializeDAHPass(Registry);
|
2015-12-27 16:13:45 +08:00
|
|
|
initializeForceFunctionAttrsLegacyPassPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializeGlobalDCEPass(Registry);
|
|
|
|
initializeGlobalOptPass(Registry);
|
|
|
|
initializeIPCPPass(Registry);
|
|
|
|
initializeAlwaysInlinerPass(Registry);
|
|
|
|
initializeSimpleInlinerPass(Registry);
|
2015-12-27 16:41:34 +08:00
|
|
|
initializeInferFunctionAttrsLegacyPassPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializeInternalizePassPass(Registry);
|
|
|
|
initializeLoopExtractorPass(Registry);
|
|
|
|
initializeBlockExtractorPassPass(Registry);
|
|
|
|
initializeSingleLoopExtractorPass(Registry);
|
2015-02-21 04:30:47 +08:00
|
|
|
initializeLowerBitSetsPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializeMergeFunctionsPass(Registry);
|
|
|
|
initializePartialInlinerPass(Registry);
|
2016-02-18 19:03:11 +08:00
|
|
|
initializePostOrderFunctionAttrsLegacyPassPass(Registry);
|
2016-01-08 18:55:52 +08:00
|
|
|
initializeReversePostOrderFunctionAttrsPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializePruneEHPass(Registry);
|
2015-10-31 07:28:12 +08:00
|
|
|
initializeStripDeadPrototypesLegacyPassPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
initializeStripSymbolsPass(Registry);
|
|
|
|
initializeStripDebugDeclarePass(Registry);
|
|
|
|
initializeStripDeadDebugInfoPass(Registry);
|
|
|
|
initializeStripNonDebugSymbolsPass(Registry);
|
2013-12-13 04:45:08 +08:00
|
|
|
initializeBarrierNoopPass(Registry);
|
2015-07-13 22:18:22 +08:00
|
|
|
initializeEliminateAvailableExternallyPass(Registry);
|
2015-08-25 23:25:11 +08:00
|
|
|
initializeSampleProfileLoaderPass(Registry);
|
2015-11-24 14:07:49 +08:00
|
|
|
initializeFunctionImportPassPass(Registry);
|
2016-02-10 06:50:34 +08:00
|
|
|
initializeWholeProgramDevirtPass(Registry);
|
2010-10-08 02:09:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMInitializeIPO(LLVMPassRegistryRef R) {
|
|
|
|
initializeIPO(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2009-03-07 00:52:18 +08:00
|
|
|
void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createArgumentPromotionPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddConstantMergePass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createConstantMergePass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createDeadArgEliminationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) {
|
2016-02-18 19:03:11 +08:00
|
|
|
unwrap(PM)->add(createPostOrderFunctionAttrsLegacyPass());
|
2009-03-07 00:52:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createFunctionInliningPass());
|
|
|
|
}
|
|
|
|
|
2011-07-26 23:23:23 +08:00
|
|
|
void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(llvm::createAlwaysInlinerPass());
|
|
|
|
}
|
|
|
|
|
2009-03-07 00:52:18 +08:00
|
|
|
void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createGlobalDCEPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createGlobalOptimizerPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createIPConstantPropagationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddPruneEHPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createPruneEHPass());
|
|
|
|
}
|
|
|
|
|
2010-04-10 04:43:20 +08:00
|
|
|
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createIPSCCPPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
|
2012-10-27 02:47:48 +08:00
|
|
|
std::vector<const char *> Export;
|
|
|
|
if (AllButMain)
|
|
|
|
Export.push_back("main");
|
2013-11-01 04:51:58 +08:00
|
|
|
unwrap(PM)->add(createInternalizePass(Export));
|
2010-04-10 04:43:20 +08:00
|
|
|
}
|
|
|
|
|
2009-03-07 00:52:18 +08:00
|
|
|
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createStripDeadPrototypesPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createStripSymbolsPass());
|
|
|
|
}
|