summaryrefslogtreecommitdiff
path: root/src/analysis/liveness-transfer-function.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-10-25 19:00:55 +0200
committerGitHub <noreply@github.com>2023-10-25 19:00:55 +0200
commitef8e424ac85a4d719233764f980a331842af6907 (patch)
tree3c1eccc0da5cc8bf1f5808bd45d1f78c7359673f /src/analysis/liveness-transfer-function.h
parentdfd8c7e244a8a6b3666221fa4a7e611e3a97467d (diff)
downloadbinaryen-ef8e424ac85a4d719233764f980a331842af6907.tar.gz
binaryen-ef8e424ac85a4d719233764f980a331842af6907.tar.bz2
binaryen-ef8e424ac85a4d719233764f980a331842af6907.zip
[analysis] Simplify core analysis code (#6034)
Simplify the monotone analyzer by replacing all the state it used to store in `BlockState` with a simple vector of lattice elements. Use simple indices to refer to both blocks and their associated states in the vector. Remove the ability for transfer functions to control the initial enqueued order of basic blocks since that was a leaky abstraction. Replace the worklist with a UniqueDeferredQueue since that has generally proven to be more efficient in smiilarly contexts, and more importantly, it has a nicer API. Make miscellaneous simplifications to other code as well. Delete a few unit tests that exposed the order in which blocks were analyzed because they printed intermediate results. These tests should be replaced with tests of analyses' public APIs in the future.
Diffstat (limited to 'src/analysis/liveness-transfer-function.h')
-rw-r--r--src/analysis/liveness-transfer-function.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/analysis/liveness-transfer-function.h b/src/analysis/liveness-transfer-function.h
index 7cc477178..5746577bb 100644
--- a/src/analysis/liveness-transfer-function.h
+++ b/src/analysis/liveness-transfer-function.h
@@ -28,23 +28,21 @@ struct LivenessTransferFunction
// to be passed in, where the temp copy is modified in place to produce the
// intermediate states.
void print(std::ostream& os,
- const BasicBlock* cfgBlock,
+ const BasicBlock& bb,
FiniteIntPowersetLattice::Element& inputState) {
os << "Intermediate States (reverse order): " << std::endl;
currState = &inputState;
currState->print(os);
os << std::endl;
- auto cfgIter = cfgBlock->rbegin();
// Since we don't store the intermediate states, we need to re-run the
// transfer function on all the CFG node expressions to reconstruct
// the intermediate states here.
- while (cfgIter != cfgBlock->rend()) {
- os << ShallowExpression{*cfgIter} << std::endl;
- visit(*cfgIter);
+ for (auto it = bb.rbegin(); it != bb.rend(); ++it) {
+ os << ShallowExpression{*it} << "\n";
+ visit(*it);
currState->print(os);
- os << std::endl;
- ++cfgIter;
+ os << "\n";
}
currState = nullptr;
}