summaryrefslogtreecommitdiff
path: root/src/analysis/visitor-transfer-function.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-10-21 02:22:37 +0200
committerGitHub <noreply@github.com>2023-10-20 17:22:37 -0700
commit17305e5d796ced05680dbca34bebef124ac9493b (patch)
tree6dc657a0e03c540b40184154f7fe2ec044386c57 /src/analysis/visitor-transfer-function.h
parentce6fe670bee398b8e258120f16b4aa7f942e418c (diff)
downloadbinaryen-17305e5d796ced05680dbca34bebef124ac9493b.tar.gz
binaryen-17305e5d796ced05680dbca34bebef124ac9493b.tar.bz2
binaryen-17305e5d796ced05680dbca34bebef124ac9493b.zip
[analysis][NFC] Create a TransferFunction concept (#6033)
Factor the static assertions for transfer functions out into a new transfer-function.h header. The concept requires the `getDependents` method to return an input range of basic blocks, and to satisfy that requirement, fix up _indirect_ptr_iterator in cfg-impl.h so that it is a proper iterator. Remove part of the lattice fuzzer that was using a placeholder transfer function in a way that does not satisfy the new type constraints; most of that code will be overhauled in the future anyway.
Diffstat (limited to 'src/analysis/visitor-transfer-function.h')
-rw-r--r--src/analysis/visitor-transfer-function.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/analysis/visitor-transfer-function.h b/src/analysis/visitor-transfer-function.h
index 699840ff3..79acf00da 100644
--- a/src/analysis/visitor-transfer-function.h
+++ b/src/analysis/visitor-transfer-function.h
@@ -35,7 +35,8 @@ protected:
public:
// Returns an iterable to all the BasicBlocks which depend on currBlock for
// information.
- BasicBlock::BasicBlockIterable getDependents(const BasicBlock* currBlock) {
+ BasicBlock::BasicBlockIterable
+ getDependents(const BasicBlock* currBlock) noexcept {
if constexpr (Direction == AnalysisDirection::Backward) {
return currBlock->preds();
} else {
@@ -46,7 +47,8 @@ public:
// Executes the transfer function on all the expressions of the corresponding
// CFG node, starting with the node's input state, and changes the input state
// to the final output state of the node in place.
- void transfer(const BasicBlock* cfgBlock, typename L::Element& inputState) {
+ void transfer(const BasicBlock* cfgBlock,
+ typename L::Element& inputState) noexcept {
// If the block is empty, we propagate the state by inputState =
// outputState.
@@ -71,7 +73,8 @@ public:
// analysis, we push all the blocks in order, while for backward analysis, we
// push them in reverse order, so that later blocks are evaluated before
// earlier ones.
- void enqueueWorklist(CFG& cfg, std::queue<const BasicBlock*>& worklist) {
+ void enqueueWorklist(const CFG& cfg,
+ std::queue<const BasicBlock*>& worklist) noexcept {
if constexpr (Direction == AnalysisDirection::Backward) {
for (auto it = cfg.rbegin(); it != cfg.rend(); ++it) {
worklist.push(&(*it));