Add control of function merging to the PMBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2014-09-13 21:46:00 +00:00
parent 75d7f73678
commit c2104d4856
2 changed files with 11 additions and 0 deletions

View File

@ -123,6 +123,7 @@ public:
bool VerifyInput;
bool VerifyOutput;
bool StripDebug;
bool MergeFunctions;
private:
/// ExtensionList - This is list of all of the extensions that are registered.

View File

@ -91,6 +91,7 @@ PassManagerBuilder::PassManagerBuilder() {
VerifyInput = false;
VerifyOutput = false;
StripDebug = false;
MergeFunctions = false;
}
PassManagerBuilder::~PassManagerBuilder() {
@ -330,6 +331,10 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
MPM.add(createConstantMergePass()); // Merge dup global constants
}
}
if (MergeFunctions)
MPM.add(createMergeFunctionsPass());
addExtensionsToPM(EP_OptimizerLast, MPM);
}
@ -427,6 +432,11 @@ void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
// Now that we have optimized the program, discard unreachable functions.
PM.add(createGlobalDCEPass());
// FIXME: this is profitable (for compiler time) to do at -O0 too, but
// currently it damages debug info.
if (MergeFunctions)
PM.add(createMergeFunctionsPass());
}
void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,