xref: /llvm-project/lld/test/wasm/initial-heap.test (revision b2cdf3cc4c08729d0ff582d55e40793a20bbcdcc)
1*b2cdf3ccSSingleAccretionRUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o
2*b2cdf3ccSSingleAccretion
3*b2cdf3ccSSingleAccretion; The initial heap size will be added to the stack size
4*b2cdf3ccSSingleAccretionRUN: wasm-ld %t.o -o %t1.wasm --stack-first -z stack-size=65536 --initial-heap=131072
5*b2cdf3ccSSingleAccretionRUN: obj2yaml %t1.wasm | FileCheck %s --check-prefixes=CHECK,CHECK-2P
6*b2cdf3ccSSingleAccretion
7*b2cdf3ccSSingleAccretion; Also test that we can parse and process a large size correctly
8*b2cdf3ccSSingleAccretionRUN: wasm-ld %t.o -o %t2.wasm --stack-first -z stack-size=65536 --initial-heap=4294901760
9*b2cdf3ccSSingleAccretionRUN: obj2yaml %t2.wasm | FileCheck %s --check-prefixes=CHECK,CHECK-4G
10*b2cdf3ccSSingleAccretion
11*b2cdf3ccSSingleAccretionCHECK:      - Type:            MEMORY
12*b2cdf3ccSSingleAccretionCHECK-NEXT:   Memories:
13*b2cdf3ccSSingleAccretionCHECK-2P-NEXT:    Minimum:         0x3
14*b2cdf3ccSSingleAccretionCHECK-4G-NEXT:    Minimum:         0x10000
15*b2cdf3ccSSingleAccretion
16*b2cdf3ccSSingleAccretion; Test various error cases.
17*b2cdf3ccSSingleAccretionRUN: not wasm-ld %t.o -o %t3.wasm --initial-heap=131073 2>&1 | FileCheck %s --check-prefix NOT-PAGE-MULTIPLE
18*b2cdf3ccSSingleAccretionRUN: not wasm-ld %t.o -o %t4.wasm --stack-first -z stack-size=65536 --initial-heap=4295032832 2>&1 | FileCheck %s --check-prefix TOO-LARGE-BY-ITSELF
19*b2cdf3ccSSingleAccretionRUN: not wasm-ld %t.o -o %t5.wasm --stack-first -z stack-size=131072 --initial-heap=4294901760 2>&1 | FileCheck %s --check-prefix TOO-LARGE-WITH-STACK
20*b2cdf3ccSSingleAccretionRUN: not wasm-ld %t.o -o %t6.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --initial-memory=131072 2>&1 | FileCheck %s --check-prefix INITIAL-MEMORY-TOO-SMALL
21*b2cdf3ccSSingleAccretionRUN: not wasm-ld %t.o -o %t7.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --max-memory=131072 2>&1 | FileCheck %s --check-prefix MAX-MEMORY-TOO-SMALL
22*b2cdf3ccSSingleAccretion
23*b2cdf3ccSSingleAccretionNOT-PAGE-MULTIPLE: initial heap must be 65536-byte aligned
24*b2cdf3ccSSingleAccretionTOO-LARGE-BY-ITSELF: initial heap too large, cannot be greater than 4294901760
25*b2cdf3ccSSingleAccretionTOO-LARGE-WITH-STACK: initial heap too large, cannot be greater than 4294836224
26*b2cdf3ccSSingleAccretionINITIAL-MEMORY-TOO-SMALL: initial memory too small, 196608 bytes needed
27*b2cdf3ccSSingleAccretionMAX-MEMORY-TOO-SMALL: maximum memory too small, 196608 bytes needed
28