Skip to content

Commit da149b3

Browse files
Omit empty non-constant-offset segments under TNH
1 parent 2ef1c39 commit da149b3

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/passes/MergeDataSegments.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,20 @@ struct MergeDataSegments : public Pass {
476476
flushAll(module, infos, boundsCheck, seg->memory);
477477
}
478478
info.zeroFilled = false;
479+
480+
// For the bounds check, conservatively assume that the offset is 0.
481+
if (info.inBounds(0, seg->data.size()) == InBounds::No) {
482+
trapSegment = std::move(seg);
483+
break;
484+
}
485+
module->dataSegments.push_back(std::move(seg));
479486
} else {
480487
// An empty non-constant-offset segment only triggers a bounds check.
481488
if (!trapsNeverHappen) {
482489
flushAll(module, infos, boundsCheck, std::nullopt);
490+
module->dataSegments.push_back(std::move(seg));
483491
}
484492
}
485-
486-
// For the bounds check, we conservatively assume that the offset is 0.
487-
if (info.inBounds(0, seg->data.size()) == InBounds::No) {
488-
trapSegment = std::move(seg);
489-
break;
490-
}
491-
module->dataSegments.push_back(std::move(seg));
492493
}
493494
}
494495

0 commit comments

Comments
 (0)