diff options
author | Thomas Lively <tlively@google.com> | 2023-01-09 16:23:12 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 14:23:12 -0800 |
commit | e3d9b82d9f8910063373e2952582de545659d448 (patch) | |
tree | d182bcadbeffc811b8b6eb064ae1041a690451f6 /src | |
parent | 2608864d6fc812a90d2e2594c70767f5fb4811a7 (diff) | |
download | binaryen-e3d9b82d9f8910063373e2952582de545659d448.tar.gz binaryen-e3d9b82d9f8910063373e2952582de545659d448.tar.bz2 binaryen-e3d9b82d9f8910063373e2952582de545659d448.zip |
[Wasm GC] Do not treat extern conversions as casts (#5411)
In particular, do not treat the converted value as "falling through" the
conversion. Since the conversions cross type hierarchies, treating the converted
values as fallthrough values would make subsequent casts look like they must
fail, when in fact they may not.
Fixes #5407.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/properties.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ir/properties.h b/src/ir/properties.h index 2214eecaf..cddcbc5f2 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -311,7 +311,12 @@ inline Expression* getImmediateFallthrough( } else if (auto* as = curr->dynCast<RefCast>()) { return as->ref; } else if (auto* as = curr->dynCast<RefAs>()) { - return as->value; + // Extern conversions are not casts and actually produce new values. + // Treating them as fallthroughs would lead to misoptimizations of + // subsequent casts. + if (as->op != ExternInternalize && as->op != ExternExternalize) { + return as->value; + } } else if (auto* br = curr->dynCast<BrOn>()) { return br->ref; } |