diff options
author | Thomas Lively <tlively@google.com> | 2024-11-26 14:26:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-26 22:26:57 +0000 |
commit | 4ffe27255ce99d452d05d4b352e3f6e1e9ca7d83 (patch) | |
tree | 45609182512408ac238411d0fd44e22745d0f585 /src | |
parent | ffc3f2219b18c2a2ddb160c0d81518234faa2cd1 (diff) | |
download | binaryen-4ffe27255ce99d452d05d4b352e3f6e1e9ca7d83.tar.gz binaryen-4ffe27255ce99d452d05d4b352e3f6e1e9ca7d83.tar.bz2 binaryen-4ffe27255ce99d452d05d4b352e3f6e1e9ca7d83.zip |
ReFinalize after merging siblings in TypeMerging (#7121)
The LUB of sibling types is their common supertype, but after the
sibling types are merged, their LUB is the merged type, which is a
strict subtype of the previous LUB. This means that merging sibling
types causes `selects` to have stale types when the two select arms
previously had the two merged sibling types. To fix any potential stale
types, ReFinalize after merging sibling types.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/TypeMerging.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/passes/TypeMerging.cpp b/src/passes/TypeMerging.cpp index 22c2352f2..e7a25cf37 100644 --- a/src/passes/TypeMerging.cpp +++ b/src/passes/TypeMerging.cpp @@ -38,6 +38,7 @@ #include "ir/module-utils.h" #include "ir/type-updating.h" +#include "ir/utils.h" #include "pass.h" #include "support/dfa_minimization.h" #include "support/small_set.h" @@ -229,14 +230,24 @@ void TypeMerging::run(Module* module_) { // Merging can unlock more sibling merging opportunities because two identical // types cannot be merged until their respective identical parents have been // merged in a previous step, making them siblings. + // + // If we merge siblings, we also need to refinalize because the LUB of merged + // siblings is the merged type rather than their common supertype after the + // merge. + bool refinalize = false; merge(Supertypes); for (int i = 0; i < MAX_ITERATIONS; ++i) { if (!merge(Siblings)) { break; } + refinalize = true; } applyMerges(); + + if (refinalize) { + ReFinalize().run(getPassRunner(), module); + } } bool TypeMerging::merge(MergeKind kind) { |