summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-01-25 13:26:04 -0800
committerGitHub <noreply@github.com>2024-01-25 13:26:04 -0800
commit5fb2137d7f1272b7b107f0413190ad94bb69a73b (patch)
treec455db5364de1616804a05f5edee0c54219119e9 /src
parent662835a88f6f47d5b1451b453046ae80b4b0fc62 (diff)
downloadbinaryen-5fb2137d7f1272b7b107f0413190ad94bb69a73b.tar.gz
binaryen-5fb2137d7f1272b7b107f0413190ad94bb69a73b.tar.bz2
binaryen-5fb2137d7f1272b7b107f0413190ad94bb69a73b.zip
MemoryPacking: Ignore empty segments (#6243)
They might trap. Leave that for RemoveUnusedModuleElements. Fixes #6230
Diffstat (limited to 'src')
-rw-r--r--src/passes/MemoryPacking.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp
index 1d214abdc..c47516485 100644
--- a/src/passes/MemoryPacking.cpp
+++ b/src/passes/MemoryPacking.cpp
@@ -270,6 +270,13 @@ bool MemoryPacking::canSplit(const std::unique_ptr<DataSegment>& segment,
return false;
}
+ if (segment->data.empty()) {
+ // Ignore empty segments, leaving them in place. We may not need them, but
+ // leave that for RemoveUnusedModuleElements to decide (as they may trap
+ // during startup if out of bounds, which is an effect).
+ return false;
+ }
+
for (auto* referrer : referrers) {
if (auto* curr = referrer->dynCast<MemoryInit>()) {
if (segment->isPassive) {