diff options
author | Thomas Lively <tlively@google.com> | 2023-10-25 19:00:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 19:00:55 +0200 |
commit | ef8e424ac85a4d719233764f980a331842af6907 (patch) | |
tree | 3c1eccc0da5cc8bf1f5808bd45d1f78c7359673f /src/tools/wasm-fuzz-lattices.cpp | |
parent | dfd8c7e244a8a6b3666221fa4a7e611e3a97467d (diff) | |
download | binaryen-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/tools/wasm-fuzz-lattices.cpp')
-rw-r--r-- | src/tools/wasm-fuzz-lattices.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/tools/wasm-fuzz-lattices.cpp b/src/tools/wasm-fuzz-lattices.cpp index fe801ba12..390104223 100644 --- a/src/tools/wasm-fuzz-lattices.cpp +++ b/src/tools/wasm-fuzz-lattices.cpp @@ -192,7 +192,7 @@ public: // the transfer function is monotonic. If this is violated, then we print out // the CFG block input which caused the transfer function to exhibit // non-monotonic behavior. - void checkMonotonicity(const BasicBlock* cfgBlock, + void checkMonotonicity(const BasicBlock& bb, typename L::Element& first, typename L::Element& second, typename L::Element& firstResult, @@ -233,7 +233,7 @@ public: secondResult.print(ss); ss << "\n show that the transfer function is not monotone when given the " "input:\n"; - cfgBlock->print(ss); + bb.print(ss); ss << "\n"; Fatal() << ss.str(); @@ -260,19 +260,19 @@ public: typename L::Element x, typename L::Element y, typename L::Element z) { - for (auto cfgIter = cfg.begin(); cfgIter != cfg.end(); ++cfgIter) { + for (const auto& bb : cfg) { // Apply transfer function on each lattice element. - typename L::Element xResult = x; - txfn.transfer(&(*cfgIter), xResult); - typename L::Element yResult = y; - txfn.transfer(&(*cfgIter), yResult); - typename L::Element zResult = z; - txfn.transfer(&(*cfgIter), zResult); + auto xResult = x; + txfn.transfer(bb, xResult); + auto yResult = y; + txfn.transfer(bb, yResult); + auto zResult = z; + txfn.transfer(bb, zResult); // Check monotonicity for every pair of transfer function outputs. - checkMonotonicity(&(*cfgIter), x, y, xResult, yResult); - checkMonotonicity(&(*cfgIter), x, z, xResult, zResult); - checkMonotonicity(&(*cfgIter), y, z, yResult, zResult); + checkMonotonicity(bb, x, y, xResult, yResult); + checkMonotonicity(bb, x, z, xResult, zResult); + checkMonotonicity(bb, y, z, yResult, zResult); } } }; |