Index: lld/trunk/test/wasm/alias.ll =================================================================== --- lld/trunk/test/wasm/alias.ll +++ lld/trunk/test/wasm/alias.ll @@ -66,10 +66,10 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: start_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 @@ -82,7 +82,7 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/call-indirect.ll =================================================================== --- lld/trunk/test/wasm/call-indirect.ll +++ lld/trunk/test/wasm/call-indirect.ll @@ -57,7 +57,7 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - I32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 3, 1, 3, 4, 3 ] +; CHECK-NEXT: FunctionTypes: [ 3, 0, 3, 1, 3, 4 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -107,50 +107,50 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: bar ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: call_bar_indirect ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: foo ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: indirect_func ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 0, 2 ] +; CHECK-NEXT: Functions: [ 1, 3 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 42010B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: +; CHECK-NEXT: Body: 42010B +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 1 ; CHECK-NEXT: Body: 4100280284888080002100410028028088808000118080808000001A2000118180808000001A0B -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 410028028888808000118180808000001A0B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 42012000118280808000001A0B +; CHECK-NEXT: Body: 410028028888808000118180808000001A0B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 42012000118280808000001A0B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 @@ -163,10 +163,15 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: bar +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: call_bar_indirect +; CHECK-NEXT: Name: bar ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: foo +; CHECK-NEXT: Name: call_bar_indirect ; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: foo +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: Name: call_ptr +; CHECK-NEXT: ... Index: lld/trunk/test/wasm/comdats.ll =================================================================== --- lld/trunk/test/wasm/comdats.ll +++ lld/trunk/test/wasm/comdats.ll @@ -53,42 +53,42 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: inlineFn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: constantData ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: callInline1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: callInline2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1 ] +; CHECK-NEXT: Functions: [ 2 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180888080000B +; CHECK-NEXT: Body: 1082808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: Body: 4180888080000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 Index: lld/trunk/test/wasm/entry.ll =================================================================== --- lld/trunk/test/wasm/entry.ll +++ lld/trunk/test/wasm/entry.ll @@ -25,7 +25,7 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: entry ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Type: ; The __wasm_call_ctors is somewhat special. Make sure we can use it Index: lld/trunk/test/wasm/export.ll =================================================================== --- lld/trunk/test/wasm/export.ll +++ lld/trunk/test/wasm/export.ll @@ -30,8 +30,8 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: hidden_function ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Type: CODE Index: lld/trunk/test/wasm/function-imports-first.ll =================================================================== --- lld/trunk/test/wasm/function-imports-first.ll +++ lld/trunk/test/wasm/function-imports-first.ll @@ -24,25 +24,25 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - F32 ; CHECK: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 1 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 43000000001081808080001A0B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: Body: 43000000001082808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: ret32 +; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: ret32 ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/function-imports.ll =================================================================== --- lld/trunk/test/wasm/function-imports.ll +++ lld/trunk/test/wasm/function-imports.ll @@ -18,14 +18,14 @@ ; CHECK: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: -; CHECK-NEXT: - F32 ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - F32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK: - Index: 0 @@ -34,9 +34,9 @@ ; CHECK: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: ret32 +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: ret32 ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/gc-sections.ll =================================================================== --- lld/trunk/test/wasm/gc-sections.ll +++ lld/trunk/test/wasm/gc-sections.ll @@ -31,10 +31,10 @@ ; CHECK: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION @@ -48,13 +48,13 @@ ; CHECK-NEXT: Content: '02000000' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name -; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: used_function +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: used_function ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... ; RUN: wasm-ld -print-gc-sections --no-gc-sections -o %t1.no-gc.wasm %t.o @@ -63,13 +63,13 @@ ; NO-GC: - Type: TYPE ; NO-GC-NEXT: Signatures: ; NO-GC-NEXT: - Index: 0 -; NO-GC-NEXT: ReturnType: I64 -; NO-GC-NEXT: ParamTypes: +; NO-GC-NEXT: ReturnType: NORESULT +; NO-GC-NEXT: ParamTypes: ; NO-GC-NEXT: - Index: 1 -; NO-GC-NEXT: ReturnType: I32 +; NO-GC-NEXT: ReturnType: I64 ; NO-GC-NEXT: ParamTypes: ; NO-GC-NEXT: - Index: 2 -; NO-GC-NEXT: ReturnType: NORESULT +; NO-GC-NEXT: ReturnType: I32 ; NO-GC-NEXT: ParamTypes: ; NO-GC-NEXT: - Type: FUNCTION @@ -83,15 +83,15 @@ ; NO-GC-NEXT: Content: '010000000000000002000000' ; NO-GC-NEXT: - Type: CUSTOM ; NO-GC-NEXT: Name: name -; NO-GC-NEXT: FunctionNames: +; NO-GC-NEXT: FunctionNames: ; NO-GC-NEXT: - Index: 0 -; NO-GC-NEXT: Name: unused_function +; NO-GC-NEXT: Name: __wasm_call_ctors ; NO-GC-NEXT: - Index: 1 -; NO-GC-NEXT: Name: used_function +; NO-GC-NEXT: Name: unused_function ; NO-GC-NEXT: - Index: 2 -; NO-GC-NEXT: Name: _start +; NO-GC-NEXT: Name: used_function ; NO-GC-NEXT: - Index: 3 -; NO-GC-NEXT: Name: __wasm_call_ctors +; NO-GC-NEXT: Name: _start ; NO-GC-NEXT: ... ; RUN: not wasm-ld --gc-sections --relocatable -o %t1.no-gc.wasm %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR Index: lld/trunk/test/wasm/init-fini.ll =================================================================== --- lld/trunk/test/wasm/init-fini.ll +++ lld/trunk/test/wasm/init-fini.ll @@ -52,50 +52,56 @@ ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 6, 8, 12, 14, 16 ] - -; CHECK: Body: 100010011007100A100D100A100F10001009100A10110B +; CHECK-NEXT: Functions: [ 7, 9, 13, 15, 17 ] +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Locals: +; CHECK-NEXT: Body: 100110021008100B100E100B10101001100A100B10120B +; CHECK: - Index: 18 +; CHECK-NEXT: Locals: +; CHECK-NEXT: Body: 024041858080800041004180888080001085808080000D000F0B00000B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: func1 +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: func2 +; CHECK-NEXT: Name: func1 ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: func3 +; CHECK-NEXT: Name: func2 ; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: func4 +; CHECK-NEXT: Name: func3 ; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: __cxa_atexit +; CHECK-NEXT: Name: func4 ; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: __cxa_atexit ; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Name: .Lcall_dtors.101 +; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 7 -; CHECK-NEXT: Name: .Lregister_call_dtors.101 +; CHECK-NEXT: Name: .Lcall_dtors.101 ; CHECK-NEXT: - Index: 8 -; CHECK-NEXT: Name: .Lcall_dtors.1001 +; CHECK-NEXT: Name: .Lregister_call_dtors.101 ; CHECK-NEXT: - Index: 9 -; CHECK-NEXT: Name: .Lregister_call_dtors.1001 +; CHECK-NEXT: Name: .Lcall_dtors.1001 ; CHECK-NEXT: - Index: 10 -; CHECK-NEXT: Name: myctor +; CHECK-NEXT: Name: .Lregister_call_dtors.1001 ; CHECK-NEXT: - Index: 11 -; CHECK-NEXT: Name: mydtor +; CHECK-NEXT: Name: myctor ; CHECK-NEXT: - Index: 12 -; CHECK-NEXT: Name: .Lcall_dtors.101 +; CHECK-NEXT: Name: mydtor ; CHECK-NEXT: - Index: 13 -; CHECK-NEXT: Name: .Lregister_call_dtors.101 +; CHECK-NEXT: Name: .Lcall_dtors.101 ; CHECK-NEXT: - Index: 14 -; CHECK-NEXT: Name: .Lcall_dtors.202 +; CHECK-NEXT: Name: .Lregister_call_dtors.101 ; CHECK-NEXT: - Index: 15 -; CHECK-NEXT: Name: .Lregister_call_dtors.202 +; CHECK-NEXT: Name: .Lcall_dtors.202 ; CHECK-NEXT: - Index: 16 -; CHECK-NEXT: Name: .Lcall_dtors.2002 +; CHECK-NEXT: Name: .Lregister_call_dtors.202 ; CHECK-NEXT: - Index: 17 -; CHECK-NEXT: Name: .Lregister_call_dtors.2002 +; CHECK-NEXT: Name: .Lcall_dtors.2002 ; CHECK-NEXT: - Index: 18 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: .Lregister_call_dtors.2002 ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/load-undefined.test =================================================================== --- lld/trunk/test/wasm/load-undefined.test +++ lld/trunk/test/wasm/load-undefined.test @@ -21,13 +21,13 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: ret32 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: ret64 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Type: Index: lld/trunk/test/wasm/local-symbols.ll =================================================================== --- lld/trunk/test/wasm/local-symbols.ll +++ lld/trunk/test/wasm/local-symbols.ll @@ -26,13 +26,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -82,7 +82,7 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: foo ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 @@ -90,13 +90,13 @@ ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4100280284888080000B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1080808080001A0B +; CHECK-NEXT: Body: 4100280284888080000B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 1081808080001A0B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 @@ -109,9 +109,9 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: baz +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: baz ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/locals-duplicate.test =================================================================== --- lld/trunk/test/wasm/locals-duplicate.test +++ lld/trunk/test/wasm/locals-duplicate.test @@ -10,14 +10,14 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -; CHECK-NEXT: 0, 0, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +; CHECK-NEXT: 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -73,63 +73,63 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: colliding_func2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: get_global1A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: get_global2A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Name: colliding_global2 ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: get_global3A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 6 ; CHECK-NEXT: - Name: get_func1A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 6 +; CHECK-NEXT: Index: 7 ; CHECK-NEXT: - Name: get_func2A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 7 +; CHECK-NEXT: Index: 8 ; CHECK-NEXT: - Name: get_func3A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 8 +; CHECK-NEXT: Index: 9 ; CHECK-NEXT: - Name: colliding_func1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 9 +; CHECK-NEXT: Index: 10 ; CHECK-NEXT: - Name: get_global1B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 12 +; CHECK-NEXT: Index: 13 ; CHECK-NEXT: - Name: colliding_global1 ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: get_global2B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 13 +; CHECK-NEXT: Index: 14 ; CHECK-NEXT: - Name: get_global3B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 14 +; CHECK-NEXT: Index: 15 ; CHECK-NEXT: - Name: get_func1B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 15 +; CHECK-NEXT: Index: 16 ; CHECK-NEXT: - Name: get_func2B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 16 +; CHECK-NEXT: Index: 17 ; CHECK-NEXT: - Name: get_func3B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 17 +; CHECK-NEXT: Index: 18 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 0, 1, 2, 9, 10, 11 ] +; CHECK-NEXT: Functions: [ 1, 2, 3, 10, 11, 12 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B @@ -138,25 +138,25 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180888080000B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4184888080000B +; CHECK-NEXT: Body: 4180888080000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4188888080000B +; CHECK-NEXT: Body: 4184888080000B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: Body: 4188888080000B ; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4182808080000B +; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Index: 8 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4183808080000B +; CHECK-NEXT: Body: 4182808080000B ; CHECK-NEXT: - Index: 9 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: Body: 4183808080000B ; CHECK-NEXT: - Index: 10 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B @@ -165,25 +165,25 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 12 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 418C888080000B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 13 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4190888080000B +; CHECK-NEXT: Body: 418C888080000B ; CHECK-NEXT: - Index: 14 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4194888080000B +; CHECK-NEXT: Body: 4190888080000B ; CHECK-NEXT: - Index: 15 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4184808080000B +; CHECK-NEXT: Body: 4194888080000B ; CHECK-NEXT: - Index: 16 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4185808080000B +; CHECK-NEXT: Body: 4184808080000B ; CHECK-NEXT: - Index: 17 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4186808080000B +; CHECK-NEXT: Body: 4185808080000B ; CHECK-NEXT: - Index: 18 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 4186808080000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 @@ -196,43 +196,43 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: colliding_func1 +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: colliding_func2 +; CHECK-NEXT: Name: colliding_func1 ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: colliding_func3 +; CHECK-NEXT: Name: colliding_func2 ; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: get_global1A +; CHECK-NEXT: Name: colliding_func3 ; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: get_global2A +; CHECK-NEXT: Name: get_global1A ; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: get_global3A +; CHECK-NEXT: Name: get_global2A ; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Name: get_func1A +; CHECK-NEXT: Name: get_global3A ; CHECK-NEXT: - Index: 7 -; CHECK-NEXT: Name: get_func2A +; CHECK-NEXT: Name: get_func1A ; CHECK-NEXT: - Index: 8 -; CHECK-NEXT: Name: get_func3A +; CHECK-NEXT: Name: get_func2A ; CHECK-NEXT: - Index: 9 -; CHECK-NEXT: Name: colliding_func1 +; CHECK-NEXT: Name: get_func3A ; CHECK-NEXT: - Index: 10 -; CHECK-NEXT: Name: colliding_func2 +; CHECK-NEXT: Name: colliding_func1 ; CHECK-NEXT: - Index: 11 -; CHECK-NEXT: Name: colliding_func3 +; CHECK-NEXT: Name: colliding_func2 ; CHECK-NEXT: - Index: 12 -; CHECK-NEXT: Name: get_global1B +; CHECK-NEXT: Name: colliding_func3 ; CHECK-NEXT: - Index: 13 -; CHECK-NEXT: Name: get_global2B +; CHECK-NEXT: Name: get_global1B ; CHECK-NEXT: - Index: 14 -; CHECK-NEXT: Name: get_global3B +; CHECK-NEXT: Name: get_global2B ; CHECK-NEXT: - Index: 15 -; CHECK-NEXT: Name: get_func1B +; CHECK-NEXT: Name: get_global3B ; CHECK-NEXT: - Index: 16 -; CHECK-NEXT: Name: get_func2B +; CHECK-NEXT: Name: get_func1B ; CHECK-NEXT: - Index: 17 -; CHECK-NEXT: Name: get_func3B +; CHECK-NEXT: Name: get_func2B ; CHECK-NEXT: - Index: 18 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: get_func3B ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/undefined-weak-call.ll =================================================================== --- lld/trunk/test/wasm/undefined-weak-call.ll +++ lld/trunk/test/wasm/undefined-weak-call.ll @@ -29,17 +29,17 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - I32 ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: -; CHECK-NEXT: - I32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 2 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 1, 2 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -83,15 +83,15 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: callWeakFuncs ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 10828080800010838080800041021084808080004180808080004180808080006A0B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 000B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 000B @@ -100,18 +100,18 @@ ; CHECK-NEXT: Body: 000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 000B +; CHECK-NEXT: Body: 10818080800010828080800041021083808080004180808080004180808080006A0B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: callWeakFuncs -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: undefined function weakFunc1 -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: undefined function weakFunc2 -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: undefined function weakFunc3 +; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: Name: callWeakFuncs ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/visibility-hidden.ll =================================================================== --- lld/trunk/test/wasm/visibility-hidden.ll +++ lld/trunk/test/wasm/visibility-hidden.ll @@ -44,11 +44,11 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: objectDefault ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: archiveDefault ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Type: Index: lld/trunk/test/wasm/weak-alias-overide.ll =================================================================== --- lld/trunk/test/wasm/weak-alias-overide.ll +++ lld/trunk/test/wasm/weak-alias-overide.ll @@ -26,13 +26,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 0, 0, 0, 0, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 1, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -76,78 +76,78 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: alias_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: direct_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_direct ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: call_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Name: call_alias_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 6 ; CHECK-NEXT: - Name: call_direct_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 6 +; CHECK-NEXT: Index: 7 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 0, 2 ] +; CHECK-NEXT: Functions: [ 1, 3 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1080808080001A0B +; CHECK-NEXT: Body: 41010B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: Body: 1081808080001A0B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080000B +; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1080808080000B +; CHECK-NEXT: Body: 1083808080000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: - Type: I32 -; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081080808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 1081808080000B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004182808080003602081082808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B ; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Count: 2 +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004182808080003602081083808080002101200041106A24808080800020010B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: alias_fn +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: alias_fn ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: direct_fn +; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: call_direct +; CHECK-NEXT: Name: direct_fn ; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: call_alias +; CHECK-NEXT: Name: call_direct ; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: call_alias_ptr +; CHECK-NEXT: Name: call_alias ; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Name: call_direct_ptr +; CHECK-NEXT: Name: call_alias_ptr ; CHECK-NEXT: - Index: 7 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: call_direct_ptr ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/weak-alias.ll =================================================================== --- lld/trunk/test/wasm/weak-alias.ll +++ lld/trunk/test/wasm/weak-alias.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -73,75 +73,75 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: alias_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: direct_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: call_direct ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: call_alias_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Name: call_direct_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 6 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1 ] +; CHECK-NEXT: Functions: [ 2 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: Body: 1082808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080000B +; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080000B +; CHECK-NEXT: Body: 1082808080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: - Type: I32 -; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 1082808080000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Count: 2 +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: direct_fn +; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: call_direct +; CHECK-NEXT: Name: direct_fn ; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: call_alias +; CHECK-NEXT: Name: call_direct ; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: call_alias_ptr +; CHECK-NEXT: Name: call_alias ; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: call_direct_ptr +; CHECK-NEXT: Name: call_alias_ptr ; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: call_direct_ptr ; CHECK-NEXT: ... ; RUN: wasm-ld --check-signatures --relocatable %t.o %t2.o -o %t.reloc.o Index: lld/trunk/test/wasm/weak-symbols.ll =================================================================== --- lld/trunk/test/wasm/weak-symbols.ll +++ lld/trunk/test/wasm/weak-symbols.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -79,45 +79,45 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: weakFn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: exportWeak1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: weakGlobal ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: exportWeak2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1 ] +; CHECK-NEXT: Functions: [ 2 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: Body: 1082808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: Body: 41010B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 @@ -130,15 +130,15 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start +; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: weakFn +; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: exportWeak1 -; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: weakFn +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: exportWeak1 ; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: exportWeak2 +; CHECK-NEXT: Name: weakFn ; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: __wasm_call_ctors +; CHECK-NEXT: Name: exportWeak2 ; CHECK-NEXT: ... Index: lld/trunk/test/wasm/weak-undefined.ll =================================================================== --- lld/trunk/test/wasm/weak-undefined.ll +++ lld/trunk/test/wasm/weak-undefined.ll @@ -33,13 +33,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: ANYFUNC @@ -83,25 +83,25 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: get_address_of_foo ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: get_address_of_global_var ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180808080000B +; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4180808080000B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 4180808080000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 1082808080001A0B ; CHECK-NEXT: ... Index: lld/trunk/wasm/Writer.cpp =================================================================== --- lld/trunk/wasm/Writer.cpp +++ lld/trunk/wasm/Writer.cpp @@ -757,17 +757,15 @@ Func->setOutputIndex(FunctionIndex++); }; + for (InputFunction *Func : Symtab->SyntheticFunctions) + AddDefinedFunction(Func); + for (ObjFile *File : Symtab->ObjectFiles) { DEBUG(dbgs() << "Functions: " << File->getName() << "\n"); for (InputFunction *Func : File->Functions) AddDefinedFunction(Func); } - // TODO Move synthetic functions to come before (so __wasm_call_ctors can be - // compiled immediately by the browser). Will reorder tests. - for (InputFunction *Func : Symtab->SyntheticFunctions) - AddDefinedFunction(Func); - uint32_t TableIndex = kInitialTableOffset; auto HandleRelocs = [&](InputChunk *Chunk) { if (!Chunk->Live)