//===--------------------------------------------------------------------===//
public:
- DataflowSolver(DFValuesTy& d) : D(d) {}
+ DataflowSolver(DFValuesTy& d) : D(d), TF(d.getAnalysisData()) {}
~DataflowSolver() {}
/// runOnCFG - Computes dataflow values for all blocks in a CFG.
/// only be used for querying the dataflow values within a block with
/// and Observer object.
void runOnBlock(const CFGBlock* B) {
- if (!hasData(B,AnalysisDirTag()))
- return;
-
- TransferFuncsTy TF (D.getAnalysisData());
- ProcessBlock(B,TF,AnalysisDirTag());
+ if (hasData(B,AnalysisDirTag()))
+ ProcessBlock(B,AnalysisDirTag());
}
//===--------------------------------------------------------------------===//
EnqueueFirstBlock(cfg,AnalysisDirTag());
- // Create the state for transfer functions.
- TransferFuncsTy TF(D.getAnalysisData());
-
// Process the worklist until it is empty.
while (!WorkList.isEmpty()) {
const CFGBlock* B = WorkList.dequeue();
// If the dataflow values at the block's entry have changed,
// enqueue all predecessor blocks onto the worklist to have
// their values updated.
- ProcessBlock(B,TF,AnalysisDirTag());
+ ProcessBlock(B,AnalysisDirTag());
UpdateEdges(B,TF.getVal(),AnalysisDirTag());
}
}
/// ProcessBlock (FORWARD ANALYSIS) - Process the transfer functions
/// for a given block based on a forward analysis.
- void ProcessBlock(const CFGBlock* B, TransferFuncsTy& TF,
- dataflow::forward_analysis_tag) {
-
- ValTy& V = TF.getVal();
-
+ void ProcessBlock(const CFGBlock* B, dataflow::forward_analysis_tag) {
+
// Merge dataflow values from all predecessors of this block.
+ ValTy& V = TF.getVal();
V.resetValues(D.getAnalysisData());
MergeOperatorTy Merge;
/// for a given block based on a forward analysis.
void ProcessBlock(const CFGBlock* B, TransferFuncsTy& TF,
dataflow::backward_analysis_tag) {
-
- ValTy& V = TF.getVal();
-
+
// Merge dataflow values from all predecessors of this block.
+ ValTy& V = TF.getVal();
V.resetValues(D.getAnalysisData());
MergeOperatorTy Merge;
private:
DFValuesTy& D;
DataflowWorkListTy WorkList;
+ TransferFuncsTy TF;
};