From c193c59f338cfc24d6803fba1c04c523d0d6109b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 24 Feb 2023 10:44:59 -0800 Subject: 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. --- src/ir/memory-utils.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ir/memory-utils.cpp') 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 analysis( - wasm, [&](Function* func, bool& hasMemoryInit) { + wasm, [&](Function* func, bool& noticesSegmentIdentity) { if (func->imported()) { return; } - hasMemoryInit = FindAll(func->body).list.size() > 0; + noticesSegmentIdentity = + FindAll(func->body).list.size() > 0 || + FindAll(func->body).list.size() > 0; }); - for (auto& [func, hasMemoryInit] : analysis.map) { - if (hasMemoryInit) { + for (auto& [func, noticesSegmentIdentity] : analysis.map) { + if (noticesSegmentIdentity) { return false; } } -- cgit v1.2.3