aboutsummaryrefslogtreecommitdiff
path: root/tools/opt
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-06-12 15:42:51 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-06-12 15:42:51 +0000
commit56fe8f14099930935e3870e3e823c322a85c1c89 (patch)
treeb3032e51d630e8070e9e08d6641648f195316a80 /tools/opt
parent6b943ff3a3f8617113ecbf611cf0f8957e4e19d2 (diff)
downloadsrc-56fe8f14099930935e3870e3e823c322a85c1c89.tar.gz
src-56fe8f14099930935e3870e3e823c322a85c1c89.zip
Vendor import of llvm trunk r132879:vendor/llvm/llvm-r132879
Notes
Notes: svn path=/vendor/llvm/dist/; revision=223013 svn path=/vendor/llvm/llvm-r132879/; revision=223014; tag=vendor/llvm/llvm-r132879
Diffstat (limited to 'tools/opt')
-rw-r--r--tools/opt/opt.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 25474c44a6ef..aa375c588990 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -35,7 +35,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
-#include "llvm/Support/StandardPasses.h"
+#include "llvm/Support/PassManagerBuilder.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/LinkAllPasses.h"
@@ -387,10 +387,12 @@ struct BreakpointPrinter : public ModulePass {
AU.setPreservesAll();
}
};
+
+} // anonymous namespace
char BreakpointPrinter::ID = 0;
-inline void addPass(PassManagerBase &PM, Pass *P) {
+static inline void addPass(PassManagerBase &PM, Pass *P) {
// Add the pass to the pass manager...
PM.add(P);
@@ -403,31 +405,30 @@ inline void addPass(PassManagerBase &PM, Pass *P) {
/// duplicates llvm-gcc behaviour.
///
/// OptLevel - Optimization Level
-void AddOptimizationPasses(PassManagerBase &MPM, PassManagerBase &FPM,
- unsigned OptLevel) {
- createStandardFunctionPasses(&FPM, OptLevel);
+static void AddOptimizationPasses(PassManagerBase &MPM,FunctionPassManager &FPM,
+ unsigned OptLevel) {
+ PassManagerBuilder Builder;
+ Builder.OptLevel = OptLevel;
- llvm::Pass *InliningPass = 0;
if (DisableInline) {
// No inlining pass
- } else if (OptLevel) {
+ } else if (OptLevel > 1) {
unsigned Threshold = 225;
if (OptLevel > 2)
Threshold = 275;
- InliningPass = createFunctionInliningPass(Threshold);
+ Builder.Inliner = createFunctionInliningPass(Threshold);
} else {
- InliningPass = createAlwaysInlinerPass();
+ Builder.Inliner = createAlwaysInlinerPass();
}
- createStandardModulePasses(&MPM, OptLevel,
- /*OptimizeSize=*/ false,
- UnitAtATime,
- /*UnrollLoops=*/ OptLevel > 1,
- !DisableSimplifyLibCalls,
- /*HaveExceptions=*/ true,
- InliningPass);
+ Builder.DisableUnitAtATime = !UnitAtATime;
+ Builder.DisableUnrollLoops = OptLevel == 0;
+ Builder.DisableSimplifyLibCalls = DisableSimplifyLibCalls;
+
+ Builder.populateFunctionPassManager(FPM);
+ Builder.populateModulePassManager(MPM);
}
-void AddStandardCompilePasses(PassManagerBase &PM) {
+static void AddStandardCompilePasses(PassManagerBase &PM) {
PM.add(createVerifierPass()); // Verify that input is correct
addPass(PM, createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp
@@ -438,19 +439,16 @@ void AddStandardCompilePasses(PassManagerBase &PM) {
if (DisableOptimizations) return;
- llvm::Pass *InliningPass = !DisableInline ? createFunctionInliningPass() : 0;
-
// -std-compile-opts adds the same module passes as -O3.
- createStandardModulePasses(&PM, 3,
- /*OptimizeSize=*/ false,
- /*UnitAtATime=*/ true,
- /*UnrollLoops=*/ true,
- !DisableSimplifyLibCalls,
- /*HaveExceptions=*/ true,
- InliningPass);
+ PassManagerBuilder Builder;
+ if (!DisableInline)
+ Builder.Inliner = createFunctionInliningPass();
+ Builder.OptLevel = 3;
+ Builder.DisableSimplifyLibCalls = DisableSimplifyLibCalls;
+ Builder.populateModulePassManager(PM);
}
-void AddStandardLinkPasses(PassManagerBase &PM) {
+static void AddStandardLinkPasses(PassManagerBase &PM) {
PM.add(createVerifierPass()); // Verify that input is correct
// If the -strip-debug command line option was specified, do it.
@@ -459,13 +457,11 @@ void AddStandardLinkPasses(PassManagerBase &PM) {
if (DisableOptimizations) return;
- createStandardLTOPasses(&PM, /*Internalize=*/ !DisableInternalize,
- /*RunInliner=*/ !DisableInline,
- /*VerifyEach=*/ VerifyEach);
+ PassManagerBuilder Builder;
+ Builder.populateLTOPassManager(PM, /*Internalize=*/ !DisableInternalize,
+ /*RunInliner=*/ !DisableInline);
}
-} // anonymous namespace
-
//===----------------------------------------------------------------------===//
// main for opt
@@ -566,9 +562,9 @@ int main(int argc, char **argv) {
if (TD)
Passes.add(TD);
- OwningPtr<PassManager> FPasses;
+ OwningPtr<FunctionPassManager> FPasses;
if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
- FPasses.reset(new PassManager());
+ FPasses.reset(new FunctionPassManager(M.get()));
if (TD)
FPasses->add(new TargetData(*TD));
}
@@ -686,8 +682,12 @@ int main(int argc, char **argv) {
if (OptLevelO3)
AddOptimizationPasses(Passes, *FPasses, 3);
- if (OptLevelO1 || OptLevelO2 || OptLevelO3)
- FPasses->run(*M.get());
+ if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
+ FPasses->doInitialization();
+ for (Module::iterator F = M->begin(), E = M->end(); F != E; ++F)
+ FPasses->run(*F);
+ FPasses->doFinalization();
+ }
// Check that the module is well formed on completion of optimization
if (!NoVerify && !VerifyEach)