Skip to content

Commit 1911e0b

Browse files
authored
Also remove BulkMemory feature when running LLVMMemCopyFillLowering (#7189)
This is safe because we have already asserted that there are no passive segments. This causes Binaryen to encode the resulting binary without a DataCount section, making it compatible with engines that don't support bulk memory.
1 parent 0d7ef68 commit 1911e0b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/passes/LLVMMemoryCopyFillLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ struct LLVMMemoryCopyFillLowering
7070
" no passive segments";
7171
}
7272
}
73+
// Since there are no passive segments, we can remove the feature. This also
74+
// causes Binaryen to not encode a DataCount section.
75+
module->features.setBulkMemory(false);
7376

7477
// In order to introduce a call to a function, it must first exist, so
7578
// create an empty stub.

test/lit/passes/memory-copy-fill-lowering.wast

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
1+
;; NOTE: These assertions have been manually generated, and cannot be updated by update_lit_checks.py
2+
;; because of the assertion at the end (update_lit_checks.py ignores the features section because it's
3+
;; not semantically part of the module.)
24

3-
;; RUN: wasm-opt --enable-bulk-memory %s --llvm-memory-copy-fill-lowering -S -o - | filecheck %s
5+
;; RUN: wasm-opt --enable-bulk-memory %s --llvm-memory-copy-fill-lowering --emit-target-features -S -o - | filecheck %s
46

57
(module
68
(memory 0)
@@ -166,3 +168,4 @@
166168
;; CHECK-NEXT: )
167169
;; CHECK-NEXT: )
168170
;; CHECK-NEXT: )
171+
;; CHECK-NEXT: ;; features section: mutable-globals, sign-ext

0 commit comments

Comments
 (0)