mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
Add TargetMachine::addEarlyAsPossiblePasses, and call it from opt.
Summary: This is a hook to allow TargetMachine to install passes at the EP_EarlyAsPossible PassManagerBuilder extension point. Reviewers: chandlerc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18614 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267763 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a1d8280553
commit
ae889d3672
@ -217,6 +217,11 @@ public:
|
||||
/// uses this to answer queries about the IR.
|
||||
virtual TargetIRAnalysis getTargetIRAnalysis();
|
||||
|
||||
/// Add target-specific function passes that should be run as early as
|
||||
/// possible in the optimization pipeline. Most TargetMachines have no such
|
||||
/// passes.
|
||||
virtual void addEarlyAsPossiblePasses(PassManagerBase &) {}
|
||||
|
||||
/// These enums are meant to be passed into addPassesToEmitFile to indicate
|
||||
/// what type of file to emit, and returned by it to indicate what type of
|
||||
/// file could actually be made.
|
||||
|
@ -230,7 +230,8 @@ static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
|
||||
/// OptLevel - Optimization Level
|
||||
static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
|
||||
legacy::FunctionPassManager &FPM,
|
||||
unsigned OptLevel, unsigned SizeLevel) {
|
||||
TargetMachine *TM, unsigned OptLevel,
|
||||
unsigned SizeLevel) {
|
||||
if (!NoVerify || VerifyEach)
|
||||
FPM.add(createVerifierPass()); // Verify that input is correct
|
||||
|
||||
@ -260,6 +261,14 @@ static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
|
||||
Builder.SLPVectorize =
|
||||
DisableSLPVectorization ? false : OptLevel > 1 && SizeLevel < 2;
|
||||
|
||||
// Add target-specific passes that need to run as early as possible.
|
||||
if (TM)
|
||||
Builder.addExtension(
|
||||
PassManagerBuilder::EP_EarlyAsPossible,
|
||||
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
|
||||
TM->addEarlyAsPossiblePasses(PM);
|
||||
});
|
||||
|
||||
Builder.populateFunctionPassManager(FPM);
|
||||
Builder.populateModulePassManager(MPM);
|
||||
}
|
||||
@ -519,27 +528,27 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (OptLevelO1 && OptLevelO1.getPosition() < PassList.getPosition(i)) {
|
||||
AddOptimizationPasses(Passes, *FPasses, 1, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 1, 0);
|
||||
OptLevelO1 = false;
|
||||
}
|
||||
|
||||
if (OptLevelO2 && OptLevelO2.getPosition() < PassList.getPosition(i)) {
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 0);
|
||||
OptLevelO2 = false;
|
||||
}
|
||||
|
||||
if (OptLevelOs && OptLevelOs.getPosition() < PassList.getPosition(i)) {
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 1);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 1);
|
||||
OptLevelOs = false;
|
||||
}
|
||||
|
||||
if (OptLevelOz && OptLevelOz.getPosition() < PassList.getPosition(i)) {
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 2);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 2);
|
||||
OptLevelOz = false;
|
||||
}
|
||||
|
||||
if (OptLevelO3 && OptLevelO3.getPosition() < PassList.getPosition(i)) {
|
||||
AddOptimizationPasses(Passes, *FPasses, 3, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 3, 0);
|
||||
OptLevelO3 = false;
|
||||
}
|
||||
|
||||
@ -591,19 +600,19 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (OptLevelO1)
|
||||
AddOptimizationPasses(Passes, *FPasses, 1, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 1, 0);
|
||||
|
||||
if (OptLevelO2)
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 0);
|
||||
|
||||
if (OptLevelOs)
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 1);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 1);
|
||||
|
||||
if (OptLevelOz)
|
||||
AddOptimizationPasses(Passes, *FPasses, 2, 2);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 2, 2);
|
||||
|
||||
if (OptLevelO3)
|
||||
AddOptimizationPasses(Passes, *FPasses, 3, 0);
|
||||
AddOptimizationPasses(Passes, *FPasses, TM.get(), 3, 0);
|
||||
|
||||
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
|
||||
FPasses->doInitialization();
|
||||
|
Loading…
Reference in New Issue
Block a user