Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / WebAssembly / external-func-address.ll
blob53ef1cfc1bb859d9b09ed5076ce7e92772105560
1 ; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
3 target triple = "wasm32-unknown-unknown"
5 ; Verify that addresses of external functions generate correctly typed
6 ; imports and relocations of type R_TABLE_INDEX_I32.
8 declare void @f0(i32) #0
9 @ptr_to_f0 = hidden global ptr @f0, align 4
11 attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" }
13 declare void @f1(i32) #1
14 @ptr_to_f1 = hidden global ptr @f1, align 4
16 ; Check that varargs functions have correctly typed imports
17 declare i32 @varargs(i32, i32, ...)
18 define void @call(i32) {
19  %a = call i32 (i32, i32, ...) @varargs(i32 0, i32 0)
20  ret void
23 ; CHECK:      --- !WASM
24 ; CHECK-NEXT: FileHeader:
25 ; CHECK-NEXT:   Version:         0x1
26 ; CHECK-NEXT: Sections:
27 ; CHECK-NEXT:   - Type:            TYPE
28 ; CHECK-NEXT:     Signatures:
29 ; CHECK-NEXT:       - Index:           0
30 ; CHECK-NEXT:         ParamTypes:
31 ; CHECK-NEXT:           - I32
32 ; CHECK-NEXT:         ReturnTypes:     []
33 ; CHECK-NEXT:       - Index:           1
34 ; CHECK-NEXT:         ParamTypes:
35 ; CHECK-NEXT:           - I32
36 ; CHECK-NEXT:           - I32
37 ; CHECK-NEXT:           - I32
38 ; CHECK-NEXT:         ReturnTypes:
39 ; CHECK-NEXT:           - I32
40 ; CHECK:        - Type:            IMPORT
41 ; CHECK-NEXT:     Imports:
42 ; CHECK:            - Module:          env
43 ; CHECK-NEXT:         Field:           __linear_memory
44 ; CHECK:            - Module:          env
45 ; CHECK-NEXT:         Field:           varargs
46 ; CHECK-NEXT:         Kind:            FUNCTION
47 ; CHECK-NEXT:         SigIndex:        1
48 ; CHECK:            - Module:          somewhere
49 ; CHECK-NEXT:         Field:           something
50 ; CHECK:            - Module:          env
51 ; CHECK-NEXT:         Field:           f1
52 ; CHECK-NEXT:         Kind:            FUNCTION
53 ; CHECK-NEXT:         SigIndex:        0
54 ; CHECK:            - Module:          env
55 ; CHECK-NEXT:         Field:           __indirect_function_table
56 ; CHECK:        - Type:            ELEM
57 ; CHECK-NEXT:     Segments:
58 ; CHECK-NEXT:       - Offset:
59 ; CHECK-NEXT:           Opcode:          I32_CONST
60 ; CHECK-NEXT:           Value:           1
61 ; CHECK-NEXT:         Functions:       [ 1, 2 ]
62 ; CHECK:        - Type:            DATA{{$}}
63 ; CHECK-NEXT:     Relocations:
64 ; CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_I32
65 ; CHECK-NEXT:         Index:           3
66 ; CHECK-NEXT:         Offset:          0x6