Summary: The DataCount section is necessary for the bulk memory operations memory.init and data.drop to validate, but it is not recognized by engines that do not support bulk memory, so emit the section only if bulk-memory is enabled. Reviewers: aheejin, dschuff, sbc100 Subscribers: jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60637 llvm-svn: 358798
48 lines
2.0 KiB
LLVM
48 lines
2.0 KiB
LLVM
target triple = "wasm32-unknown-unknown"
|
|
|
|
@a = hidden global [6 x i8] c"hello\00", align 1
|
|
@b = hidden global [8 x i8] c"goodbye\00", align 1
|
|
@c = hidden global [9 x i8] c"whatever\00", align 1
|
|
@d = hidden global i32 42, align 4
|
|
|
|
@e = private constant [9 x i8] c"constant\00", align 1
|
|
@f = private constant i8 43, align 4
|
|
|
|
; RUN: llc -filetype=obj %s -o %t.data-segment-merging.o
|
|
|
|
; RUN: wasm-ld -no-gc-sections --no-entry -o %t.merged.wasm %t.data-segment-merging.o
|
|
; RUN: obj2yaml %t.merged.wasm | FileCheck %s --check-prefix=MERGE
|
|
|
|
; MERGE-NOT: DATACOUNT
|
|
; MERGE: - Type: DATA
|
|
; MERGE: Segments:
|
|
; MERGE: Content: 68656C6C6F00676F6F6462796500776861746576657200002A000000
|
|
; MERGE: Content: 636F6E7374616E74000000002B
|
|
; MERGE-NOT: Content:
|
|
|
|
; RUN: wasm-ld -no-gc-sections --no-entry --no-merge-data-segments -o %t.separate.wasm %t.data-segment-merging.o
|
|
; RUN: obj2yaml %t.separate.wasm | FileCheck %s --check-prefix=SEPARATE
|
|
|
|
; SEPARATE-NOT: DATACOUNT
|
|
; SEPARATE: - Type: DATA
|
|
; SEPARATE: Segments:
|
|
; SEPARATE: Content: 68656C6C6F00
|
|
; SEPARATE: Content: 676F6F6462796500
|
|
; SEPARATE: Content: '776861746576657200'
|
|
; SEPARATE: Content: 2A000000
|
|
; SEPARATE: Content: 636F6E7374616E7400
|
|
; SEPARATE: Content: 2B
|
|
; SEPARATE-NOT: Content:
|
|
|
|
; RUN: llc -filetype=obj %s -mattr=+bulk-memory -o %t.data-segment-merging.bulk-memory.o
|
|
; RUN: wasm-ld -no-gc-sections --no-entry -o %t.merged.bulk-memory.wasm %t.data-segment-merging.bulk-memory.o
|
|
; RUN: obj2yaml %t.merged.bulk-memory.wasm | FileCheck %s --check-prefix=BULK-MEMORY
|
|
|
|
; BULK-MEMORY: - Type: DATACOUNT
|
|
; BULK-MEMORY: Count: 2
|
|
; BULK-MEMORY: - Type: DATA
|
|
; BULK-MEMORY: Segments:
|
|
; BULK-MEMORY: Content: 68656C6C6F00676F6F6462796500776861746576657200002A000000
|
|
; BULK-MEMORY: Content: 636F6E7374616E74000000002B
|
|
; BULK-MEMORY-NOT: Content:
|