From 4bf2d3bc3da17a28b65222d6e84f6126dcb9c553 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Sep 2021 14:06:56 -0700 Subject: Fix the effects of array.copy (#4118) This appeared to be a regression from #4117, however this was always a bug, and that PR just exposed it. That is, somehow we forgot to indicate the effects of ArrayCopy, and after that PR we'd vacuum it out incorrectly. --- test/example/cpp-unit.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/example/cpp-unit.cpp') diff --git a/test/example/cpp-unit.cpp b/test/example/cpp-unit.cpp index 9c95bb31c..41096a43a 100644 --- a/test/example/cpp-unit.cpp +++ b/test/example/cpp-unit.cpp @@ -599,12 +599,26 @@ void test_cost() { void test_effects() { PassOptions options; Module module; + // Unreachables trap. Unreachable unreachable; assert_equal(EffectAnalyzer(options, module, &unreachable).trap, true); + // Nops... do not. Nop nop; assert_equal(EffectAnalyzer(options, module, &nop).trap, false); + + // ArrayCopy can trap, reads arrays, and writes arrays (but not structs). + { + ArrayCopy arrayCopy(module.allocator); + EffectAnalyzer effects(options, module); + effects.visit(&arrayCopy); + assert_equal(effects.trap, true); + assert_equal(effects.readsArray, true); + assert_equal(effects.writesArray, true); + assert_equal(effects.readsStruct, false); + assert_equal(effects.writesStruct, false); + } } void test_literals() { -- cgit v1.2.3