2018-01-31 09:45:47 +08:00
|
|
|
; RUN: llc -filetype=obj %s -o %t.o
|
2018-04-21 01:28:12 +08:00
|
|
|
; RUN: yaml2obj %S/Inputs/globals.yaml -o %t_globals.o
|
|
|
|
; RUN: wasm-ld -print-gc-sections -o %t1.wasm %t.o %t_globals.o | \
|
|
|
|
; RUN: FileCheck %s -check-prefix=PRINT-GC
|
2018-02-20 06:29:48 +08:00
|
|
|
; PRINT-GC: removing unused section {{.*}}:(unused_function)
|
|
|
|
; PRINT-GC-NOT: removing unused section {{.*}}:(used_function)
|
|
|
|
; PRINT-GC: removing unused section {{.*}}:(.data.unused_data)
|
|
|
|
; PRINT-GC-NOT: removing unused section {{.*}}:(.data.used_data)
|
2018-04-21 01:28:12 +08:00
|
|
|
; PRINT-GC: removing unused section {{.*}}:(unused_global)
|
|
|
|
; PRINT-GC-NOT: removing unused section {{.*}}:(used_global)
|
2018-01-31 09:45:47 +08:00
|
|
|
|
2018-05-11 01:59:41 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2018-01-31 09:45:47 +08:00
|
|
|
|
2018-02-01 07:48:14 +08:00
|
|
|
@unused_data = hidden global i64 1, align 4
|
2018-01-31 09:45:47 +08:00
|
|
|
@used_data = hidden global i32 2, align 4
|
|
|
|
|
2018-04-21 01:28:12 +08:00
|
|
|
define hidden i64 @unused_function(i64 %arg) {
|
2018-02-01 07:48:14 +08:00
|
|
|
%1 = load i64, i64* @unused_data, align 4
|
|
|
|
ret i64 %1
|
2018-01-31 09:45:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define hidden i32 @used_function() {
|
|
|
|
%1 = load i32, i32* @used_data, align 4
|
|
|
|
ret i32 %1
|
|
|
|
}
|
|
|
|
|
2018-04-21 01:28:12 +08:00
|
|
|
declare i64 @use_global()
|
|
|
|
|
2018-01-31 09:45:47 +08:00
|
|
|
define hidden void @_start() {
|
|
|
|
entry:
|
|
|
|
call i32 @used_function()
|
2018-04-21 01:28:12 +08:00
|
|
|
call i64 @use_global()
|
2018-01-31 09:45:47 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; RUN: obj2yaml %t1.wasm | FileCheck %s
|
2018-02-01 07:48:14 +08:00
|
|
|
|
|
|
|
; CHECK: - Type: TYPE
|
2018-04-21 01:28:12 +08:00
|
|
|
; CHECK-NEXT: Signatures:
|
2018-02-01 07:48:14 +08:00
|
|
|
; CHECK-NEXT: - Index: 0
|
2019-10-19 04:27:30 +08:00
|
|
|
; CHECK-NEXT: ParamTypes: []
|
|
|
|
; CHECK-NEXT: ReturnTypes:
|
|
|
|
; CHECK-NEXT: - I32
|
2018-02-01 07:48:14 +08:00
|
|
|
; CHECK-NEXT: - Index: 1
|
2019-10-19 04:27:30 +08:00
|
|
|
; CHECK-NEXT: ParamTypes: []
|
|
|
|
; CHECK-NEXT: ReturnTypes: []
|
2018-04-21 01:28:12 +08:00
|
|
|
; CHECK-NEXT: - Index: 2
|
2019-10-19 04:27:30 +08:00
|
|
|
; CHECK-NEXT: ParamTypes: []
|
|
|
|
; CHECK-NEXT: ReturnTypes:
|
|
|
|
; CHECK-NEXT: - I64
|
2018-02-01 07:48:14 +08:00
|
|
|
; CHECK-NEXT: - Type: FUNCTION
|
|
|
|
|
2018-04-21 01:28:12 +08:00
|
|
|
; CHECK: - Type: GLOBAL
|
|
|
|
; CHECK-NEXT: Globals:
|
|
|
|
; CHECK-NEXT: - Index: 0
|
|
|
|
; CHECK-NEXT: Type: I32
|
|
|
|
; CHECK-NEXT: Mutable: true
|
|
|
|
; CHECK-NEXT: InitExpr:
|
|
|
|
; CHECK-NEXT: Opcode: I32_CONST
|
|
|
|
; CHECK-NEXT: Value: 66576
|
|
|
|
; CHECK-NEXT: - Index: 1
|
|
|
|
; CHECK-NEXT: Type: I64
|
|
|
|
; CHECK-NEXT: Mutable: true
|
|
|
|
; CHECK-NEXT: InitExpr:
|
|
|
|
; CHECK-NEXT: Opcode: I64_CONST
|
|
|
|
; CHECK-NEXT: Value: 456
|
|
|
|
|
2018-01-31 09:45:47 +08:00
|
|
|
; CHECK: - Type: DATA
|
2019-10-19 04:27:30 +08:00
|
|
|
; CHECK-NEXT: Segments:
|
2018-01-31 09:45:47 +08:00
|
|
|
; CHECK-NEXT: - SectionOffset: 7
|
2019-02-20 06:56:19 +08:00
|
|
|
; CHECK-NEXT: InitFlags: 0
|
|
|
|
; CHECK-NEXT: Offset:
|
2018-01-31 09:45:47 +08:00
|
|
|
; CHECK-NEXT: Opcode: I32_CONST
|
|
|
|
; CHECK-NEXT: Value: 1024
|
|
|
|
; CHECK-NEXT: Content: '02000000'
|
|
|
|
; CHECK-NEXT: - Type: CUSTOM
|
|
|
|
; CHECK-NEXT: Name: name
|
2018-03-12 23:44:07 +08:00
|
|
|
; CHECK-NEXT: FunctionNames:
|
2018-01-31 09:45:47 +08:00
|
|
|
; CHECK-NEXT: - Index: 0
|
2018-03-12 23:44:07 +08:00
|
|
|
; CHECK-NEXT: Name: used_function
|
2019-03-02 06:35:47 +08:00
|
|
|
; CHECK-NEXT: - Index: 1
|
2018-03-12 23:44:07 +08:00
|
|
|
; CHECK-NEXT: Name: _start
|
2019-03-02 06:35:47 +08:00
|
|
|
; CHECK-NEXT: - Index: 2
|
2018-04-21 01:28:12 +08:00
|
|
|
; CHECK-NEXT: Name: use_global
|
2018-01-31 09:45:47 +08:00
|
|
|
; CHECK-NEXT: ...
|
|
|
|
|
2018-04-21 01:28:12 +08:00
|
|
|
; RUN: wasm-ld -print-gc-sections --no-gc-sections -o %t1.no-gc.wasm \
|
|
|
|
; RUN: %t.o %t_globals.o
|
2018-01-31 09:45:47 +08:00
|
|
|
; RUN: obj2yaml %t1.no-gc.wasm | FileCheck %s -check-prefix=NO-GC
|
2018-02-01 07:48:14 +08:00
|
|
|
|
|
|
|
; NO-GC: - Type: TYPE
|
2018-04-21 01:28:12 +08:00
|
|
|
; NO-GC-NEXT: Signatures:
|
2018-02-01 07:48:14 +08:00
|
|
|
; NO-GC-NEXT: - Index: 0
|
2019-10-19 04:27:30 +08:00
|
|
|
; NO-GC-NEXT: ParamTypes: []
|
|
|
|
; NO-GC-NEXT: ReturnTypes: []
|
2018-02-01 07:48:14 +08:00
|
|
|
; NO-GC-NEXT: - Index: 1
|
2018-04-21 01:28:12 +08:00
|
|
|
; NO-GC-NEXT: ParamTypes:
|
|
|
|
; NO-GC-NEXT: - I64
|
2019-10-19 04:27:30 +08:00
|
|
|
; NO-GC-NEXT: ReturnTypes:
|
|
|
|
; NO-GC-NEXT: - I64
|
2018-02-01 07:48:14 +08:00
|
|
|
; NO-GC-NEXT: - Index: 2
|
2019-10-19 04:27:30 +08:00
|
|
|
; NO-GC-NEXT: ParamTypes: []
|
|
|
|
; NO-GC-NEXT: ReturnTypes:
|
|
|
|
; NO-GC-NEXT: - I32
|
2018-04-21 01:28:12 +08:00
|
|
|
; NO-GC-NEXT: - Index: 3
|
2019-10-19 04:27:30 +08:00
|
|
|
; NO-GC-NEXT: ParamTypes: []
|
|
|
|
; NO-GC-NEXT: ReturnTypes:
|
|
|
|
; NO-GC-NEXT: - I64
|
2018-02-01 07:48:14 +08:00
|
|
|
; NO-GC-NEXT: - Type: FUNCTION
|
|
|
|
|
2018-04-21 01:28:12 +08:00
|
|
|
; NO-GC: - Type: GLOBAL
|
|
|
|
; NO-GC-NEXT: Globals:
|
|
|
|
; NO-GC-NEXT: - Index: 0
|
|
|
|
; NO-GC-NEXT: Type: I32
|
|
|
|
; NO-GC-NEXT: Mutable: true
|
|
|
|
; NO-GC-NEXT: InitExpr:
|
|
|
|
; NO-GC-NEXT: Opcode: I32_CONST
|
|
|
|
; NO-GC-NEXT: Value: 66576
|
|
|
|
; NO-GC-NEXT: - Index: 1
|
|
|
|
; NO-GC-NEXT: Type: I64
|
|
|
|
; NO-GC-NEXT: Mutable: true
|
|
|
|
; NO-GC-NEXT: InitExpr:
|
|
|
|
; NO-GC-NEXT: Opcode: I64_CONST
|
|
|
|
; NO-GC-NEXT: Value: 123
|
|
|
|
; NO-GC-NEXT: - Index: 2
|
|
|
|
; NO-GC-NEXT: Type: I64
|
|
|
|
; NO-GC-NEXT: Mutable: true
|
|
|
|
; NO-GC-NEXT: InitExpr:
|
|
|
|
; NO-GC-NEXT: Opcode: I64_CONST
|
|
|
|
; NO-GC-NEXT: Value: 456
|
|
|
|
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC: - Type: DATA
|
2019-10-19 04:27:30 +08:00
|
|
|
; NO-GC-NEXT: Segments:
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - SectionOffset: 7
|
2019-02-20 06:56:19 +08:00
|
|
|
; NO-GC-NEXT: InitFlags: 0
|
|
|
|
; NO-GC-NEXT: Offset:
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: Opcode: I32_CONST
|
|
|
|
; NO-GC-NEXT: Value: 1024
|
2018-02-01 07:48:14 +08:00
|
|
|
; NO-GC-NEXT: Content: '010000000000000002000000'
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - Type: CUSTOM
|
|
|
|
; NO-GC-NEXT: Name: name
|
2018-03-12 23:44:07 +08:00
|
|
|
; NO-GC-NEXT: FunctionNames:
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - Index: 0
|
2018-03-12 23:44:07 +08:00
|
|
|
; NO-GC-NEXT: Name: __wasm_call_ctors
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - Index: 1
|
2018-03-12 23:44:07 +08:00
|
|
|
; NO-GC-NEXT: Name: unused_function
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - Index: 2
|
2018-03-12 23:44:07 +08:00
|
|
|
; NO-GC-NEXT: Name: used_function
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: - Index: 3
|
2018-03-12 23:44:07 +08:00
|
|
|
; NO-GC-NEXT: Name: _start
|
2018-04-21 01:28:12 +08:00
|
|
|
; NO-GC-NEXT: - Index: 4
|
|
|
|
; NO-GC-NEXT: Name: use_global
|
2018-01-31 09:45:47 +08:00
|
|
|
; NO-GC-NEXT: ...
|
|
|
|
|
2018-02-17 06:58:02 +08:00
|
|
|
; RUN: not wasm-ld --gc-sections --relocatable -o %t1.no-gc.wasm %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
|
2018-03-15 03:49:57 +08:00
|
|
|
; CHECK-ERROR: error: -r and --gc-sections may not be used together
|