1; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
2; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/call-ret32.s -o %t.call.o
3; RUN: llc -filetype=obj %s -o %t.main.o
4
5; RUN: wasm-ld --export=call_ret32 --export=ret32 -o %t.wasm %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=WARN
6; RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=YAML
7
8; RUN: wasm-ld -r -o %t.reloc.o %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=WARN
9; RUN: obj2yaml %t.reloc.o | FileCheck %s -check-prefix=RELOC
10
11; RUN: not wasm-ld --fatal-warnings -o %t.wasm %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=ERROR
12
13target triple = "wasm32-unknown-unknown"
14
15@ret32_address_main = global i32 (i32, i64, i32)* @ret32, align 4
16
17; Function Attrs: nounwind
18define hidden void @_start() local_unnamed_addr {
19entry:
20  %call1 = call i32 @ret32(i32 1, i64 2, i32 3)
21  %addr = load i32 (i32, i64, i32)*, i32 (i32, i64, i32)** @ret32_address_main, align 4
22  %call2 = call i32 %addr(i32 1, i64 2, i32 3)
23  ret void
24}
25
26declare i32 @ret32(i32, i64, i32) local_unnamed_addr
27
28; WARN: warning: function signature mismatch: ret32
29; WARN-NEXT: >>> defined as (i32, i64, i32) -> i32 in {{.*}}.main.o
30; WARN-NEXT: >>> defined as (f32) -> i32 in {{.*}}.ret32.o
31
32; ERROR: error: function signature mismatch: ret32
33; ERROR-NEXT: >>> defined as (i32, i64, i32) -> i32 in {{.*}}.main.o
34; ERROR-NEXT: >>> defined as (f32) -> i32 in {{.*}}.ret32.o
35
36; YAML:        - Type:            EXPORT
37; YAML:           - Name:            ret32
38; YAML-NEXT:        Kind:            FUNCTION
39; YAML-NEXT:        Index:           2
40; YAML-NEXT:      - Name:            call_ret32
41; YAML-NEXT:        Kind:            FUNCTION
42; YAML-NEXT:        Index:           3
43
44; YAML:        - Type:            CUSTOM
45; YAML-NEXT:     Name:            name
46; YAML-NEXT:     FunctionNames:
47; YAML-NEXT:       - Index:           0
48; YAML-NEXT:         Name:            'signature_mismatch:ret32'
49; YAML-NEXT:       - Index:           1
50; YAML-NEXT:         Name:            _start
51; YAML-NEXT:       - Index:           2
52; YAML-NEXT:         Name:            ret32
53; YAML-NEXT:       - Index:           3
54; YAML-NEXT:         Name:            call_ret32
55; YAML-NEXT:     GlobalNames:
56; YAML-NEXT:       - Index:           0
57; YAML-NEXT:         Name:            __stack_pointer
58; YAML-NEXT:     DataSegmentNames:
59; YAML-NEXT:       - Index:           0
60; YAML-NEXT:         Name:            .data
61; YAML-NEXT: ...
62
63;      RELOC:     Name:            linking
64; RELOC-NEXT:     Version:         2
65; RELOC-NEXT:     SymbolTable:
66; RELOC-NEXT:       - Index:           0
67; RELOC-NEXT:         Kind:            FUNCTION
68; RELOC-NEXT:         Name:            _start
69; RELOC-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
70; RELOC-NEXT:         Function:        1
71; RELOC-NEXT:       - Index:           1
72; RELOC-NEXT:         Kind:            FUNCTION
73; RELOC-NEXT:         Name:            ret32
74; RELOC-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
75; RELOC-NEXT:         Function:        2
76; RELOC-NEXT:       - Index:           2
77; RELOC-NEXT:         Kind:            DATA
78; RELOC-NEXT:         Name:            ret32_address_main
79; RELOC-NEXT:         Flags:           [  ]
80; RELOC-NEXT:         Segment:         0
81; RELOC-NEXT:         Size:            4
82; RELOC-NEXT:       - Index:           3
83; RELOC-NEXT:         Kind:            TABLE
84; RELOC-NEXT:         Name:            __indirect_function_table
85; RELOC-NEXT:         Flags:           [ UNDEFINED, NO_STRIP ]
86; RELOC-NEXT:         Table:           0
87; RELOC-NEXT:       - Index:           4
88; RELOC-NEXT:         Kind:            FUNCTION
89; RELOC-NEXT:         Name:            call_ret32
90; RELOC-NEXT:         Flags:           [ ]
91; RELOC-NEXT:         Function:        3
92; RELOC-NEXT:       - Index:           5
93; RELOC-NEXT:         Kind:            DATA
94; RELOC-NEXT:         Name:            ret32_address
95; RELOC-NEXT:         Flags:           [  ]
96; RELOC-NEXT:         Segment:         1
97; RELOC-NEXT:         Size:            4
98; RELOC-NEXT:       - Index:           6
99; RELOC-NEXT:         Kind:            FUNCTION
100; RELOC-NEXT:         Name:            'signature_mismatch:ret32'
101; RELOC-NEXT:         Flags:           [ BINDING_LOCAL ]
102; RELOC-NEXT:         Function:        0
103