1; RUN: llc -filetype=obj %s -o %t.o
2; RUN: wasm-ld --export=_Z3fooi --demangle -o %t_demangle.wasm %t.o
3; RUN: obj2yaml %t_demangle.wasm | FileCheck --check-prefixes=CHECK,DEMANGLE %s
4; RUN: wasm-ld --export=_Z3fooi --no-demangle -o %t_nodemangle.wasm %t.o
5; RUN: obj2yaml %t_nodemangle.wasm | FileCheck --check-prefixes=CHECK,MANGLE %s
6
7target triple = "wasm32-unknown-unknown"
8
9; Check that the EXPORT name is still mangled, but that the "name" custom
10; section contains the unmangled name.
11
12define void @_Z3fooi(i32 %arg) {
13  ret void
14}
15
16declare extern_weak void @_Z3bari(i32 %arg)
17
18define void @_start() {
19  call void @_Z3fooi(i32 1)
20  call void @_Z3bari(i32 1)
21  ret void
22}
23
24; CHECK:        - Type:            EXPORT
25; CHECK-NEXT:     Exports:
26; CHECK-NEXT:       - Name:            memory
27; CHECK-NEXT:         Kind:            MEMORY
28; CHECK-NEXT:         Index:           0
29; CHECK-NEXT:       - Name:            _Z3fooi
30; CHECK-NEXT:         Kind:            FUNCTION
31; CHECK-NEXT:         Index:           1
32; CHECK-NEXT:       - Name:            _start
33; CHECK-NEXT:         Kind:            FUNCTION
34; CHECK-NEXT:         Index:           2
35; CHECK-NEXT:   - Type:            CODE
36; CHECK-NEXT:     Functions:
37; CHECK-NEXT:       - Index:           0
38; CHECK-NEXT:         Locals:
39; CHECK-NEXT:         Body:            000B
40; CHECK-NEXT:       - Index:           1
41; CHECK-NEXT:         Locals:
42; CHECK-NEXT:         Body:            0B
43; CHECK-NEXT:       - Index:           2
44; CHECK-NEXT:         Locals:
45; CHECK-NEXT:         Body:            410110818080800041011080808080000B
46; CHECK-NEXT:   - Type:            CUSTOM
47; CHECK-NEXT:     Name:            name
48; CHECK-NEXT:     FunctionNames:
49; CHECK-NEXT:       - Index:           0
50; DEMANGLE-NEXT:      Name:            'undefined_weak:bar(int)'
51; MANGLE-NEXT:        Name:            'undefined_weak:_Z3bari'
52; CHECK-NEXT:       - Index:           1
53; DEMANGLE-NEXT:      Name:            'foo(int)'
54; MANGLE-NEXT:        Name:            _Z3fooi
55; CHECK-NEXT:       - Index:           2
56; CHECK-NEXT:         Name:            _start
57; CHECK-NEXT:     GlobalNames:
58; CHECK-NEXT:       - Index:           0
59; CHECK-NEXT:         Name:            __stack_pointer
60; CHECK-NEXT: ...
61