Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / wasm / why-extract.s
blob88be4b3fcae51660541b8d9b9aab94720b10fbab
1 # RUN: rm -rf %t && split-file %s %t
2 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/main.s -o %t/main.o
3 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a.s -o %t/a.o
4 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a_b.s -o %t/a_b.o
5 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/b.s -o %t/b.o
6 # RUN: llvm-ar rc %t/a.a %t/a.o
7 # RUN: llvm-ar rc %t/a_b.a %t/a_b.o
8 # RUN: llvm-ar rc %t/b.a %t/b.o
9 # RUN: cd %t
11 ## Nothing is extracted from an archive. The file is created with just a header.
12 # RUN: wasm-ld main.o a.o b.a -o /dev/null --why-extract=why1.txt
13 # RUN: FileCheck %s --input-file=why1.txt --check-prefix=CHECK1 --match-full-lines --strict-whitespace
15 # CHECK1:reference extracted symbol
16 # CHECK1-NOT:{{.}}
18 ## Some archive members are extracted.
19 # RUN: wasm-ld main.o a_b.a b.a -o /dev/null --why-extract=why2.txt
20 # RUN: FileCheck %s --input-file=why2.txt --check-prefix=CHECK2 --match-full-lines --strict-whitespace
22 # CHECK2:reference extracted symbol
23 # CHECK2-NEXT:main.o a_b.a(a_b.o) a
24 # CHECK2-NEXT:a_b.a(a_b.o) b.a(b.o) b()
26 ## An undefined symbol error does not suppress the output.
27 # RUN: not wasm-ld main.o a_b.a -o /dev/null --why-extract=why3.txt
28 # RUN: FileCheck %s --input-file=why3.txt --check-prefix=CHECK3 --match-full-lines --strict-whitespace
30 ## Check that backward references are supported.
31 ## - means stdout.
32 # RUN: wasm-ld b.a a_b.a main.o -o /dev/null --why-extract=- | FileCheck %s --check-prefix=CHECK4
34 # CHECK3:reference extracted symbol
35 # CHECK3-NEXT:main.o a_b.a(a_b.o) a
37 # CHECK4:reference extracted symbol
38 # CHECK4-NEXT:a_b.a(a_b.o) b.a(b.o) b()
39 # CHECK4-NEXT:main.o a_b.a(a_b.o) a
41 # RUN: wasm-ld main.o a_b.a b.a -o /dev/null --no-demangle --why-extract=- | FileCheck %s --check-prefix=MANGLED
43 # MANGLED: a_b.a(a_b.o) b.a(b.o) _Z1bv
45 # RUN: wasm-ld main.o a.a b.a -o /dev/null -u _Z1bv --why-extract=- | FileCheck %s --check-prefix=UNDEFINED
47 ## We insert -u symbol before processing other files, so its name is <internal>.
48 ## This is not ideal.
49 # UNDEFINED: <internal> b.a(b.o) b()
51 # RUN: wasm-ld main.o a.a b.a -o /dev/null -e _Z1bv --why-extract=- | FileCheck %s --check-prefix=ENTRY
53 # ENTRY: --entry b.a(b.o) b()
55 # SCRIPT: <internal> b.a(b.o) b()
57 # RUN: not wasm-ld -shared main.o -o /dev/null --why-extract=/ 2>&1 | FileCheck %s --check-prefix=ERR
59 # ERR: error: cannot open --why-extract= file /: {{.*}}
61 #--- main.s
62 .globl _start
63 .functype a () -> ()
64 _start:
65 .functype _start () -> ()
66 call a
67 end_function
69 #--- a.s
70 .globl a
72 .functype a () -> ()
73 end_function
75 #--- a_b.s
76 .functype _Z1bv () -> ()
77 .globl a
79 .functype a () -> ()
80 call _Z1bv
81 end_function
83 #--- b.s
84 .globl _Z1bv
85 _Z1bv:
86 .functype _Z1bv () -> ()
87 end_function