diff options
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/find_all.h | 2 | ||||
-rw-r--r-- | src/ir/properties.h | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/ir/find_all.h b/src/ir/find_all.h index bd3d265e2..77edafe89 100644 --- a/src/ir/find_all.h +++ b/src/ir/find_all.h @@ -40,6 +40,8 @@ template<typename T> struct FindAll { finder.list = &list; finder.walk(ast); } + + bool has() { return !list.empty(); } }; // Find all pointers to instances of a certain node type diff --git a/src/ir/properties.h b/src/ir/properties.h index c4deac9d5..379a85708 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -223,6 +223,9 @@ inline Index getZeroExtBits(Expression* curr) { // and other operations that receive a value and let it flow through them. If // there is no value falling through, returns the node itself (as that is the // value that trivially falls through, with 0 steps in the middle). +// Note that this returns the value that would fall through if one does in fact +// do so. For example, the final element in a block may not fall through if we +// hit a return or a trap or an exception is thrown before we get there. inline Expression* getFallthrough(Expression* curr, const PassOptions& passOptions, FeatureSet features) { @@ -259,6 +262,8 @@ inline Expression* getFallthrough(Expression* curr, if (!EffectAnalyzer(passOptions, features, tryy->body).throws) { return getFallthrough(tryy->body, passOptions, features); } + } else if (auto* as = curr->dynCast<RefCast>()) { + return getFallthrough(as->ref, passOptions, features); } else if (auto* as = curr->dynCast<RefAs>()) { return getFallthrough(as->value, passOptions, features); } else if (auto* br = curr->dynCast<BrOn>()) { |