[lld] 70aa111 - [lld][WebAssembly] Convert a bunch more tests to asm. NFC
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 16:30:17 PST 2022
Author: Sam Clegg
Date: 2022-02-18T16:30:08-08:00
New Revision: 70aa11187e5c7ecca327356569dbb2e56f06cbe0
URL: https://github.com/llvm/llvm-project/commit/70aa11187e5c7ecca327356569dbb2e56f06cbe0
DIFF: https://github.com/llvm/llvm-project/commit/70aa11187e5c7ecca327356569dbb2e56f06cbe0.diff
LOG: [lld][WebAssembly] Convert a bunch more tests to asm. NFC
Differential Revision: https://reviews.llvm.org/D120060
Added:
lld/test/wasm/archive-export.test
lld/test/wasm/call-indirect.s
lld/test/wasm/driver.s
lld/test/wasm/entry.s
lld/test/wasm/fatal-warnings.s
lld/test/wasm/function-imports.s
lld/test/wasm/stack-pointer.s
lld/test/wasm/trace-symbol.s
Modified:
Removed:
lld/test/wasm/archive-export.ll
lld/test/wasm/call-indirect.ll
lld/test/wasm/driver.ll
lld/test/wasm/entry.ll
lld/test/wasm/fatal-warnings.ll
lld/test/wasm/function-imports.ll
lld/test/wasm/stack-pointer.ll
lld/test/wasm/trace-symbol.ll
################################################################################
diff --git a/lld/test/wasm/archive-export.ll b/lld/test/wasm/archive-export.test
similarity index 100%
rename from lld/test/wasm/archive-export.ll
rename to lld/test/wasm/archive-export.test
diff --git a/lld/test/wasm/call-indirect.ll b/lld/test/wasm/call-indirect.ll
deleted file mode 100644
index 31e2c75864554..0000000000000
--- a/lld/test/wasm/call-indirect.ll
+++ /dev/null
@@ -1,162 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/call-indirect.s -o %t2.o
-; RUN: wasm-ld --export-dynamic -o %t.wasm %t2.o %t.o
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-; bitcode generated from the following C code:
-; int foo(void) { return 1; }
-; int (*indirect_func)(void) = &foo;
-; void _start(void) { indirect_func(); }
-
-target triple = "wasm32-unknown-unknown"
-
- at indirect_func = local_unnamed_addr global i32 ()* @foo, align 4
-
-; Function Attrs: norecurse nounwind readnone
-define i32 @foo() #0 {
-entry:
- ret i32 2
-}
-
-; Function Attrs: nounwind
-define void @_start() local_unnamed_addr #1 {
-entry:
- %0 = load i32 ()*, i32 ()** @indirect_func, align 4
- %call = call i32 %0() #2
- ret void
-}
-
-; Indirect function call where no function actually has this type.
-; Ensures that the type entry is still created in this case.
-define void @call_ptr(i64 (i64)* %arg) {
- %1 = call i64 %arg(i64 1)
- ret void
-}
-
-; CHECK: !WASM
-; CHECK-NEXT: FileHeader:
-; CHECK-NEXT: Version: 0x1
-; CHECK-NEXT: Sections:
-; CHECK-NEXT: - Type: TYPE
-; CHECK-NEXT: Signatures:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: ReturnTypes:
-; CHECK-NEXT: - I64
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: ReturnTypes:
-; CHECK-NEXT: - I32
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: - I64
-; CHECK-NEXT: ReturnTypes:
-; CHECK-NEXT: - I64
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: ReturnTypes: []
-; CHECK-NEXT: - Index: 4
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: - I32
-; CHECK-NEXT: ReturnTypes: []
-; CHECK-NEXT: - Type: FUNCTION
-; CHECK-NEXT: FunctionTypes: [ 0, 3, 1, 3, 4 ]
-; CHECK-NEXT: - Type: TABLE
-; CHECK-NEXT: Tables:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: ElemType: FUNCREF
-; CHECK-NEXT: Limits:
-; CHECK-NEXT: Flags: [ HAS_MAX ]
-; CHECK-NEXT: Minimum: 0x3
-; CHECK-NEXT: Maximum: 0x3
-; CHECK-NEXT: - Type: MEMORY
-; CHECK-NEXT: Memories:
-; CHECK-NEXT: - Minimum: 0x2
-; CHECK-NEXT: - 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: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1032
-; CHECK-NEXT: - Type: EXPORT
-; CHECK-NEXT: Exports:
-; CHECK-NEXT: - Name: memory
-; CHECK-NEXT: Kind: MEMORY
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: bar
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: call_bar_indirect
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: foo
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 2
-; CHECK-NEXT: - Name: _start
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 3
-; CHECK-NEXT: - Name: indirect_func
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: call_ptr
-; CHECK-NEXT: Kind: FUNCTION
-; 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: [ 0, 2 ]
-; CHECK-NEXT: - Type: CODE
-; CHECK-NEXT: Functions:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 42010B
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 410028028088808000118080808000001A410028028488808000118180808000001A0B
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 41020B
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 410028028888808000118180808000001A0B
-; CHECK-NEXT: - Index: 4
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 42012000118280808000001A0B
-; CHECK-NEXT: - Type: DATA
-; CHECK-NEXT: Segments:
-; CHECK-NEXT: - SectionOffset: 7
-; CHECK-NEXT: InitFlags: 0
-; CHECK-NEXT: Offset:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
-; CHECK-NEXT: Content: '010000000200000002000000'
-; CHECK-NEXT: - Type: CUSTOM
-; CHECK-NEXT: Name: name
-; CHECK-NEXT: FunctionNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: bar
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Name: call_bar_indirect
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Name: foo
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Name: _start
-; CHECK-NEXT: - Index: 4
-; CHECK-NEXT: Name: call_ptr
-; CHECK-NEXT: GlobalNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: __stack_pointer
-; CHECK-NEXT: DataSegmentNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: .data
-; CHECK-NEXT: ...
diff --git a/lld/test/wasm/call-indirect.s b/lld/test/wasm/call-indirect.s
new file mode 100644
index 0000000000000..7bf39a9f5aec9
--- /dev/null
+++ b/lld/test/wasm/call-indirect.s
@@ -0,0 +1,165 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/call-indirect.s -o %t2.o
+# RUN: wasm-ld --export-dynamic -o %t.wasm %t2.o %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+.globl foo
+foo:
+ .functype foo () -> (i32)
+ i32.const 2
+ end_function
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ i32.const 0
+ i32.load indirect_func
+ call_indirect () -> (i32)
+ drop
+ end_function
+
+# Indirect function call where no function actually has this type.
+# Ensures that the type entry is still created in this case.
+.section .text,"",@
+.globl call_ptr
+call_ptr:
+ .functype call_ptr (i32) -> ()
+ i64.const 1
+ local.get 0
+ call_indirect (i64) -> (i64)
+ drop
+ end_function
+
+.globl indirect_func
+.section .data.indirect_func,"",@
+indirect_func:
+ .int32 foo
+ .size indirect_func, 4
+
+# CHECK: !WASM
+# CHECK-NEXT: FileHeader:
+# CHECK-NEXT: Version: 0x1
+# CHECK-NEXT: Sections:
+# CHECK-NEXT: - Type: TYPE
+# CHECK-NEXT: Signatures:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: ReturnTypes:
+# CHECK-NEXT: - I64
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: ReturnTypes:
+# CHECK-NEXT: - I32
+# CHECK-NEXT: - Index: 2
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: - I64
+# CHECK-NEXT: ReturnTypes:
+# CHECK-NEXT: - I64
+# CHECK-NEXT: - Index: 3
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: ReturnTypes: []
+# CHECK-NEXT: - Index: 4
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: - I32
+# CHECK-NEXT: ReturnTypes: []
+# CHECK-NEXT: - Type: FUNCTION
+# CHECK-NEXT: FunctionTypes: [ 0, 3, 1, 3, 4 ]
+# CHECK-NEXT: - Type: TABLE
+# CHECK-NEXT: Tables:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: ElemType: FUNCREF
+# CHECK-NEXT: Limits:
+# CHECK-NEXT: Flags: [ HAS_MAX ]
+# CHECK-NEXT: Minimum: 0x3
+# CHECK-NEXT: Maximum: 0x3
+# CHECK-NEXT: - Type: MEMORY
+# CHECK-NEXT: Memories:
+# CHECK-NEXT: - Minimum: 0x2
+# CHECK-NEXT: - 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: I32
+# CHECK-NEXT: Mutable: false
+# CHECK-NEXT: InitExpr:
+# CHECK-NEXT: Opcode: I32_CONST
+# CHECK-NEXT: Value: 1032
+# CHECK-NEXT: - Type: EXPORT
+# CHECK-NEXT: Exports:
+# CHECK-NEXT: - Name: memory
+# CHECK-NEXT: Kind: MEMORY
+# CHECK-NEXT: Index: 0
+# CHECK-NEXT: - Name: bar
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Index: 0
+# CHECK-NEXT: - Name: call_bar_indirect
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Index: 1
+# CHECK-NEXT: - Name: foo
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Index: 2
+# CHECK-NEXT: - Name: _start
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Index: 3
+# CHECK-NEXT: - Name: indirect_func
+# CHECK-NEXT: Kind: GLOBAL
+# CHECK-NEXT: Index: 1
+# CHECK-NEXT: - Name: call_ptr
+# CHECK-NEXT: Kind: FUNCTION
+# 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: [ 0, 2 ]
+# CHECK-NEXT: - Type: CODE
+# CHECK-NEXT: Functions:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 42010B
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 410028028088808000118080808000001A410028028488808000118180808000001A0B
+# CHECK-NEXT: - Index: 2
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 41020B
+# CHECK-NEXT: - Index: 3
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 410028028888808000118180808000001A0B
+# CHECK-NEXT: - Index: 4
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 42012000118280808000001A0B
+# CHECK-NEXT: - Type: DATA
+# CHECK-NEXT: Segments:
+# CHECK-NEXT: - SectionOffset: 7
+# CHECK-NEXT: InitFlags: 0
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Opcode: I32_CONST
+# CHECK-NEXT: Value: 1024
+# CHECK-NEXT: Content: '010000000200000002000000'
+# CHECK-NEXT: - Type: CUSTOM
+# CHECK-NEXT: Name: name
+# CHECK-NEXT: FunctionNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: bar
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: Name: call_bar_indirect
+# CHECK-NEXT: - Index: 2
+# CHECK-NEXT: Name: foo
+# CHECK-NEXT: - Index: 3
+# CHECK-NEXT: Name: _start
+# CHECK-NEXT: - Index: 4
+# CHECK-NEXT: Name: call_ptr
+# CHECK-NEXT: GlobalNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: __stack_pointer
+# CHECK-NEXT: DataSegmentNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: .data
+# CHECK-NEXT: ...
diff --git a/lld/test/wasm/driver.ll b/lld/test/wasm/driver.ll
deleted file mode 100644
index e5aecf8a49740..0000000000000
--- a/lld/test/wasm/driver.ll
+++ /dev/null
@@ -1,41 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-
-target triple = "wasm32-unknown-unknown"
-
-define hidden void @_start() local_unnamed_addr #0 {
-entry:
- ret void
-}
-
-; RUN: not wasm-ld -o %t.exe 2>&1 | FileCheck -check-prefix=IN %s
-; IN: error: no input files
-
-; RUN: not wasm-ld %t.o 2>&1 | FileCheck -check-prefix=OUT %s
-; OUT: error: no output file specified
-
-; RUN: not wasm-ld 2>&1 | FileCheck -check-prefix=BOTH %s
-; BOTH: error: no input files
-; BOTH-NOT: error: no output file specified
-
-; RUN: not wasm-ld --export-table --import-table %t.o 2>&1 \
-; RUN: | FileCheck -check-prefix=TABLE %s
-; TABLE: error: --import-table and --export-table may not be used together
-
-; RUN: not wasm-ld --relocatable --shared-memory %t.o 2>&1 \
-; RUN: | FileCheck -check-prefix=SHARED-MEM %s
-; SHARED-MEM: error: -r and --shared-memory may not be used together
-
-; RUN: wasm-ld %t.o -z foo -o /dev/null 2>&1 | FileCheck -check-prefix=ERR10 %s
-; RUN: wasm-ld %t.o -z foo -o /dev/null --version 2>&1 | FileCheck -check-prefix=ERR10 %s
-; ERR10: warning: unknown -z value: foo
-
-;; Check we report "unknown -z value" error even with -v.
-; RUN: wasm-ld %t.o -z foo -o /dev/null -v 2>&1 | FileCheck -check-prefix=ERR10 %s
-
-;; Note: in GNU ld, --fatal-warning still leads to a warning.
-; RUN: not wasm-ld %t.o -z foo --fatal-warnings 2>&1 | FileCheck --check-prefix=ERR10-FATAL %s
-; ERR10-FATAL: error: unknown -z value: foo
-
-;; stack-size without an = is also an error
-; RUN: not wasm-ld %t.o -z stack-size 2>&1 | FileCheck -check-prefix=ERR11 %s
-; ERR11: unknown -z value: stack-size
diff --git a/lld/test/wasm/driver.s b/lld/test/wasm/driver.s
new file mode 100644
index 0000000000000..46d59e362a6a8
--- /dev/null
+++ b/lld/test/wasm/driver.s
@@ -0,0 +1,39 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ end_function
+
+# RUN: not wasm-ld -o %t.exe 2>&1 | FileCheck -check-prefix=IN %s
+# IN: error: no input files
+
+# RUN: not wasm-ld %t.o 2>&1 | FileCheck -check-prefix=OUT %s
+# OUT: error: no output file specified
+
+# RUN: not wasm-ld 2>&1 | FileCheck -check-prefix=BOTH %s
+# BOTH: error: no input files
+# BOTH-NOT: error: no output file specified
+
+# RUN: not wasm-ld --export-table --import-table %t.o 2>&1 \
+# RUN: | FileCheck -check-prefix=TABLE %s
+# TABLE: error: --import-table and --export-table may not be used together
+
+# RUN: not wasm-ld --relocatable --shared-memory %t.o 2>&1 \
+# RUN: | FileCheck -check-prefix=SHARED-MEM %s
+# SHARED-MEM: error: -r and --shared-memory may not be used together
+
+# RUN: wasm-ld %t.o -z foo -o /dev/null 2>&1 | FileCheck -check-prefix=ERR10 %s
+# RUN: wasm-ld %t.o -z foo -o /dev/null --version 2>&1 | FileCheck -check-prefix=ERR10 %s
+# ERR10: warning: unknown -z value: foo
+
+## Check we report "unknown -z value" error even with -v.
+# RUN: wasm-ld %t.o -z foo -o /dev/null -v 2>&1 | FileCheck -check-prefix=ERR10 %s
+
+## Note: in GNU ld, --fatal-warning still leads to a warning.
+# RUN: not wasm-ld %t.o -z foo --fatal-warnings 2>&1 | FileCheck --check-prefix=ERR10-FATAL %s
+# ERR10-FATAL: error: unknown -z value: foo
+
+## stack-size without an = is also an error
+# RUN: not wasm-ld %t.o -z stack-size 2>&1 | FileCheck -check-prefix=ERR11 %s
+# ERR11: unknown -z value: stack-size
diff --git a/lld/test/wasm/entry.ll b/lld/test/wasm/entry.ll
deleted file mode 100644
index 21779a01bfec7..0000000000000
--- a/lld/test/wasm/entry.ll
+++ /dev/null
@@ -1,38 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-
-target triple = "wasm32-unknown-unknown"
-
-define hidden void @entry() local_unnamed_addr #0 {
-entry:
- ret void
-}
-
-; RUN: wasm-ld -e entry -o %t1.wasm %t.o
-; RUN: obj2yaml %t1.wasm | FileCheck %s
-; RUN: wasm-ld --entry=entry -o %t2.wasm %t.o
-; RUN: obj2yaml %t2.wasm | FileCheck %s
-
-; CHECK: - Type: EXPORT
-; CHECK-NEXT: Exports:
-; CHECK-NEXT: - Name: memory
-; CHECK-NEXT: Kind: MEMORY
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: entry
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Type:
-
-; The __wasm_call_ctors is somewhat special since its created by the linker.
-; Make sure we can use it as the entry point if we choose
-; RUN: wasm-ld --entry=__wasm_call_ctors -o %t3.wasm %t.o
-; RUN: obj2yaml %t3.wasm | FileCheck %s -check-prefix=CHECK-CTOR
-
-; CHECK-CTOR: - Type: EXPORT
-; CHECK-CTOR-NEXT: Exports:
-; CHECK-CTOR-NEXT: - Name: memory
-; CHECK-CTOR-NEXT: Kind: MEMORY
-; CHECK-CTOR-NEXT: Index: 0
-; CHECK-CTOR-NEXT: - Name: __wasm_call_ctors
-; CHECK-CTOR-NEXT: Kind: FUNCTION
-; CHECK-CTOR-NEXT: Index: 0
-; CHECK-CTOR-NEXT: - Type:
diff --git a/lld/test/wasm/entry.s b/lld/test/wasm/entry.s
new file mode 100644
index 0000000000000..9275249492aac
--- /dev/null
+++ b/lld/test/wasm/entry.s
@@ -0,0 +1,36 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+
+.globl entry
+entry:
+ .functype entry () -> ()
+ end_function
+
+# RUN: wasm-ld -e entry -o %t1.wasm %t.o
+# RUN: obj2yaml %t1.wasm | FileCheck %s
+# RUN: wasm-ld --entry=entry -o %t2.wasm %t.o
+# RUN: obj2yaml %t2.wasm | FileCheck %s
+
+# CHECK: - Type: EXPORT
+# CHECK-NEXT: Exports:
+# CHECK-NEXT: - Name: memory
+# CHECK-NEXT: Kind: MEMORY
+# CHECK-NEXT: Index: 0
+# CHECK-NEXT: - Name: entry
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Index: 0
+# CHECK-NEXT: - Type:
+
+# The __wasm_call_ctors is somewhat special since its created by the linker.
+# Make sure we can use it as the entry point if we choose
+# RUN: wasm-ld --entry=__wasm_call_ctors -o %t3.wasm %t.o
+# RUN: obj2yaml %t3.wasm | FileCheck %s -check-prefix=CHECK-CTOR
+
+# CHECK-CTOR: - Type: EXPORT
+# CHECK-CTOR-NEXT: Exports:
+# CHECK-CTOR-NEXT: - Name: memory
+# CHECK-CTOR-NEXT: Kind: MEMORY
+# CHECK-CTOR-NEXT: Index: 0
+# CHECK-CTOR-NEXT: - Name: __wasm_call_ctors
+# CHECK-CTOR-NEXT: Kind: FUNCTION
+# CHECK-CTOR-NEXT: Index: 0
+# CHECK-CTOR-NEXT: - Type:
diff --git a/lld/test/wasm/fatal-warnings.ll b/lld/test/wasm/fatal-warnings.ll
deleted file mode 100644
index 01a0137a2f454..0000000000000
--- a/lld/test/wasm/fatal-warnings.ll
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.main.o
-; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
-; RUN: wasm-ld -o %t.wasm %t.main.o %t.ret32.o 2>&1 | FileCheck %s -check-prefix=CHECK-WARN
-; RUN: not wasm-ld --fatal-warnings -o %t.wasm %t.main.o %t.ret32.o 2>&1 | FileCheck %s -check-prefix=CHECK-FATAL
-
-; CHECK-WARN: warning: function signature mismatch: ret32
-; CHECK-FATAL: error: function signature mismatch: ret32
-
-target triple = "wasm32-unknown-unknown"
-
-define hidden void @_start() local_unnamed_addr #0 {
-entry:
- %call = tail call i32 @ret32(i32 1, i64 2, i32 3) #2
- ret void
-}
-
-declare i32 @ret32(i32, i64, i32) local_unnamed_addr #1
diff --git a/lld/test/wasm/fatal-warnings.s b/lld/test/wasm/fatal-warnings.s
new file mode 100644
index 0000000000000..a534195b0478b
--- /dev/null
+++ b/lld/test/wasm/fatal-warnings.s
@@ -0,0 +1,19 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
+# RUN: wasm-ld -o %t.wasm %t.o %t.ret32.o 2>&1 | FileCheck %s -check-prefix=CHECK-WARN
+# RUN: not wasm-ld --fatal-warnings -o %t.wasm %t.o %t.ret32.o 2>&1 | FileCheck %s -check-prefix=CHECK-FATAL
+
+# CHECK-WARN: warning: function signature mismatch: ret32
+# CHECK-FATAL: error: function signature mismatch: ret32
+
+.functype ret32 (f32, i64, i32) -> (i32)
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ f32.const 1.0
+ i64.const 2
+ i32.const 3
+ call ret32
+ drop
+ end_function
diff --git a/lld/test/wasm/function-imports.ll b/lld/test/wasm/function-imports.ll
deleted file mode 100644
index 4b18532fc2207..0000000000000
--- a/lld/test/wasm/function-imports.ll
+++ /dev/null
@@ -1,43 +0,0 @@
-; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
-; RUN: llc -filetype=obj %s -o %t.o
-; RUN: wasm-ld -o %t.wasm %t.ret32.o %t.o
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-; Function Attrs: nounwind
-define hidden void @_start() local_unnamed_addr #0 {
-entry:
- %call = tail call i32 @ret32(float 0.000000e+00) #2
- ret void
-}
-
-declare i32 @ret32(float) local_unnamed_addr #1
-
-; CHECK: Sections:
-; CHECK: - Type: TYPE
-; CHECK-NEXT: Signatures:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: - F32
-; CHECK-NEXT: ReturnTypes:
-; CHECK-NEXT: - I32
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: ReturnTypes: []
-; CHECK-NEXT: - Type: FUNCTION
-; CHECK-NEXT: FunctionTypes: [ 0, 1 ]
-; CHECK: - Type: CODE
-; CHECK-NEXT: Functions:
-; CHECK: - Index: 0
-; CHECK: - Index: 1
-; CHECK: Name: name
-; CHECK-NEXT: FunctionNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: ret32
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Name: _start
-; CHECK-NEXT: GlobalNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: __stack_pointer
-; CHECK-NEXT: ...
diff --git a/lld/test/wasm/function-imports.s b/lld/test/wasm/function-imports.s
new file mode 100644
index 0000000000000..825747849fff2
--- /dev/null
+++ b/lld/test/wasm/function-imports.s
@@ -0,0 +1,42 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld -o %t.wasm %t.ret32.o %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+.functype ret32 (f32) -> (i32)
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ f32.const 0.000000e+00
+ call ret32
+ drop
+ end_function
+
+# CHECK: Sections:
+# CHECK: - Type: TYPE
+# CHECK-NEXT: Signatures:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: - F32
+# CHECK-NEXT: ReturnTypes:
+# CHECK-NEXT: - I32
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: ReturnTypes: []
+# CHECK-NEXT: - Type: FUNCTION
+# CHECK-NEXT: FunctionTypes: [ 0, 1 ]
+# CHECK: - Type: CODE
+# CHECK-NEXT: Functions:
+# CHECK: - Index: 0
+# CHECK: - Index: 1
+# CHECK: Name: name
+# CHECK-NEXT: FunctionNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: ret32
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: Name: _start
+# CHECK-NEXT: GlobalNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: __stack_pointer
+# CHECK-NEXT: ...
diff --git a/lld/test/wasm/stack-pointer.ll b/lld/test/wasm/stack-pointer.ll
deleted file mode 100644
index 38693d252ea7f..0000000000000
--- a/lld/test/wasm/stack-pointer.ll
+++ /dev/null
@@ -1,67 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-; RUN: wasm-ld --relocatable -o %t.wasm %t.o
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-; Function Attrs: nounwind
-define i32 @_start() local_unnamed_addr {
-entry:
- %retval = alloca i32, align 4
- ret i32 0
-}
-
-; CHECK: --- !WASM
-; CHECK-NEXT: FileHeader:
-; CHECK-NEXT: Version: 0x1
-; CHECK-NEXT: Sections:
-; CHECK-NEXT: - Type: TYPE
-; CHECK-NEXT: Signatures:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: ParamTypes:
-; CHECK-NEXT: ReturnTypes:
-; CHECK-NEXT: - I32
-; CHECK-NEXT: - Type: IMPORT
-; CHECK-NEXT: Imports:
-; CHECK-NEXT: - Module: env
-; CHECK-NEXT: Field: __stack_pointer
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: GlobalType: I32
-; CHECK-NEXT: GlobalMutable: true
-; CHECK-NEXT: - Type: FUNCTION
-; CHECK-NEXT: FunctionTypes: [ 0 ]
-; CHECK-NEXT: - Type: MEMORY
-; CHECK-NEXT: Memories:
-; CHECK-NEXT: - Minimum: 0x0
-; CHECK-NEXT: - Type: CODE
-; CHECK-NEXT: Relocations:
-; CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: Offset: 0x4
-; CHECK-NEXT: Functions:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Locals:
-; CHECK-NEXT: Body: 23808080800041106B1A41000B
-; CHECK-NEXT: - Type: CUSTOM
-; CHECK-NEXT: Name: linking
-; CHECK-NEXT: Version: 2
-; CHECK-NEXT: SymbolTable:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Kind: FUNCTION
-; CHECK-NEXT: Name: _start
-; CHECK-NEXT: Flags: [ ]
-; CHECK-NEXT: Function: 0
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Name: __stack_pointer
-; CHECK-NEXT: Flags: [ UNDEFINED ]
-; CHECK-NEXT: Global: 0
-; CHECK-NEXT: - Type: CUSTOM
-; CHECK-NEXT: Name: name
-; CHECK-NEXT: FunctionNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: _start
-; CHECK-NEXT: GlobalNames:
-; CHECK-NEXT: - Index: 0
-; CHECK-NEXT: Name: __stack_pointer
-; CHECK-NEXT: ...
diff --git a/lld/test/wasm/stack-pointer.s b/lld/test/wasm/stack-pointer.s
new file mode 100644
index 0000000000000..902ac493d3dec
--- /dev/null
+++ b/lld/test/wasm/stack-pointer.s
@@ -0,0 +1,70 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld --relocatable -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+.globaltype __stack_pointer, i32
+
+.globl _start
+_start:
+ .functype _start () -> (i32)
+ global.get __stack_pointer
+ i32.const 16
+ i32.sub
+ drop
+ i32.const 0
+ end_function
+
+# CHECK: --- !WASM
+# CHECK-NEXT: FileHeader:
+# CHECK-NEXT: Version: 0x1
+# CHECK-NEXT: Sections:
+# CHECK-NEXT: - Type: TYPE
+# CHECK-NEXT: Signatures:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: ParamTypes:
+# CHECK-NEXT: ReturnTypes:
+# CHECK-NEXT: - I32
+# CHECK-NEXT: - Type: IMPORT
+# CHECK-NEXT: Imports:
+# CHECK-NEXT: - Module: env
+# CHECK-NEXT: Field: __stack_pointer
+# CHECK-NEXT: Kind: GLOBAL
+# CHECK-NEXT: GlobalType: I32
+# CHECK-NEXT: GlobalMutable: true
+# CHECK-NEXT: - Type: FUNCTION
+# CHECK-NEXT: FunctionTypes: [ 0 ]
+# CHECK-NEXT: - Type: MEMORY
+# CHECK-NEXT: Memories:
+# CHECK-NEXT: - Minimum: 0x0
+# CHECK-NEXT: - Type: CODE
+# CHECK-NEXT: Relocations:
+# CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
+# CHECK-NEXT: Index: 1
+# CHECK-NEXT: Offset: 0x4
+# CHECK-NEXT: Functions:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Locals:
+# CHECK-NEXT: Body: 23808080800041106B1A41000B
+# CHECK-NEXT: - Type: CUSTOM
+# CHECK-NEXT: Name: linking
+# CHECK-NEXT: Version: 2
+# CHECK-NEXT: SymbolTable:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT: Name: _start
+# CHECK-NEXT: Flags: [ ]
+# CHECK-NEXT: Function: 0
+# CHECK-NEXT: - Index: 1
+# CHECK-NEXT: Kind: GLOBAL
+# CHECK-NEXT: Name: __stack_pointer
+# CHECK-NEXT: Flags: [ UNDEFINED ]
+# CHECK-NEXT: Global: 0
+# CHECK-NEXT: - Type: CUSTOM
+# CHECK-NEXT: Name: name
+# CHECK-NEXT: FunctionNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: _start
+# CHECK-NEXT: GlobalNames:
+# CHECK-NEXT: - Index: 0
+# CHECK-NEXT: Name: __stack_pointer
+# CHECK-NEXT: ...
diff --git a/lld/test/wasm/trace-symbol.ll b/lld/test/wasm/trace-symbol.ll
deleted file mode 100644
index 25154004d6b0e..0000000000000
--- a/lld/test/wasm/trace-symbol.ll
+++ /dev/null
@@ -1,28 +0,0 @@
-; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
-; RUN: llc -filetype=obj -o %t.start.o %s
-; RUN: wasm-ld -o %t.wasm %t.start.o %t.ret32.o -y ret32 -y _start | FileCheck %s -check-prefix=BOTH
-; RUN: wasm-ld -o %t.wasm %t.ret32.o %t.start.o -y ret32 -y _start | FileCheck %s -check-prefix=REVERSED
-
-; check alias
-; RUN: wasm-ld -o %t.wasm %t.start.o %t.ret32.o -trace-symbol=_start | FileCheck %s -check-prefixes=JUST-START
-
-target triple = "wasm32-unknown-unknown"
-
-declare i32 @ret32(float %arg)
-
-define void @_start() {
-entry:
- %call1 = call i32 @ret32(float 0.0)
- ret void
-}
-
-; BOTH: start.o: definition of _start
-; BOTH-NEXT: start.o: reference to ret32
-; BOTH-NEXT: ret32.o: definition of ret32
-
-; REVERSED: ret32.o: definition of ret32
-; REVERSED-NEXT: start.o: definition of _start
-; REVERSED-NEXT: start.o: reference to ret32
-
-; JUST-START: start.o: definition of _start
-; JUST-START-NOT: ret32
diff --git a/lld/test/wasm/trace-symbol.s b/lld/test/wasm/trace-symbol.s
new file mode 100644
index 0000000000000..88e5c6f5829e3
--- /dev/null
+++ b/lld/test/wasm/trace-symbol.s
@@ -0,0 +1,28 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.start.o %s
+# RUN: wasm-ld -o %t.wasm %t.start.o %t.ret32.o -y ret32 -y _start | FileCheck %s -check-prefix=BOTH
+# RUN: wasm-ld -o %t.wasm %t.ret32.o %t.start.o -y ret32 -y _start | FileCheck %s -check-prefix=REVERSED
+
+# check alias
+# RUN: wasm-ld -o %t.wasm %t.start.o %t.ret32.o -trace-symbol=_start | FileCheck %s -check-prefixes=JUST-START
+
+.functype ret32 (f32) -> (i32)
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ f32.const 0.0
+ call ret32
+ drop
+ end_function
+
+# BOTH: start.o: definition of _start
+# BOTH-NEXT: start.o: reference to ret32
+# BOTH-NEXT: ret32.o: definition of ret32
+
+# REVERSED: ret32.o: definition of ret32
+# REVERSED-NEXT: start.o: definition of _start
+# REVERSED-NEXT: start.o: reference to ret32
+
+# JUST-START: start.o: definition of _start
+# JUST-START-NOT: ret32
More information about the llvm-commits
mailing list