4 #include "analysisCommon.h"
6 #include "functionState.h"
10 #include <boost/shared_ptr.hpp>
39 std::vector<Lattice*>& initLattices, std::vector<NodeFact*>& initFacts)=0;
45 std::set<Function> visited;
51 { this->interAnalysis = intraDFAnalysis->interAnalysis; }
61 virtual bool runAnalysis(
const Function& func,
NodeState* state,
bool analyzeDueToCallers, std::set<Function> calleesUpdated)=0;
69 bool analyzeDueToCallers =
true;
72 std::set<Function> calleesUpdated;
74 return runAnalysis(func, state, analyzeDueToCallers, calleesUpdated);
91 const std::vector<Lattice*> &dfInfo;
96 : func(f), dfNode(n), nodeState(s), dfInfo(d)
99 virtual bool finish() = 0;
127 void visit(
SgNode *n) { modified = analysis->transfer(func, dfNode, nodeState, dfInfo); }
128 bool finish() {
return modified; }
146 virtual boost::shared_ptr<IntraDFTransferVisitor> getTransferVisitor(
const Function& func,
const DataflowNode& n,
147 NodeState& state,
const std::vector<Lattice*>& dfInfo)
148 {
return boost::shared_ptr<IntraDFTransferVisitor>(
new DefaultTransfer(func, n, state, dfInfo,
this)); }
168 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw)=0;
179 this->dfAnalysis = dfAnalysis;
180 this->filter = dfAnalysis->filter;
191 const std::set<Function>& funcsToFind;
194 std::map<Function, std::set<DataflowNode> > funcCalls;
203 std::map<Function, std::set<DataflowNode> >& getFuncCalls() {
return funcCalls; }
214 bool runAnalysis(
const Function& func,
NodeState* state,
bool analyzeDueToCallers, std::set<Function> calleesUpdated);
219 bool propagateStateToNextNode(
220 const std::vector<Lattice*>& curNodeState,
DataflowNode curDFNode,
int nodeIndex,
221 const std::vector<Lattice*>& nextNodeState,
DataflowNode nextDFNode);
223 std::vector<DataflowNode> gatherDescendants(std::vector<DataflowEdge> edges,
228 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState) = 0;
229 virtual vector<Lattice*> getLatticeAnte(
NodeState *state) = 0;
230 virtual vector<Lattice*> getLatticePost(
NodeState *state) = 0;
237 virtual vector<DataflowNode> getDescendants(
const DataflowNode &n) = 0;
251 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState);
252 vector<Lattice*> getLatticeAnte(
NodeState *state);
253 vector<Lattice*> getLatticePost(
NodeState *state);
255 vector<DataflowNode> getDescendants(
const DataflowNode &n);
269 getInitialWorklist(
const Function &func,
bool firstVisit,
bool analyzeDueToCallers,
const set<Function> &calleesUpdated,
NodeState *fState);
270 virtual vector<Lattice*> getLatticeAnte(
NodeState *state);
271 virtual vector<Lattice*> getLatticePost(
NodeState *state);
273 vector<DataflowNode> getDescendants(
const DataflowNode &n);
336 this->analysis = analysis;
342 std::vector<Lattice*>& initLattices, std::vector<NodeFact*>& initFacts);
374 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw)
392 std::vector<Lattice*> mergedLatsRetStmt;
393 std::vector<Lattice*> mergedLatsRetVal;
408 MergeAllReturnStates(
Analysis* analysis,
const std::vector<Lattice*>& mergedLatsRetStmt,
const std::vector<Lattice*>& mergedLatsRetVal):
409 analysis(analysis), mergedLatsRetStmt(mergedLatsRetStmt), mergedLatsRetVal(mergedLatsRetVal)
416 static bool mergeLats(std::vector<Lattice*>& mergedLat,
const std::vector<Lattice*>& lats);
419 std::vector<Lattice*>& getMergedLatsRetStmt() {
return mergedLatsRetStmt; }
422 std::vector<Lattice*>& getMergedLatsRetVal() {
return mergedLatsRetVal; }
425 bool getModified() {
return modified; }
437 std::vector<Lattice*>& latsAtFuncReturn;
439 std::vector<Lattice*>& latsRetVal;
444 DFStateAtReturns(std::vector<Lattice*>& latsAtFuncReturn, std::vector<Lattice*>& latsRetVal);
455 std::vector<Lattice*>& getLatsAtFuncReturn() {
return latsAtFuncReturn; }
458 std::vector<Lattice*>& getLatsRetVal() {
return latsRetVal; }
460 std::string str(std::string indent);
472 std::set<Function> remainingDueToCallers;
478 std::map<Function, std::set<Function> > remainingDueToCalls;
497 const std::vector<Lattice*>& dfInfo, std::vector<Lattice*>** retState,
bool fw);
Apply an analysis A's transfer function at a particular AST node type.
This class represents the base class for all IR nodes within Sage III.