llvm-project/lld/test/wasm/memory-naming.test
Sam Clegg 6c84dd7b1c
[lld][WebAssembly] Default to --stack-first (#166998)
The really painful part of this PR was updating all the test files. I
had some help from Gemini GLI there
which did a pretty good job (got maybe 80% of the updates done).

Fixes: #151015
2025-11-08 00:27:06 +00:00

104 lines
4.3 KiB
Plaintext

# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o
# RUN: wasm-ld --export-memory=foo -o %t.wasm %t.start.o
# RUN: obj2yaml %t.wasm | FileCheck %s
# Verify that the --export-memory=<name> option changes the exported name of the module's memory
# CHECK: - Type: EXPORT
# CHECK-NEXT: Exports:
# CHECK-NEXT: - Name: foo
# CHECK-NEXT: Kind: MEMORY
# CHECK-NEXT: Index: 0
# CHECK-NEXT: - Name: _start
# CHECK-NEXT: Kind: FUNCTION
# CHECK-NEXT: Index: 0
# CHECK-NEXT: - Type:
# RUN:wasm-ld --export-memory --export-memory -o %t.unnamed.wasm %t.start.o
# RUN: obj2yaml %t.unnamed.wasm | FileCheck -check-prefix=CHECK-UNNAMED %s
# Verify that the --export-memory option without a parameter exports the memory
# as "memory"
# CHECK-UNNAMED: - Type: EXPORT
# CHECK-UNNAMED-NEXT: Exports:
# CHECK-UNNAMED-NEXT: - Name: memory
# CHECK-UNNAMED-NEXT: Kind: MEMORY
# CHECK-UNNAMED-NEXT: Index: 0
# CHECK-UNNAMED-NEXT: - Name: _start
# CHECK-UNNAMED-NEXT: Kind: FUNCTION
# CHECK-UNNAMED-NEXT: Index: 0
# CHECK-UNNAMED-NEXT: - Type:
# RUN:wasm-ld --export-memory=foo --export-memory=foo -o %t.duplicate.wasm %t.start.o
# RUN: obj2yaml %t.duplicate.wasm | FileCheck -check-prefix=CHECK-DUPLICATE %s
# Verify that passing --export-memory with the same name twice works
# CHECK-DUPLICATE: - Type: EXPORT
# CHECK-DUPLICATE-NEXT: Exports:
# CHECK-DUPLICATE-NEXT: - Name: foo
# CHECK-DUPLICATE-NEXT: Kind: MEMORY
# CHECK-DUPLICATE-NEXT: Index: 0
# CHECK-DUPLICATE-NEXT: - Name: _start
# CHECK-DUPLICATE-NEXT: Kind: FUNCTION
# CHECK-DUPLICATE-NEXT: Index: 0
# CHECK-DUPLICATE-NEXT: - Type:
# RUN:wasm-ld --import-memory=foo,bar -o %t.import.wasm %t.start.o
# RUN: obj2yaml %t.import.wasm | FileCheck -check-prefix=CHECK-IMPORT %s
# Verify that memory imports can be renamed, and that no memory is exported by
# default when memory is being imported
# CHECK-IMPORT: - Type: IMPORT
# CHECK-IMPORT-NEXT: Imports:
# CHECK-IMPORT-NEXT: - Module: foo
# CHECK-IMPORT-NEXT: Field: bar
# CHECK-IMPORT-NEXT: Kind: MEMORY
# CHECK-IMPORT-NEXT: Memory:
# CHECK-IMPORT-NEXT: Minimum: 0x1
# CHECK-IMPORT: - Type: EXPORT
# CHECK-IMPORT-NEXT: Exports:
# CHECK-IMPORT-NEXT: - Name: _start
# CHECK-IMPORT-NEXT: Kind: FUNCTION
# CHECK-IMPORT-NEXT: Index: 0
# CHECK-IMPORT-NEXT: - Type:
# RUN:wasm-ld --import-memory=foo -o %t.import.wasm %t.start.o
# RUN: obj2yaml %t.import.wasm | FileCheck -check-prefix=CHECK-IMPORT-DEFAULT %s
# Verify that memory import module defaults to `env`, which is the default
# module for all imports.
# CHECK-IMPORT-DEFAULT: - Type: IMPORT
# CHECK-IMPORT-DEFAULT-NEXT: Imports:
# CHECK-IMPORT-DEFAULT-NEXT: - Module: env
# CHECK-IMPORT-DEFAULT-NEXT: Field: foo
# CHECK-IMPORT-DEFAULT-NEXT: Kind: MEMORY
# CHECK-IMPORT-DEFAULT-NEXT: Memory:
# CHECK-IMPORT-DEFAULT-NEXT: Minimum: 0x1
# CHECK-IMPORT-DEFAULT-NEXT: - Type:
# RUN:wasm-ld --import-memory=foo,bar --export-memory=qux -o %t.both.wasm %t.start.o
# RUN: obj2yaml %t.both.wasm | FileCheck -check-prefix=CHECK-BOTH %s
# Verify that memory can be both imported and exported from a module
# CHECK-BOTH: - Type: IMPORT
# CHECK-BOTH-NEXT: Imports:
# CHECK-BOTH-NEXT: - Module: foo
# CHECK-BOTH-NEXT: Field: bar
# CHECK-BOTH-NEXT: Kind: MEMORY
# CHECK-BOTH-NEXT: Memory:
# CHECK-BOTH-NEXT: Minimum: 0x1
# CHECK-BOTH: - Type: EXPORT
# CHECK-BOTH-NEXT: Exports:
# CHECK-BOTH-NEXT: - Name: qux
# CHECK-BOTH-NEXT: Kind: MEMORY
# CHECK-BOTH-NEXT: Index: 0
# CHECK-BOTH-NEXT: - Name: _start
# CHECK-BOTH-NEXT: Kind: FUNCTION
# CHECK-BOTH-NEXT: Index: 0
# CHECK-BOTH-NEXT: - Type: