1 ; RUN: llc -mcpu=mvp -filetype=obj %s -o - | obj2yaml | FileCheck %s
2 ; RUN: llc -mcpu=mvp -filetype=asm %s -asm-verbose=false -o - | FileCheck --check-prefix=ASM %s
3 ; RUN: llc -mcpu=mvp -filetype=asm %s -o - | llvm-mc -triple=wasm32 -filetype=obj -o - | obj2yaml | FileCheck %s
4 ; These RUN lines verify the ll direct-to-object path, the ll->asm path, and the
5 ; object output via asm.
7 target triple = "wasm32-unknown-unknown"
9 ; Import a function just so we can check the index arithmetic for
10 ; WASM_COMDAT_FUNCTION entries is performed correctly
11 declare i32 @funcImport()
12 define i32 @callImport() {
14 %call = call i32 @funcImport()
18 ; Function in its own COMDAT
19 $basicInlineFn = comdat any
20 define linkonce_odr i32 @basicInlineFn() #1 comdat {
24 ; Global, data, and function in same COMDAT
25 $sharedComdat = comdat any
26 @constantData = weak_odr constant [3 x i8] c"abc", comdat($sharedComdat)
27 define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
32 ; CHECK-NEXT: - Type: TYPE
33 ; CHECK-NEXT: Signatures:
34 ; CHECK-NEXT: - Index: 0
35 ; CHECK-NEXT: ParamTypes: []
36 ; CHECK-NEXT: ReturnTypes:
38 ; CHECK-NEXT: - Type: IMPORT
39 ; CHECK-NEXT: Imports:
40 ; CHECK-NEXT: - Module: env
41 ; CHECK-NEXT: Field: __linear_memory
42 ; CHECK-NEXT: Kind: MEMORY
44 ; CHECK-NEXT: Minimum: 0x1
45 ; CHECK-NEXT: - Module: env
46 ; CHECK-NEXT: Field: funcImport
47 ; CHECK-NEXT: Kind: FUNCTION
48 ; CHECK-NEXT: SigIndex: 0
49 ; CHECK-NEXT: - Type: FUNCTION
50 ; CHECK-NEXT: FunctionTypes: [ 0, 0, 0 ]
51 ; CHECK-NEXT: - Type: DATACOUNT
52 ; CHECK-NEXT: Count: 1
53 ; CHECK-NEXT: - Type: CODE
54 ; CHECK-NEXT: Relocations:
55 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
56 ; CHECK-NEXT: Index: 1
57 ; CHECK-NEXT: Offset: 0x4
58 ; CHECK-NEXT: Functions:
59 ; CHECK-NEXT: - Index: 1
61 ; CHECK-NEXT: Body: 1080808080000B
62 ; CHECK-NEXT: - Index: 2
64 ; CHECK-NEXT: Body: 41000B
65 ; CHECK-NEXT: - Index: 3
67 ; CHECK-NEXT: Body: 41000B
68 ; CHECK-NEXT: - Type: DATA
69 ; CHECK-NEXT: Segments:
70 ; CHECK-NEXT: - SectionOffset: 6
71 ; CHECK-NEXT: InitFlags: 0
73 ; CHECK-NEXT: Opcode: I32_CONST
74 ; CHECK-NEXT: Value: 0
75 ; CHECK-NEXT: Content: '616263'
76 ; CHECK-NEXT: - Type: CUSTOM
77 ; CHECK-NEXT: Name: linking
78 ; CHECK-NEXT: Version: 2
79 ; CHECK-NEXT: SymbolTable:
80 ; CHECK-NEXT: - Index: 0
81 ; CHECK-NEXT: Kind: FUNCTION
82 ; CHECK-NEXT: Name: callImport
83 ; CHECK-NEXT: Flags: [ ]
84 ; CHECK-NEXT: Function: 1
85 ; CHECK-NEXT: - Index: 1
86 ; CHECK-NEXT: Kind: FUNCTION
87 ; CHECK-NEXT: Name: funcImport
88 ; CHECK-NEXT: Flags: [ UNDEFINED ]
89 ; CHECK-NEXT: Function: 0
90 ; CHECK-NEXT: - Index: 2
91 ; CHECK-NEXT: Kind: FUNCTION
92 ; CHECK-NEXT: Name: basicInlineFn
93 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
94 ; CHECK-NEXT: Function: 2
95 ; CHECK-NEXT: - Index: 3
96 ; CHECK-NEXT: Kind: FUNCTION
97 ; CHECK-NEXT: Name: sharedFn
98 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
99 ; CHECK-NEXT: Function: 3
100 ; CHECK-NEXT: - Index: 4
101 ; CHECK-NEXT: Kind: DATA
102 ; CHECK-NEXT: Name: constantData
103 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
104 ; CHECK-NEXT: Segment: 0
105 ; CHECK-NEXT: Size: 3
106 ; CHECK-NEXT: SegmentInfo:
107 ; CHECK-NEXT: - Index: 0
108 ; CHECK-NEXT: Name: .rodata.constantData
109 ; CHECK-NEXT: Alignment: 0
110 ; CHECK-NEXT: Flags: [ ]
111 ; CHECK-NEXT: Comdats:
112 ; CHECK-NEXT: Name: basicInlineFn
113 ; CHECK-NEXT: Entries:
114 ; CHECK-NEXT: - Kind: FUNCTION
115 ; CHECK-NEXT: Index: 2
116 ; CHECK-NEXT: Name: sharedComdat
117 ; CHECK-NEXT: Entries:
118 ; CHECK-NEXT: - Kind: FUNCTION
119 ; CHECK-NEXT: Index: 3
120 ; CHECK-NEXT: - Kind: DATA
121 ; CHECK-NEXT: Index: 0
125 ; ASM: .section .text.basicInlineFn,"G",@,basicInlineFn,comdat
126 ; ASM-NEXT: .weak basicInlineFn
127 ; ASM-NEXT: .type basicInlineFn,@function
128 ; ASM-NEXT: basicInlineFn:
130 ; ASM: .section .text.sharedFn,"G",@,sharedComdat,comdat
131 ; ASM-NEXT: .weak sharedFn
132 ; ASM-NEXT: .type sharedFn,@function
133 ; ASM-NEXT: sharedFn:
135 ; ASM: .type constantData,@object
136 ; ASM-NEXT: .section .rodata.constantData,"G",@,sharedComdat,comdat
137 ; ASM-NEXT: .weak constantData
138 ; ASM-NEXT: constantData: