mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-12 02:47:10 +00:00
Add the ability for SCC passes to initialize and finalize themselves
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c99acc3709
commit
a10df50282
@ -26,9 +26,16 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class CallGraphNode;
|
class CallGraphNode;
|
||||||
|
class Module;
|
||||||
|
|
||||||
struct CallGraphSCCPass : public Pass {
|
struct CallGraphSCCPass : public Pass {
|
||||||
|
|
||||||
|
/// doInitialization - This method is called before the SCC's of the program
|
||||||
|
/// has been processed, allowing the pass to do initialization as necessary.
|
||||||
|
virtual bool doInitialization(Module &M) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// runOnSCC - This method should be implemented by the subclass to perform
|
/// runOnSCC - This method should be implemented by the subclass to perform
|
||||||
/// whatever action is necessary for the specified SCC. Note that
|
/// whatever action is necessary for the specified SCC. Note that
|
||||||
/// non-recursive (or only self-recursive) functions will have an SCC size of
|
/// non-recursive (or only self-recursive) functions will have an SCC size of
|
||||||
@ -36,6 +43,12 @@ struct CallGraphSCCPass : public Pass {
|
|||||||
///
|
///
|
||||||
virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0;
|
virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0;
|
||||||
|
|
||||||
|
/// doFinalization - This method is called after the SCC's of the program has
|
||||||
|
/// been processed, allowing the pass to do final cleanup as necessary.
|
||||||
|
virtual bool doFinalization(Module &M) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// run - Run this pass, returning true if a modification was made to the
|
/// run - Run this pass, returning true if a modification was made to the
|
||||||
/// module argument. This is implemented in terms of the runOnSCC method.
|
/// module argument. This is implemented in terms of the runOnSCC method.
|
||||||
///
|
///
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
#include "llvm/CallGraphSCCPass.h"
|
#include "llvm/CallGraphSCCPass.h"
|
||||||
#include "llvm/Analysis/CallGraph.h"
|
#include "llvm/Analysis/CallGraph.h"
|
||||||
#include "Support/SCCIterator.h"
|
#include "Support/SCCIterator.h"
|
||||||
|
using namespace llvm;
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
||||||
/// the call graph. If the derived class implements this method, it should
|
/// the call graph. If the derived class implements this method, it should
|
||||||
@ -31,11 +30,9 @@ void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
|
|
||||||
bool CallGraphSCCPass::run(Module &M) {
|
bool CallGraphSCCPass::run(Module &M) {
|
||||||
CallGraph &CG = getAnalysis<CallGraph>();
|
CallGraph &CG = getAnalysis<CallGraph>();
|
||||||
bool Changed = false;
|
bool Changed = doInitialization(M);
|
||||||
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
|
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
Changed = runOnSCC(*I);
|
Changed = runOnSCC(*I);
|
||||||
return Changed;
|
return Changed | doFinalization(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user