1 ; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
3 target triple = "wasm32-unknown-unknown"
5 ; Import a function just so we can check the index arithmetic for
6 ; WASM_COMDAT_FUNCTION entries is performed correctly
7 declare i32 @funcImport()
8 define i32 @callImport() {
10 %call = call i32 @funcImport()
14 ; Function in its own COMDAT
15 $basicInlineFn = comdat any
16 define linkonce_odr i32 @basicInlineFn() #1 comdat {
20 ; Global, data, and function in same COMDAT
21 $sharedComdat = comdat any
22 @constantData = weak_odr constant [3 x i8] c"abc", comdat($sharedComdat)
23 define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
28 ; CHECK-NEXT: - Type: TYPE
29 ; CHECK-NEXT: Signatures:
30 ; CHECK-NEXT: - Index: 0
31 ; CHECK-NEXT: ReturnType: I32
32 ; CHECK-NEXT: ParamTypes:
33 ; CHECK-NEXT: - Type: IMPORT
34 ; CHECK-NEXT: Imports:
35 ; CHECK-NEXT: - Module: env
36 ; CHECK-NEXT: Field: __linear_memory
37 ; CHECK-NEXT: Kind: MEMORY
39 ; CHECK-NEXT: Initial: 0x00000001
40 ; CHECK-NEXT: - Module: env
41 ; CHECK-NEXT: Field: __indirect_function_table
42 ; CHECK-NEXT: Kind: TABLE
44 ; CHECK-NEXT: ElemType: FUNCREF
46 ; CHECK-NEXT: Initial: 0x00000000
47 ; CHECK-NEXT: - Module: env
48 ; CHECK-NEXT: Field: funcImport
49 ; CHECK-NEXT: Kind: FUNCTION
50 ; CHECK-NEXT: SigIndex: 0
51 ; CHECK-NEXT: - Type: FUNCTION
52 ; CHECK-NEXT: FunctionTypes: [ 0, 0, 0 ]
53 ; CHECK-NEXT: - Type: DATACOUNT
54 ; CHECK-NEXT: Count: 1
55 ; CHECK-NEXT: - Type: CODE
56 ; CHECK-NEXT: Relocations:
57 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
58 ; CHECK-NEXT: Index: 1
59 ; CHECK-NEXT: Offset: 0x00000004
60 ; CHECK-NEXT: Functions:
61 ; CHECK-NEXT: - Index: 1
63 ; CHECK-NEXT: Body: 1080808080000B
64 ; CHECK-NEXT: - Index: 2
66 ; CHECK-NEXT: Body: 41000B
67 ; CHECK-NEXT: - Index: 3
69 ; CHECK-NEXT: Body: 41000B
70 ; CHECK-NEXT: - Type: DATA
71 ; CHECK-NEXT: Segments:
72 ; CHECK-NEXT: - SectionOffset: 6
73 ; CHECK-NEXT: InitFlags: 0
75 ; CHECK-NEXT: Opcode: I32_CONST
76 ; CHECK-NEXT: Value: 0
77 ; CHECK-NEXT: Content: '616263'
78 ; CHECK-NEXT: - Type: CUSTOM
79 ; CHECK-NEXT: Name: linking
80 ; CHECK-NEXT: Version: 2
81 ; CHECK-NEXT: SymbolTable:
82 ; CHECK-NEXT: - Index: 0
83 ; CHECK-NEXT: Kind: FUNCTION
84 ; CHECK-NEXT: Name: callImport
85 ; CHECK-NEXT: Flags: [ ]
86 ; CHECK-NEXT: Function: 1
87 ; CHECK-NEXT: - Index: 1
88 ; CHECK-NEXT: Kind: FUNCTION
89 ; CHECK-NEXT: Name: funcImport
90 ; CHECK-NEXT: Flags: [ UNDEFINED ]
91 ; CHECK-NEXT: Function: 0
92 ; CHECK-NEXT: - Index: 2
93 ; CHECK-NEXT: Kind: FUNCTION
94 ; CHECK-NEXT: Name: basicInlineFn
95 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
96 ; CHECK-NEXT: Function: 2
97 ; CHECK-NEXT: - Index: 3
98 ; CHECK-NEXT: Kind: FUNCTION
99 ; CHECK-NEXT: Name: sharedFn
100 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
101 ; CHECK-NEXT: Function: 3
102 ; CHECK-NEXT: - Index: 4
103 ; CHECK-NEXT: Kind: DATA
104 ; CHECK-NEXT: Name: constantData
105 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
106 ; CHECK-NEXT: Segment: 0
107 ; CHECK-NEXT: Size: 3
108 ; CHECK-NEXT: SegmentInfo:
109 ; CHECK-NEXT: - Index: 0
110 ; CHECK-NEXT: Name: .rodata.constantData
111 ; CHECK-NEXT: Alignment: 0
112 ; CHECK-NEXT: Flags: [ ]
113 ; CHECK-NEXT: Comdats:
114 ; CHECK-NEXT: Name: basicInlineFn
115 ; CHECK-NEXT: Entries:
116 ; CHECK-NEXT: - Kind: FUNCTION
117 ; CHECK-NEXT: Index: 2
118 ; CHECK-NEXT: Name: sharedComdat
119 ; CHECK-NEXT: Entries:
120 ; CHECK-NEXT: - Kind: FUNCTION
121 ; CHECK-NEXT: Index: 3
122 ; CHECK-NEXT: - Kind: DATA
123 ; CHECK-NEXT: Index: 0