mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
switch opt to using PassManagerBuilder.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/PluginLoader.h"
|
#include "llvm/Support/PluginLoader.h"
|
||||||
#include "llvm/Support/PrettyStackTrace.h"
|
#include "llvm/Support/PrettyStackTrace.h"
|
||||||
#include "llvm/Support/StandardPasses.h"
|
#include "llvm/Support/PassManagerBuilder.h"
|
||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
#include "llvm/Support/ToolOutputFile.h"
|
#include "llvm/Support/ToolOutputFile.h"
|
||||||
#include "llvm/LinkAllPasses.h"
|
#include "llvm/LinkAllPasses.h"
|
||||||
@@ -387,10 +387,12 @@ struct BreakpointPrinter : public ModulePass {
|
|||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
char BreakpointPrinter::ID = 0;
|
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...
|
// Add the pass to the pass manager...
|
||||||
PM.add(P);
|
PM.add(P);
|
||||||
|
|
||||||
@@ -403,31 +405,30 @@ inline void addPass(PassManagerBase &PM, Pass *P) {
|
|||||||
/// duplicates llvm-gcc behaviour.
|
/// duplicates llvm-gcc behaviour.
|
||||||
///
|
///
|
||||||
/// OptLevel - Optimization Level
|
/// OptLevel - Optimization Level
|
||||||
void AddOptimizationPasses(PassManagerBase &MPM, PassManagerBase &FPM,
|
static void AddOptimizationPasses(PassManagerBase &MPM,FunctionPassManager &FPM,
|
||||||
unsigned OptLevel) {
|
unsigned OptLevel) {
|
||||||
createStandardFunctionPasses(&FPM, OptLevel);
|
PassManagerBuilder Builder;
|
||||||
|
Builder.OptLevel = OptLevel;
|
||||||
|
|
||||||
llvm::Pass *InliningPass = 0;
|
|
||||||
if (DisableInline) {
|
if (DisableInline) {
|
||||||
// No inlining pass
|
// No inlining pass
|
||||||
} else if (OptLevel) {
|
} else if (OptLevel) {
|
||||||
unsigned Threshold = 225;
|
unsigned Threshold = 225;
|
||||||
if (OptLevel > 2)
|
if (OptLevel > 2)
|
||||||
Threshold = 275;
|
Threshold = 275;
|
||||||
InliningPass = createFunctionInliningPass(Threshold);
|
Builder.Inliner = createFunctionInliningPass(Threshold);
|
||||||
} else {
|
} else {
|
||||||
InliningPass = createAlwaysInlinerPass();
|
Builder.Inliner = createAlwaysInlinerPass();
|
||||||
}
|
}
|
||||||
createStandardModulePasses(&MPM, OptLevel,
|
Builder.DisableUnitAtATime = !UnitAtATime;
|
||||||
/*OptimizeSize=*/ false,
|
Builder.DisableUnrollLoops = OptLevel == 0;
|
||||||
UnitAtATime,
|
Builder.DisableSimplifyLibCalls = DisableSimplifyLibCalls;
|
||||||
/*UnrollLoops=*/ OptLevel > 1,
|
|
||||||
!DisableSimplifyLibCalls,
|
Builder.populateFunctionPassManager(FPM);
|
||||||
/*HaveExceptions=*/ true,
|
Builder.populateModulePassManager(MPM);
|
||||||
InliningPass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddStandardCompilePasses(PassManagerBase &PM) {
|
static void AddStandardCompilePasses(PassManagerBase &PM) {
|
||||||
PM.add(createVerifierPass()); // Verify that input is correct
|
PM.add(createVerifierPass()); // Verify that input is correct
|
||||||
|
|
||||||
addPass(PM, createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp
|
addPass(PM, createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp
|
||||||
@@ -438,19 +439,16 @@ void AddStandardCompilePasses(PassManagerBase &PM) {
|
|||||||
|
|
||||||
if (DisableOptimizations) return;
|
if (DisableOptimizations) return;
|
||||||
|
|
||||||
llvm::Pass *InliningPass = !DisableInline ? createFunctionInliningPass() : 0;
|
|
||||||
|
|
||||||
// -std-compile-opts adds the same module passes as -O3.
|
// -std-compile-opts adds the same module passes as -O3.
|
||||||
createStandardModulePasses(&PM, 3,
|
PassManagerBuilder Builder;
|
||||||
/*OptimizeSize=*/ false,
|
if (!DisableInline)
|
||||||
/*UnitAtATime=*/ true,
|
Builder.Inliner = createFunctionInliningPass();
|
||||||
/*UnrollLoops=*/ true,
|
Builder.OptLevel = 3;
|
||||||
!DisableSimplifyLibCalls,
|
Builder.DisableSimplifyLibCalls = DisableSimplifyLibCalls;
|
||||||
/*HaveExceptions=*/ true,
|
Builder.populateModulePassManager(PM);
|
||||||
InliningPass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddStandardLinkPasses(PassManagerBase &PM) {
|
static void AddStandardLinkPasses(PassManagerBase &PM) {
|
||||||
PM.add(createVerifierPass()); // Verify that input is correct
|
PM.add(createVerifierPass()); // Verify that input is correct
|
||||||
|
|
||||||
// If the -strip-debug command line option was specified, do it.
|
// If the -strip-debug command line option was specified, do it.
|
||||||
@@ -459,13 +457,11 @@ void AddStandardLinkPasses(PassManagerBase &PM) {
|
|||||||
|
|
||||||
if (DisableOptimizations) return;
|
if (DisableOptimizations) return;
|
||||||
|
|
||||||
createStandardLTOPasses(&PM, /*Internalize=*/ !DisableInternalize,
|
PassManagerBuilder Builder;
|
||||||
/*RunInliner=*/ !DisableInline,
|
Builder.populateLTOPassManager(PM, /*Internalize=*/ !DisableInternalize,
|
||||||
/*VerifyEach=*/ VerifyEach);
|
/*RunInliner=*/ !DisableInline);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// main for opt
|
// main for opt
|
||||||
@@ -566,9 +562,9 @@ int main(int argc, char **argv) {
|
|||||||
if (TD)
|
if (TD)
|
||||||
Passes.add(TD);
|
Passes.add(TD);
|
||||||
|
|
||||||
OwningPtr<PassManager> FPasses;
|
OwningPtr<FunctionPassManager> FPasses;
|
||||||
if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
|
if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
|
||||||
FPasses.reset(new PassManager());
|
FPasses.reset(new FunctionPassManager(M.get()));
|
||||||
if (TD)
|
if (TD)
|
||||||
FPasses->add(new TargetData(*TD));
|
FPasses->add(new TargetData(*TD));
|
||||||
}
|
}
|
||||||
@@ -687,7 +683,8 @@ int main(int argc, char **argv) {
|
|||||||
AddOptimizationPasses(Passes, *FPasses, 3);
|
AddOptimizationPasses(Passes, *FPasses, 3);
|
||||||
|
|
||||||
if (OptLevelO1 || OptLevelO2 || OptLevelO3)
|
if (OptLevelO1 || OptLevelO2 || OptLevelO3)
|
||||||
FPasses->run(*M.get());
|
for (Module::iterator F = M->begin(), E = M->end(); F != E; ++F)
|
||||||
|
FPasses->run(*F);
|
||||||
|
|
||||||
// Check that the module is well formed on completion of optimization
|
// Check that the module is well formed on completion of optimization
|
||||||
if (!NoVerify && !VerifyEach)
|
if (!NoVerify && !VerifyEach)
|
||||||
|
|||||||
Reference in New Issue
Block a user