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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-10-08 02:09:59 +08:00
|
|
|
// This file implements the common infrastructure (including C bindings) for
|
|
|
|
// libLLVMIPO.a, which implements several transformations over the LLVM
|
|
|
|
// 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"
|
2009-03-07 00:52:18 +08:00
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/Transforms/IPO.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-10-08 02:09:59 +08:00
|
|
|
void llvm::initializeIPO(PassRegistry &Registry) {
|
|
|
|
initializeArgPromotionPass(Registry);
|
|
|
|
initializeConstantMergePass(Registry);
|
|
|
|
initializeDAEPass(Registry);
|
|
|
|
initializeDAHPass(Registry);
|
|
|
|
initializeFunctionAttrsPass(Registry);
|
|
|
|
initializeGlobalDCEPass(Registry);
|
|
|
|
initializeGlobalOptPass(Registry);
|
|
|
|
initializeIPCPPass(Registry);
|
|
|
|
initializeAlwaysInlinerPass(Registry);
|
|
|
|
initializeSimpleInlinerPass(Registry);
|
|
|
|
initializeInternalizePassPass(Registry);
|
|
|
|
initializeLoopExtractorPass(Registry);
|
|
|
|
initializeBlockExtractorPassPass(Registry);
|
|
|
|
initializeSingleLoopExtractorPass(Registry);
|
|
|
|
initializeMergeFunctionsPass(Registry);
|
|
|
|
initializePartialInlinerPass(Registry);
|
|
|
|
initializePruneEHPass(Registry);
|
|
|
|
initializeStripDeadPrototypesPassPass(Registry);
|
|
|
|
initializeStripSymbolsPass(Registry);
|
|
|
|
initializeStripDebugDeclarePass(Registry);
|
|
|
|
initializeStripDeadDebugInfoPass(Registry);
|
|
|
|
initializeStripNonDebugSymbolsPass(Registry);
|
2013-12-13 04:45:08 +08:00
|
|
|
initializeBarrierNoopPass(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) {
|
|
|
|
unwrap(PM)->add(createFunctionAttrsPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|