Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / wasm / archive-weak-undefined.s
blobec95787bd0ee5ed3b172fc3269b556f73ce5820a
1 ## Test that weak undefined symbols do not fetch members from archive files.
2 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
4 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
5 # RUN: rm -f %t.a
6 # RUN: llvm-ar rcs %t.a %t.ret32.o %t.hello.o
8 # RUN: wasm-ld %t.o %t.a -o %t.wasm
9 # RUN: obj2yaml %t.wasm | FileCheck %s
11 ## Also test with the library symbols being read first
12 # RUN: wasm-ld %t.a %t.o -o %t2.wasm
13 # RUN: obj2yaml %t2.wasm | FileCheck %s
15 # RUN: wasm-ld -u hello_str %t.o %t.a -o %t2.wasm
16 # RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=CHECK-DATA
18 # Weak external function symbol
19 .weak ret32
20 .functype ret32 () -> (i32)
22 # Weak external data symbol
23 .weak hello_str
25 .globl _start
26 _start:
27 .functype _start () -> ()
28 block
29 i32.const hello_str
30 i32.eqz
31 br_if 0
32 call ret32
33 drop
34 end_block
35 end_function
37 # Ensure we have no data section. If we do, would mean that hello_str was
38 # pulled out of the library.
39 # CHECK-NOT: Type: DATA
40 # CHECK-DATA: Type: DATA
42 # CHECK: Name: 'undefined_weak:ret32'
43 # CHECK-NOT: Name: ret32