mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Add an extension point for peephole optimizers.
This extension point allows adding passes that perform peephole optimizations similar to the instruction combiner. These passes will be inserted after each instance of the instruction combiner pass. Differential Revision: http://reviews.llvm.org/D3905 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -86,7 +86,12 @@ public:
|
|||||||
/// EP_EnabledOnOptLevel0 - This extension point allows adding passes that
|
/// EP_EnabledOnOptLevel0 - This extension point allows adding passes that
|
||||||
/// should not be disabled by O0 optimization level. The passes will be
|
/// should not be disabled by O0 optimization level. The passes will be
|
||||||
/// inserted after the inlining pass.
|
/// inserted after the inlining pass.
|
||||||
EP_EnabledOnOptLevel0
|
EP_EnabledOnOptLevel0,
|
||||||
|
|
||||||
|
/// EP_Peephole - This extension point allows adding passes that perform
|
||||||
|
/// peephole optimizations similar to the instruction combiner. These passes
|
||||||
|
/// will be inserted after each instance of the instruction combiner pass.
|
||||||
|
EP_Peephole,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The Optimization Level - Specify the basic optimization level.
|
/// The Optimization Level - Specify the basic optimization level.
|
||||||
|
@@ -157,6 +157,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
|
MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
|
||||||
|
|
||||||
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +184,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
|
MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
|
||||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||||
MPM.add(createInstructionCombiningPass()); // Combine silly seq's
|
MPM.add(createInstructionCombiningPass()); // Combine silly seq's
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
|
|
||||||
if (!DisableTailCalls)
|
if (!DisableTailCalls)
|
||||||
MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
|
MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
|
||||||
@@ -208,6 +210,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
// Run instcombine after redundancy elimination to exploit opportunities
|
// Run instcombine after redundancy elimination to exploit opportunities
|
||||||
// opened up by them.
|
// opened up by them.
|
||||||
MPM.add(createInstructionCombiningPass());
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
MPM.add(createJumpThreadingPass()); // Thread jumps
|
MPM.add(createJumpThreadingPass()); // Thread jumps
|
||||||
MPM.add(createCorrelatedValuePropagationPass());
|
MPM.add(createCorrelatedValuePropagationPass());
|
||||||
MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
|
MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
|
||||||
@@ -222,6 +225,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
if (BBVectorize) {
|
if (BBVectorize) {
|
||||||
MPM.add(createBBVectorizePass());
|
MPM.add(createBBVectorizePass());
|
||||||
MPM.add(createInstructionCombiningPass());
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
if (OptLevel > 1 && UseGVNAfterVectorization)
|
if (OptLevel > 1 && UseGVNAfterVectorization)
|
||||||
MPM.add(createGVNPass()); // Remove redundancies
|
MPM.add(createGVNPass()); // Remove redundancies
|
||||||
else
|
else
|
||||||
@@ -235,6 +239,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
|
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
|
||||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||||
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
|
|
||||||
// FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
|
// FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
|
||||||
// pass manager that we are specifically trying to avoid. To prevent this
|
// pass manager that we are specifically trying to avoid. To prevent this
|
||||||
@@ -247,6 +252,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
// as function calls, so that we can only pass them when the vectorizer
|
// as function calls, so that we can only pass them when the vectorizer
|
||||||
// changed the code.
|
// changed the code.
|
||||||
MPM.add(createInstructionCombiningPass());
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
MPM.add(createCFGSimplificationPass());
|
MPM.add(createCFGSimplificationPass());
|
||||||
|
|
||||||
if (!DisableUnrollLoops)
|
if (!DisableUnrollLoops)
|
||||||
@@ -299,6 +305,7 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
|
|||||||
// function pointers. When this happens, we often have to resolve varargs
|
// function pointers. When this happens, we often have to resolve varargs
|
||||||
// calls, etc, so let instcombine do this.
|
// calls, etc, so let instcombine do this.
|
||||||
PM.add(createInstructionCombiningPass());
|
PM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, PM);
|
||||||
|
|
||||||
// Inline small functions
|
// Inline small functions
|
||||||
if (RunInliner)
|
if (RunInliner)
|
||||||
@@ -317,6 +324,7 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
|
|||||||
|
|
||||||
// The IPO passes may leave cruft around. Clean up after them.
|
// The IPO passes may leave cruft around. Clean up after them.
|
||||||
PM.add(createInstructionCombiningPass());
|
PM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, PM);
|
||||||
PM.add(createJumpThreadingPass());
|
PM.add(createJumpThreadingPass());
|
||||||
|
|
||||||
// Break up allocas
|
// Break up allocas
|
||||||
@@ -346,6 +354,7 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
|
|||||||
|
|
||||||
// Cleanup and simplify the code after the scalar optimizations.
|
// Cleanup and simplify the code after the scalar optimizations.
|
||||||
PM.add(createInstructionCombiningPass());
|
PM.add(createInstructionCombiningPass());
|
||||||
|
addExtensionsToPM(EP_Peephole, PM);
|
||||||
|
|
||||||
PM.add(createJumpThreadingPass());
|
PM.add(createJumpThreadingPass());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user