LLVM  6.0.0svn
IPO.cpp
Go to the documentation of this file.
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/Transforms/IPO.h"
17 #include "llvm-c/Initialization.h"
19 #include "llvm/InitializePasses.h"
20 #include "llvm/Transforms/IPO.h"
23 
24 using namespace llvm;
25 
29  initializeCrossDSOCFIPass(Registry);
30  initializeDAEPass(Registry);
31  initializeDAHPass(Registry);
35  initializeGlobalSplitPass(Registry);
36  initializeIPCPPass(Registry);
49  initializePruneEHPass(Registry);
55  initializeBarrierNoopPass(Registry);
60 }
61 
63  initializeIPO(*unwrap(R));
64 }
65 
68 }
69 
71  unwrap(PM)->add(createConstantMergePass());
72 }
73 
76 }
77 
80 }
81 
84 }
85 
88 }
89 
91  unwrap(PM)->add(createGlobalDCEPass());
92 }
93 
96 }
97 
100 }
101 
103  unwrap(PM)->add(createPruneEHPass());
104 }
105 
107  unwrap(PM)->add(createIPSCCPPass());
108 }
109 
110 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
111  auto PreserveMain = [=](const GlobalValue &GV) {
112  return AllButMain && GV.getName() == "main";
113  };
114  unwrap(PM)->add(createInternalizePass(PreserveMain));
115 }
116 
119 }
120 
122  unwrap(PM)->add(createStripSymbolsPass());
123 }
void initializeIPCPPass(PassRegistry &)
ModulePass * createIPConstantPropagationPass()
createIPConstantPropagationPass - This pass propagates constants from call sites into the bodies of f...
void initializeGlobalOptLegacyPassPass(PassRegistry &)
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
void initializeInternalizeLegacyPassPass(PassRegistry &)
void initializeLoopExtractorPass(PassRegistry &)
void initializeStripDeadDebugInfoPass(PassRegistry &)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
void initializePartialInlinerLegacyPassPass(PassRegistry &)
void initializeSimpleInlinerPass(PassRegistry &)
void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM)
See llvm::createGlobalDCEPass function.
Definition: IPO.cpp:90
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
void initializeWholeProgramDevirtPass(PassRegistry &)
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:1949
void initializeGlobalSplitPass(PassRegistry &)
void initializeGlobalDCELegacyPassPass(PassRegistry &)
void LLVMAddPruneEHPass(LLVMPassManagerRef PM)
See llvm::createPruneEHPass function.
Definition: IPO.cpp:102
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:117
void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM)
See llvm::createAlwaysInlinerPass function.
Definition: IPO.cpp:86
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM)
See llvm::createIPSCCPPass function.
Definition: IPO.cpp:106
void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry &)
void initializeStripSymbolsPass(PassRegistry &)
void initializePruneEHPass(PassRegistry &)
void initializeLowerTypeTestsPass(PassRegistry &)
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
void LLVMAddConstantMergePass(LLVMPassManagerRef PM)
See llvm::createConstantMergePass function.
Definition: IPO.cpp:70
void initializeArgPromotionPass(PassRegistry &)
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
void initializeInferFunctionAttrsLegacyPassPass(PassRegistry &)
void initializeStripNonDebugSymbolsPass(PassRegistry &)
void initializeCrossDSOCFIPass(PassRegistry &)
void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM)
See llvm::createDeadArgEliminationPass function.
Definition: IPO.cpp:74
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
void initializeMergeFunctionsPass(PassRegistry &)
void initializeEliminateAvailableExternallyLegacyPassPass(PassRegistry &)
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
void initializeDAEPass(PassRegistry &)
void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain)
See llvm::createInternalizePass function.
Definition: IPO.cpp:110
void initializeFunctionImportLegacyPassPass(PassRegistry &)
Pass * createAlwaysInlinerLegacyPass(bool InsertLifetime=true)
Create a legacy pass manager instance of a pass to inline and remove functions marked as "always_inli...
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:2721
void initializeSampleProfileLoaderLegacyPassPass(PassRegistry &)
void initializeAlwaysInlinerLegacyPassPass(PassRegistry &)
Pass * createPostOrderFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to compute function attrs in post-order.
void initializeConstantMergeLegacyPassPass(PassRegistry &)
void initializeIPO(PassRegistry &)
Initialize all passes linked into the IPO library.
Definition: IPO.cpp:26
void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM)
See llvm::createIPConstantPropagationPass function.
Definition: IPO.cpp:98
void LLVMInitializeIPO(LLVMPassRegistryRef R)
Definition: IPO.cpp:62
Provides passes to inlining "always_inline" functions.
ModulePass * createInternalizePass(std::function< bool(const GlobalValue &)> MustPreserveGV)
createInternalizePass - This pass loops over all of the functions in the input module, internalizing all globals (functions and variables) it can.
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:114
void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM)
See llvm::createArgumentPromotionPass function.
Definition: IPO.cpp:66
void initializeSingleLoopExtractorPass(PassRegistry &)
void initializeDAHPass(PassRegistry &)
void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM)
See llvm::createFunctionInliningPass function.
Definition: IPO.cpp:82
void initializeBlockExtractorPassPass(PassRegistry &)
void initializePostOrderFunctionAttrsLegacyPassPass(PassRegistry &)
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM)
See llvm::createStripSymbolsPass function.
Definition: IPO.cpp:121
Provides passes for computing function attributes based on interprocedural analyses.
void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM)
See llvm::createGlobalOptimizerPass function.
Definition: IPO.cpp:94
void initializeForceFunctionAttrsLegacyPassPass(PassRegistry &)
void initializeStripDebugDeclarePass(PassRegistry &)
void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM)
See llvm::createFunctionAttrsPass function.
Definition: IPO.cpp:78
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls...
Definition: PruneEH.cpp:62
void initializeBarrierNoopPass(PassRegistry &)
ModulePass * createStripSymbolsPass(bool OnlyDebugInfo=false)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM)
See llvm::createStripDeadPrototypesPass function.
Definition: IPO.cpp:117
void initializeStripDeadPrototypesLegacyPassPass(PassRegistry &)