[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / test / MC / WebAssembly / weak-alias.ll
blobc9c707e69e2a3e9f51055fb6783623349a133119
1 ; RUN: llc -filetype=obj -wasm-keep-registers %s -o %t.o
2 ; RUN: obj2yaml %t.o | FileCheck %s
3 ; RUN: llvm-objdump -t %t.o | FileCheck --check-prefix=CHECK-SYMS %s
5 target triple = "wasm32-unknown-unknown"
7 ; 'foo_alias()' is weak alias of function 'foo()'
8 ; 'bar_alias' is weak alias of global variable 'bar'
9 ; Generates two exports of the same function, one of them weak
11 @bar = global i32 7, align 8
12 @bar_alias = weak hidden alias i32, i32* @bar
13 @foo_alias = weak hidden alias i32 (), i32 ()* @foo
15 @direct_address = global i32()* @foo, align 8
16 @alias_address = global i32()* @foo_alias, align 8
18 define hidden i32 @foo() #0 {
19 entry:
20   ret i32 0
23 define hidden i32 @call_direct() #0 {
24 entry:
25   %call = call i32 @foo()
26   ret i32 %call
29 define hidden i32 @call_alias() #0 {
30 entry:
31   %call = call i32 @foo_alias()
32   ret i32 %call
35 define hidden i32 @call_direct_ptr() #0 {
36 entry:
37   %0 = load i32 ()*, i32 ()** @direct_address, align 8
38   %call = call i32 %0()
39   ret i32 %call
42 define hidden i32 @call_alias_ptr() #0 {
43 entry:
44   %0 = load i32 ()*, i32 ()** @alias_address, align 8
45   %call = call i32 %0()
46   ret i32 %call
49 ; CHECK:        - Type:            TYPE
50 ; CHECK-NEXT:     Signatures:
51 ; CHECK-NEXT:       - Index:           0
52 ; CHECK-NEXT:         ParamTypes:
53 ; CHECK-NEXT:         ReturnTypes:
54 ; CHECK-NEXT:           - I32
55 ; CHECK-NEXT:   - Type:            IMPORT
56 ; CHECK-NEXT:     Imports:
57 ; CHECK-NEXT:       - Module:          env
58 ; CHECK-NEXT:         Field:           __linear_memory
59 ; CHECK-NEXT:         Kind:            MEMORY
60 ; CHECK-NEXT:         Memory:
61 ; CHECK-NEXT:           Initial:         0x00000001
62 ; CHECK-NEXT:       - Module:          env
63 ; CHECK-NEXT:         Field:           __indirect_function_table
64 ; CHECK-NEXT:         Kind:            TABLE
65 ; CHECK-NEXT:         Table:
66 ; CHECK-NEXT:           ElemType:        FUNCREF
67 ; CHECK-NEXT:           Limits:
68 ; CHECK-NEXT:             Initial:         0x00000001
69 ; CHECK-NEXT:   - Type:            FUNCTION
70 ; CHECK-NEXT:     FunctionTypes:   [ 0, 0, 0, 0, 0 ]
71 ; CHECK-NEXT:   - Type:            ELEM
72 ; CHECK-NEXT:     Segments:
73 ; CHECK-NEXT:       - Offset:
74 ; CHECK-NEXT:           Opcode:          I32_CONST
75 ; CHECK-NEXT:           Value:           1
76 ; CHECK-NEXT:         Functions:       [ 0 ]
77 ; CHECK-NEXT:   - Type:            DATACOUNT
78 ; CHECK-NEXT:     Count:           3
79 ; CHECK-NEXT:   - Type:            CODE
80 ; CHECK-NEXT:     Relocations:
81 ; CHECK-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
82 ; CHECK-NEXT:         Index:           0
83 ; CHECK-NEXT:         Offset:          0x00000009
84 ; CHECK-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
85 ; CHECK-NEXT:         Index:           3
86 ; CHECK-NEXT:         Offset:          0x00000012
87 ; CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
88 ; CHECK-NEXT:         Index:           5
89 ; CHECK-NEXT:         Offset:          0x0000001E
90 ; CHECK-NEXT:       - Type:            R_WASM_TYPE_INDEX_LEB
91 ; CHECK-NEXT:         Index:           0
92 ; CHECK-NEXT:         Offset:          0x00000024
93 ; CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
94 ; CHECK-NEXT:         Index:           7
95 ; CHECK-NEXT:         Offset:          0x00000031
96 ; CHECK-NEXT:       - Type:            R_WASM_TYPE_INDEX_LEB
97 ; CHECK-NEXT:         Index:           0
98 ; CHECK-NEXT:         Offset:          0x00000037
99 ; CHECK-NEXT:     Functions:
100 ; CHECK-NEXT:       - Index:           0
101 ; CHECK-NEXT:         Locals:
102 ; CHECK-NEXT:         Body:            41000B
103 ; CHECK-NEXT:       - Index:           1
104 ; CHECK-NEXT:         Locals:
105 ; CHECK-NEXT:         Body:            1080808080000B
106 ; CHECK-NEXT:       - Index:           2
107 ; CHECK-NEXT:         Locals:
108 ; CHECK-NEXT:         Body:            1080808080000B
109 ; CHECK-NEXT:       - Index:           3
110 ; CHECK-NEXT:         Locals:
111 ; CHECK-NEXT:         Body:            410028028880808000118080808000000B
112 ; CHECK-NEXT:       - Index:           4
113 ; CHECK-NEXT:         Locals:
114 ; CHECK-NEXT:         Body:            410028029080808000118080808000000B
115 ; CHECK-NEXT:   - Type:            DATA
116 ; CHECK-NEXT:     Relocations:
117 ; CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_I32
118 ; CHECK-NEXT:         Index:           0
119 ; CHECK-NEXT:         Offset:          0x0000000F
120 ; CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_I32
121 ; CHECK-NEXT:         Index:           3
122 ; CHECK-NEXT:         Offset:          0x00000018
123 ; CHECK-NEXT:     Segments:
124 ; CHECK-NEXT:       - SectionOffset:   6
125 ; CHECK-NEXT:         InitFlags:       0
126 ; CHECK-NEXT:         Offset:
127 ; CHECK-NEXT:           Opcode:          I32_CONST
128 ; CHECK-NEXT:           Value:           0
129 ; CHECK-NEXT:         Content:         '07000000'
130 ; CHECK-NEXT:       - SectionOffset:   15
131 ; CHECK-NEXT:         InitFlags:       0
132 ; CHECK-NEXT:         Offset:
133 ; CHECK-NEXT:           Opcode:          I32_CONST
134 ; CHECK-NEXT:           Value:           8
135 ; CHECK-NEXT:         Content:         '01000000'
136 ; CHECK-NEXT:       - SectionOffset:   24
137 ; CHECK-NEXT:         InitFlags:       0
138 ; CHECK-NEXT:         Offset:
139 ; CHECK-NEXT:           Opcode:          I32_CONST
140 ; CHECK-NEXT:           Value:           16
141 ; CHECK-NEXT:         Content:         '01000000'
142 ; CHECK-NEXT:   - Type:            CUSTOM
143 ; CHECK-NEXT:     Name:            linking
144 ; CHECK-NEXT:     Version:         2
145 ; CHECK-NEXT:     SymbolTable:
146 ; CHECK-NEXT:       - Index:           0
147 ; CHECK-NEXT:         Kind:            FUNCTION
148 ; CHECK-NEXT:         Name:            foo
149 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
150 ; CHECK-NEXT:         Function:        0
151 ; CHECK-NEXT:       - Index:           1
152 ; CHECK-NEXT:         Kind:            FUNCTION
153 ; CHECK-NEXT:         Name:            call_direct
154 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
155 ; CHECK-NEXT:         Function:        1
156 ; CHECK-NEXT:       - Index:           2
157 ; CHECK-NEXT:         Kind:            FUNCTION
158 ; CHECK-NEXT:         Name:            call_alias
159 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
160 ; CHECK-NEXT:         Function:        2
161 ; CHECK-NEXT:       - Index:           3
162 ; CHECK-NEXT:         Kind:            FUNCTION
163 ; CHECK-NEXT:         Name:            foo_alias
164 ; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN ]
165 ; CHECK-NEXT:         Function:        0
166 ; CHECK-NEXT:       - Index:           4
167 ; CHECK-NEXT:         Kind:            FUNCTION
168 ; CHECK-NEXT:         Name:            call_direct_ptr
169 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
170 ; CHECK-NEXT:         Function:        3
171 ; CHECK-NEXT:       - Index:           5
172 ; CHECK-NEXT:         Kind:            DATA
173 ; CHECK-NEXT:         Name:            direct_address
174 ; CHECK-NEXT:         Flags:           [  ]
175 ; CHECK-NEXT:         Segment:         1
176 ; CHECK-NEXT:         Size:            4
177 ; CHECK-NEXT:       - Index:           6
178 ; CHECK-NEXT:         Kind:            FUNCTION
179 ; CHECK-NEXT:         Name:            call_alias_ptr
180 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
181 ; CHECK-NEXT:         Function:        4
182 ; CHECK-NEXT:       - Index:           7
183 ; CHECK-NEXT:         Kind:            DATA
184 ; CHECK-NEXT:         Name:            alias_address
185 ; CHECK-NEXT:         Flags:           [  ]
186 ; CHECK-NEXT:         Segment:         2
187 ; CHECK-NEXT:         Size:            4
188 ; CHECK-NEXT:       - Index:           8
189 ; CHECK-NEXT:         Kind:            DATA
190 ; CHECK-NEXT:         Name:            bar
191 ; CHECK-NEXT:         Flags:           [  ]
192 ; CHECK-NEXT:         Segment:         0
193 ; CHECK-NEXT:         Size:            4
194 ; CHECK-NEXT:       - Index:           9
195 ; CHECK-NEXT:         Kind:            DATA
196 ; CHECK-NEXT:         Name:            bar_alias
197 ; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN ]
198 ; CHECK-NEXT:         Segment:         0
199 ; CHECK-NEXT:         Size:            4
200 ; CHECK-NEXT:     SegmentInfo:
201 ; CHECK-NEXT:       - Index:           0
202 ; CHECK-NEXT:         Name:            .data.bar
203 ; CHECK-NEXT:         Alignment:       3
204 ; CHECK-NEXT:         Flags:           [ ]
205 ; CHECK-NEXT:       - Index:           1
206 ; CHECK-NEXT:         Name:            .data.direct_address
207 ; CHECK-NEXT:         Alignment:       3
208 ; CHECK-NEXT:         Flags:           [ ]
209 ; CHECK-NEXT:       - Index:           2
210 ; CHECK-NEXT:         Name:            .data.alias_address
211 ; CHECK-NEXT:         Alignment:       3
212 ; CHECK-NEXT:         Flags:           [ ]
213 ; CHECK-NEXT: ...
215 ; CHECK-SYMS: SYMBOL TABLE:
216 ; CHECK-SYMS-NEXT: 00000001 g     F CODE        .hidden foo
217 ; CHECK-SYMS-NEXT: 00000006 g     F CODE        .hidden call_direct
218 ; CHECK-SYMS-NEXT: 0000000f g     F CODE        .hidden call_alias
219 ; CHECK-SYMS-NEXT: 00000001 gw    F CODE        .hidden foo_alias
220 ; CHECK-SYMS-NEXT: 00000018 g     F CODE        .hidden call_direct_ptr
221 ; CHECK-SYMS-NEXT: 00000008 g     O DATA        direct_address
222 ; CHECK-SYMS-NEXT: 0000002b g     F CODE        .hidden call_alias_ptr
223 ; CHECK-SYMS-NEXT: 00000010 g     O DATA        alias_address
224 ; CHECK-SYMS-NEXT: 00000000 g     O DATA        bar
225 ; CHECK-SYMS-NEXT: 00000000 gw    O DATA        .hidden bar_alias