Skip to content

Commit 9e6bae0

Browse files
authored
add evaluateFunctionExit for backward analyzer in monotone-analyzer (#7547)
For backward analyzer, it is helpful to have a function to init state in the "entry point" (exit block).
1 parent f030449 commit 9e6bae0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/analysis/monotone-analyzer-impl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ inline void
2121
MonotoneCFGAnalyzer<L, TxFn>::evaluateFunctionEntry(Function* func) {
2222
txfn.evaluateFunctionEntry(func, states[0]);
2323
}
24+
template<Lattice L, TransferFunction TxFn>
25+
inline void MonotoneCFGAnalyzer<L, TxFn>::evaluateFunctionExit(Function* func) {
26+
for (size_t i = 0; i < cfg.size(); i++) {
27+
if (cfg[i].isExit()) {
28+
txfn.evaluateFunctionExit(func, states[i]);
29+
break;
30+
}
31+
}
32+
}
2433

2534
template<Lattice L, TransferFunction TxFn>
2635
inline void MonotoneCFGAnalyzer<L, TxFn>::evaluate() {

src/analysis/monotone-analyzer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ template<Lattice L, TransferFunction TxFn> class MonotoneCFGAnalyzer {
3434
// entry block depends on no other blocks, and hence cannot be changed by
3535
// them.
3636
void evaluateFunctionEntry(Function* func);
37+
// This modifies the state of the CFG's exit block, with function
38+
// information. This cannot be done otherwise in a backward analysis, as the
39+
// exit block depends on no other blocks, and hence cannot be changed by
40+
// them.
41+
void evaluateFunctionExit(Function* func);
3742

3843
// Iterates over all of the BlockStates after evaluate() is completed for the
3944
// transfer function to collect the finalized intermediate states from each

0 commit comments

Comments
 (0)