diff options
author | Alon Zakai <azakai@google.com> | 2023-02-24 10:44:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 10:44:59 -0800 |
commit | c193c59f338cfc24d6803fba1c04c523d0d6109b (patch) | |
tree | 09a94d557ac60314872c3018f92efa8fa6e77152 /src/ir/memory-utils.cpp | |
parent | d21fb738ff9bdcbbd98b757973d78b188621f11e (diff) | |
download | binaryen-c193c59f338cfc24d6803fba1c04c523d0d6109b.tar.gz binaryen-c193c59f338cfc24d6803fba1c04c523d0d6109b.tar.bz2 binaryen-c193c59f338cfc24d6803fba1c04c523d0d6109b.zip |
Memory flattening cannot be done in the presence of DataDrop (#5521)
Like MemoryInit, this instruction cares about segment identity, so merging
segments into one big one for flattening is disallowed.
Diffstat (limited to 'src/ir/memory-utils.cpp')
-rw-r--r-- | src/ir/memory-utils.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ir/memory-utils.cpp b/src/ir/memory-utils.cpp index f1471b7a4..b21d8f0ad 100644 --- a/src/ir/memory-utils.cpp +++ b/src/ir/memory-utils.cpp @@ -24,19 +24,21 @@ bool flatten(Module& wasm) { if (wasm.memories.size() > 1) { return false; } - // The presence of any MemoryInit instructions is a problem because they care - // about segment identity, which flattening gets rid of ( when it merges them - // all into one big segment). + // The presence of any instruction that cares about segment identity is a + // problem because flattening gets rid of that (when it merges them all into + // one big segment). ModuleUtils::ParallelFunctionAnalysis<bool> analysis( - wasm, [&](Function* func, bool& hasMemoryInit) { + wasm, [&](Function* func, bool& noticesSegmentIdentity) { if (func->imported()) { return; } - hasMemoryInit = FindAll<MemoryInit>(func->body).list.size() > 0; + noticesSegmentIdentity = + FindAll<MemoryInit>(func->body).list.size() > 0 || + FindAll<DataDrop>(func->body).list.size() > 0; }); - for (auto& [func, hasMemoryInit] : analysis.map) { - if (hasMemoryInit) { + for (auto& [func, noticesSegmentIdentity] : analysis.map) { + if (noticesSegmentIdentity) { return false; } } |