1; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s 2 3target triple = "wasm32-unknown-unknown" 4 5; Import a function just so we can check the index arithmetic for 6; WASM_COMDAT_FUNCTION entries is performed correctly 7declare i32 @funcImport() 8define i32 @callImport() { 9entry: 10 %call = call i32 @funcImport() 11 ret i32 %call 12} 13 14; Function in its own COMDAT 15$basicInlineFn = comdat any 16define linkonce_odr i32 @basicInlineFn() #1 comdat { 17 ret i32 0 18} 19 20; Global, data, and function in same COMDAT 21$sharedComdat = comdat any 22@constantData = weak_odr constant [3 x i8] c"abc", comdat($sharedComdat) 23define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) { 24 ret i32 0 25} 26 27; CHECK: Sections: 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 38; CHECK-NEXT: Memory: 39; CHECK-NEXT: Initial: 0x00000001 40; CHECK-NEXT: - Module: env 41; CHECK-NEXT: Field: __indirect_function_table 42; CHECK-NEXT: Kind: TABLE 43; CHECK-NEXT: Table: 44; CHECK-NEXT: ElemType: ANYFUNC 45; CHECK-NEXT: Limits: 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: CODE 54; CHECK-NEXT: Relocations: 55; CHECK-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 56; CHECK-NEXT: Index: 1 57; CHECK-NEXT: Offset: 0x00000004 58; CHECK-NEXT: Functions: 59; CHECK-NEXT: - Index: 1 60; CHECK-NEXT: Locals: 61; CHECK-NEXT: Body: 1080808080000B 62; CHECK-NEXT: - Index: 2 63; CHECK-NEXT: Locals: 64; CHECK-NEXT: Body: 41000B 65; CHECK-NEXT: - Index: 3 66; CHECK-NEXT: Locals: 67; CHECK-NEXT: Body: 41000B 68; CHECK-NEXT: - Type: DATA 69; CHECK-NEXT: Segments: 70; CHECK-NEXT: - SectionOffset: 6 71; CHECK-NEXT: MemoryIndex: 0 72; CHECK-NEXT: Offset: 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: 1 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: 1 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 122; CHECK-NEXT: ... 123