diff options
author | Bruce He <44327446+zm2he@users.noreply.github.com> | 2023-07-19 21:52:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-19 17:52:55 -0400 |
commit | f61bf9f46addc0b6885b60b3e0f1c4ccc7e64473 (patch) | |
tree | 92dd1216ad6d3982e0f51f797b3030f8dea2ee25 /src/analysis/cfg-impl.h | |
parent | a15d71f5fb4f3488e8a25071cb8813fe6045290e (diff) | |
download | binaryen-f61bf9f46addc0b6885b60b3e0f1c4ccc7e64473.tar.gz binaryen-f61bf9f46addc0b6885b60b3e0f1c4ccc7e64473.tar.bz2 binaryen-f61bf9f46addc0b6885b60b3e0f1c4ccc7e64473.zip |
Reaching Definitions Analysis for LocalGraph (#5817)
This change implements a reaching definitions analysis which is intended
to be equivalent to the information provided by LocalGraph, specifically
the Flower class of LocalGraph.
It also introduces a CRTP utility in visitor-transfer-function.h which
implements most commonly found visitor-type transfer function
functionalities. The MonotoneCFGAnalyzer is also modified to add a phase
to collect results after the analysis is solved from the final CFG
states.
Diffstat (limited to 'src/analysis/cfg-impl.h')
-rw-r--r-- | src/analysis/cfg-impl.h | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/analysis/cfg-impl.h b/src/analysis/cfg-impl.h index cf348fa09..14fadd22c 100644 --- a/src/analysis/cfg-impl.h +++ b/src/analysis/cfg-impl.h @@ -118,21 +118,17 @@ template<typename T> struct _indirect_ptr_vec { iterator end() const { return {&vec.data()[vec.size()]}; } }; -struct BasicBlock::Predecessors : _indirect_ptr_vec<BasicBlock> { - Predecessors(const BasicBlock& block) - : _indirect_ptr_vec(block.predecessors) {} +struct BasicBlock::BasicBlockIterable : _indirect_ptr_vec<BasicBlock> { + BasicBlockIterable(const std::vector<BasicBlock*>& blocks) + : _indirect_ptr_vec(blocks) {} }; -struct BasicBlock::Successors : _indirect_ptr_vec<BasicBlock> { - Successors(const BasicBlock& block) : _indirect_ptr_vec(block.successors) {} -}; - -inline BasicBlock::Predecessors BasicBlock::preds() const { - return Predecessors(*this); +inline BasicBlock::BasicBlockIterable BasicBlock::preds() const { + return BasicBlockIterable(predecessors); } -inline BasicBlock::Successors BasicBlock::succs() const { - return Successors(*this); +inline BasicBlock::BasicBlockIterable BasicBlock::succs() const { + return BasicBlockIterable(successors); } } // namespace wasm::analysis |