summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/effects.h2
-rw-r--r--test/example/cpp-unit.cpp14
2 files changed, 16 insertions, 0 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h
index b9393ade2..475e6f2b1 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -659,6 +659,8 @@ private:
}
}
void visitArrayCopy(ArrayCopy* curr) {
+ parent.readsArray = true;
+ parent.writesArray = true;
// traps when a ref is null, or when out of bounds.
parent.implicitTrap = true;
}
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() {