2012-10-16 02:21:30 +00:00
|
|
|
//===-- IPO.cpp -----------------------------------------------------------===//
|
2009-03-06 16:52:18 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-10-07 18:09:59 +00:00
|
|
|
// This file implements the common infrastructure (including C bindings) for
|
|
|
|
// libLLVMIPO.a, which implements several transformations over the LLVM
|
|
|
|
// intermediate representation.
|
2009-03-06 16:52:18 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-08-19 01:36:54 +00:00
|
|
|
#include "llvm-c/Initialization.h"
|
2009-03-06 16:52:18 +00:00
|
|
|
#include "llvm-c/Transforms/IPO.h"
|
2010-10-07 18:09:59 +00:00
|
|
|
#include "llvm/InitializePasses.h"
|
2015-02-13 10:01:29 +00:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2009-03-06 16:52:18 +00:00
|
|
|
#include "llvm/Transforms/IPO.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-10-07 18:09:59 +00: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);
|
2015-02-20 20:30:47 +00:00
|
|
|
initializeLowerBitSetsPass(Registry);
|
2010-10-07 18:09:59 +00:00
|
|
|
initializeMergeFunctionsPass(Registry);
|
|
|
|
initializePartialInlinerPass(Registry);
|
|
|
|
initializePruneEHPass(Registry);
|
|
|
|
initializeStripDeadPrototypesPassPass(Registry);
|
|
|
|
initializeStripSymbolsPass(Registry);
|
|
|
|
initializeStripDebugDeclarePass(Registry);
|
|
|
|
initializeStripDeadDebugInfoPass(Registry);
|
|
|
|
initializeStripNonDebugSymbolsPass(Registry);
|
2013-12-12 20:45:08 +00:00
|
|
|
initializeBarrierNoopPass(Registry);
|
2010-10-07 18:09:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMInitializeIPO(LLVMPassRegistryRef R) {
|
|
|
|
initializeIPO(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00: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 15:23:23 +00:00
|
|
|
void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(llvm::createAlwaysInlinerPass());
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00: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-09 20:43:20 +00:00
|
|
|
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createIPSCCPPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
|
2012-10-26 18:47:48 +00:00
|
|
|
std::vector<const char *> Export;
|
|
|
|
if (AllButMain)
|
|
|
|
Export.push_back("main");
|
2013-10-31 20:51:58 +00:00
|
|
|
unwrap(PM)->add(createInternalizePass(Export));
|
2010-04-09 20:43:20 +00:00
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createStripDeadPrototypesPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createStripSymbolsPass());
|
|
|
|
}
|