Skip to content

Commit

Permalink
Also remove BulkMemory feature when running LLVMMemCopyFillLowering (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
dschuff authored Jan 4, 2025
1 parent 0d7ef68 commit 1911e0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/passes/LLVMMemoryCopyFillLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ struct LLVMMemoryCopyFillLowering
" no passive segments";
}
}
// Since there are no passive segments, we can remove the feature. This also
// causes Binaryen to not encode a DataCount section.
module->features.setBulkMemory(false);

// In order to introduce a call to a function, it must first exist, so
// create an empty stub.
Expand Down
7 changes: 5 additions & 2 deletions test/lit/passes/memory-copy-fill-lowering.wast
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: These assertions have been manually generated, and cannot be updated by update_lit_checks.py
;; because of the assertion at the end (update_lit_checks.py ignores the features section because it's
;; not semantically part of the module.)

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

(module
(memory 0)
Expand Down Expand Up @@ -166,3 +168,4 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: ;; features section: mutable-globals, sign-ext

0 comments on commit 1911e0b

Please sign in to comment.