From c015c9fee1e0af4d3a1da2ff435b020ff107abd8 Mon Sep 17 00:00:00 2001 From: Bruce He <44327446+zm2he@users.noreply.github.com> Date: Wed, 26 Jul 2023 21:09:22 +0000 Subject: Add a Fuzzer for Lattice and Transfer Function Properties (#5831) This change adds a fuzzer which checks the following properties in abstract interpretation static analyses. - Transfer Function Monotonicity - Lattice Element Reflexivity - Lattice Element Transitivity - Lattice Element Anti-Symmetry This is done by randomly generating a module and using its functions as transfer function inputs, along with randomly generated lattice elements (states). Lattice element properties are fuzzed from the randomly generated states also. --- src/analysis/lattice.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/analysis') diff --git a/src/analysis/lattice.h b/src/analysis/lattice.h index 5ab92a320..a5c7047dd 100644 --- a/src/analysis/lattice.h +++ b/src/analysis/lattice.h @@ -11,6 +11,18 @@ namespace wasm::analysis { enum LatticeComparison { NO_RELATION, EQUAL, LESS, GREATER }; +// If parameter "comparison" compares x and y, the function returns the opposite +// direction comparison between y and x. +inline LatticeComparison reverseComparison(LatticeComparison comparison) { + if (comparison == LatticeComparison::LESS) { + return LatticeComparison::GREATER; + } else if (comparison == LatticeComparison::GREATER) { + return LatticeComparison::LESS; + } else { + return comparison; + } +} + template constexpr bool has_getBottom = std::is_invocable_r