diff --git a/lld/test/wasm/Inputs/call-indirect.ll b/lld/test/wasm/Inputs/call-indirect.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/call-indirect.ll +++ /dev/null @@ -1,20 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -@indirect_bar = internal local_unnamed_addr global i64 ()* @bar, align 4 -@indirect_foo = internal local_unnamed_addr global i32 ()* @foo, align 4 - -declare i32 @foo() local_unnamed_addr - -define i64 @bar() { -entry: - ret i64 1 -} - -define void @call_bar_indirect() local_unnamed_addr #1 { -entry: - %0 = load i64 ()*, i64 ()** @indirect_bar, align 4 - %1 = load i32 ()*, i32 ()** @indirect_foo, align 4 - %call0 = tail call i64 %0() #2 - %call1 = tail call i32 %1() #2 - ret void -} diff --git a/lld/test/wasm/Inputs/call-indirect.s b/lld/test/wasm/Inputs/call-indirect.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/call-indirect.s @@ -0,0 +1,28 @@ + .globl bar +bar: + .functype bar () -> (i64) + i64.const 1 + end_function + + .globl call_bar_indirect +call_bar_indirect: + .functype call_bar_indirect () -> () + i32.load indirect_bar + call_indirect () -> (i64) + drop + i32.load indirect_foo + call_indirect () -> (i32) + drop + end_function + + .section .data.indirect_bar,"",@ +indirect_bar: + .int32 bar + .size indirect_bar, 4 + + .section .data.indirect_foo,"",@ +indirect_foo: + .int32 foo + .size indirect_foo, 4 + + .functype foo () -> (i32) diff --git a/lld/test/wasm/Inputs/call-ret32.ll b/lld/test/wasm/Inputs/call-ret32.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/call-ret32.ll +++ /dev/null @@ -1,11 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -@ret32_address = global i32 (float)* @ret32, align 4 - -define hidden i32* @call_ret32() { -entry: - %call1 = call i32 @ret32(float 0.000000e+00) - ret i32* bitcast (i32 (float)** @ret32_address to i32*) -} - -declare i32 @ret32(float) diff --git a/lld/test/wasm/Inputs/call-ret32.s b/lld/test/wasm/Inputs/call-ret32.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/call-ret32.s @@ -0,0 +1,16 @@ + .globl call_ret32 +call_ret32: + .functype call_ret32 () -> (i32) + f32.const 0x0p0 + call ret32 + drop + i32.const ret32_address + end_function + + .section .data.ret32_address,"",@ + .globl ret32_address +ret32_address: + .int32 ret32 + .size ret32_address, 4 + + .functype ret32 (f32) -> (i32) diff --git a/lld/test/wasm/Inputs/hello.ll b/lld/test/wasm/Inputs/hello.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/hello.ll +++ /dev/null @@ -1,17 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -; Wasm module generated from the following C code: -; void puts(const char*); -; void hello() { puts("hello\n"); } - -@hello_str = unnamed_addr constant [7 x i8] c"hello\0A\00", align 1 - -; Function Attrs: nounwind -define hidden void @hello() local_unnamed_addr #0 { -entry: - tail call void @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @hello_str, i32 0, i32 0)) - ret void -} - -; Function Attrs: nounwind -declare void @puts(i8* nocapture readonly) local_unnamed_addr #1 diff --git a/lld/test/wasm/Inputs/hello.s b/lld/test/wasm/Inputs/hello.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/hello.s @@ -0,0 +1,18 @@ +# asm generated by clang from the following C code: +# void puts(const char*); +# void hello() { puts("hello\n"); } + + .globl hello +hello: + .functype hello () -> () + i32.const hello_str + call puts + end_function + + .section .rodata.hello_str,"",@ + .globl hello_str +hello_str: + .asciz "hello\n" + .size hello_str, 7 + + .functype puts (i32) -> () diff --git a/lld/test/wasm/Inputs/hidden.ll b/lld/test/wasm/Inputs/hidden.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/hidden.ll +++ /dev/null @@ -1,13 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -; Function Attrs: norecurse nounwind readnone -define hidden i32 @archiveHidden() #0 { -entry: - ret i32 0 -} - -; Function Attrs: norecurse nounwind readnone -define i32 @archiveDefault() #1 { -entry: - ret i32 0 -} diff --git a/lld/test/wasm/Inputs/hidden.s b/lld/test/wasm/Inputs/hidden.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/hidden.s @@ -0,0 +1,12 @@ + .hidden archiveHidden + .globl archiveHidden +archiveHidden: + .functype archiveHidden () -> (i32) + i32.const 0 + end_function + + .globl archiveDefault +archiveDefault: + .functype archiveDefault () -> (i32) + i32.const 0 + end_function diff --git a/lld/test/wasm/Inputs/import-attributes.ll b/lld/test/wasm/Inputs/import-attributes.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/import-attributes.ll +++ /dev/null @@ -1,10 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define void @call_foo() { - call void @foo(); - ret void -} - -declare void @foo() #0 - -attributes #0 = { "wasm-import-module"="baz" } diff --git a/lld/test/wasm/Inputs/import-attributes.s b/lld/test/wasm/Inputs/import-attributes.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/import-attributes.s @@ -0,0 +1,8 @@ + .globl call_foo +call_foo: + .functype call_foo () -> () + call foo + end_function + + .functype foo () -> () + .import_module foo, baz diff --git a/lld/test/wasm/Inputs/optional-symbol.ll b/lld/test/wasm/Inputs/optional-symbol.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/optional-symbol.ll +++ /dev/null @@ -1,7 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -@__dso_handle = external global i8* - -define i8** @get_optional() { - ret i8** @__dso_handle -} diff --git a/lld/test/wasm/Inputs/optional-symbol.s b/lld/test/wasm/Inputs/optional-symbol.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/optional-symbol.s @@ -0,0 +1,7 @@ +# __dso_handle is an linker-generated symbol that is included only when needed. + + .globl get_optional +get_optional: + .functype get_optional () -> (i32) + i32.const __dso_handle + end_function diff --git a/lld/test/wasm/Inputs/ret32.ll b/lld/test/wasm/Inputs/ret32.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/ret32.ll +++ /dev/null @@ -1,6 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define hidden i32 @ret32(float %arg) { -entry: - ret i32 0 -} diff --git a/lld/test/wasm/Inputs/ret32.s b/lld/test/wasm/Inputs/ret32.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/ret32.s @@ -0,0 +1,6 @@ + .hidden ret32 + .globl ret32 +ret32: + .functype ret32 (f32) -> (i32) + i32.const 0 + end_function diff --git a/lld/test/wasm/Inputs/ret64.ll b/lld/test/wasm/Inputs/ret64.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/ret64.ll +++ /dev/null @@ -1,6 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define hidden i64 @ret64(double %arg) { -entry: - ret i64 1 -} diff --git a/lld/test/wasm/Inputs/ret64.s b/lld/test/wasm/Inputs/ret64.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/ret64.s @@ -0,0 +1,6 @@ + .hidden ret64 + .globl ret64 +ret64: + .functype ret64 (f64) -> (i64) + i64.const 1 + end_function diff --git a/lld/test/wasm/Inputs/start.ll b/lld/test/wasm/Inputs/start.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/start.ll +++ /dev/null @@ -1,6 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define void @_start() local_unnamed_addr { -entry: - ret void -} diff --git a/lld/test/wasm/Inputs/start.s b/lld/test/wasm/Inputs/start.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/start.s @@ -0,0 +1,4 @@ + .globl _start +_start: + .functype _start () -> () + end_function diff --git a/lld/test/wasm/Inputs/strong-symbol.ll b/lld/test/wasm/Inputs/strong-symbol.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/strong-symbol.ll +++ /dev/null @@ -1,6 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define i64 @weakFn() #0 { -entry: - ret i64 1 -} diff --git a/lld/test/wasm/Inputs/strong-symbol.s b/lld/test/wasm/Inputs/strong-symbol.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/strong-symbol.s @@ -0,0 +1,6 @@ + .globl weakFn + .type weakFn,@function +weakFn: + .functype weakFn () -> (i64) + i64.const 1 + end_function diff --git a/lld/test/wasm/Inputs/weak-symbol1.ll b/lld/test/wasm/Inputs/weak-symbol1.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/weak-symbol1.ll +++ /dev/null @@ -1,13 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define weak i32 @weakFn() #0 { -entry: - ret i32 1 -} - -define i32 @exportWeak1() { -entry: - ret i32 ptrtoint (i32 ()* @weakFn to i32) -} - -@weakGlobal = weak global i32 1 diff --git a/lld/test/wasm/Inputs/weak-symbol1.s b/lld/test/wasm/Inputs/weak-symbol1.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/weak-symbol1.s @@ -0,0 +1,17 @@ + .weak weakFn +weakFn: + .functype weakFn () -> (i32) + i32.const 1 + end_function + + .globl exportWeak1 +exportWeak1: + .functype exportWeak1 () -> (i32) + i32.const weakFn + end_function + + .section .data.weakGlobal,"",@ + .weak weakGlobal +weakGlobal: + .int32 1 + .size weakGlobal, 4 diff --git a/lld/test/wasm/Inputs/weak-symbol2.ll b/lld/test/wasm/Inputs/weak-symbol2.ll deleted file mode 100644 --- a/lld/test/wasm/Inputs/weak-symbol2.ll +++ /dev/null @@ -1,13 +0,0 @@ -target triple = "wasm32-unknown-unknown" - -define weak i32 @weakFn() #0 { -entry: - ret i32 2 -} - -define i32 @exportWeak2() { -entry: - ret i32 ptrtoint (i32 ()* @weakFn to i32) -} - -@weakGlobal = weak global i32 2 diff --git a/lld/test/wasm/Inputs/weak-symbol2.s b/lld/test/wasm/Inputs/weak-symbol2.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/Inputs/weak-symbol2.s @@ -0,0 +1,17 @@ + .weak weakFn +weakFn: + .functype weakFn () -> (i32) + i32.const 2 + end_function + + .globl exportWeak2 +exportWeak2: + .functype exportWeak2 () -> (i32) + i32.const weakFn + end_function + + .section .data.weakGlobal,"",@ + .weak weakGlobal +weakGlobal: + .int32 2 + .size weakGlobal, 4 diff --git a/lld/test/wasm/alias.ll b/lld/test/wasm/alias.ll deleted file mode 100644 --- a/lld/test/wasm/alias.ll +++ /dev/null @@ -1,65 +0,0 @@ -; RUN: llc -filetype=obj -o %t.o %s -; RUN: wasm-ld --export=start_alias %t.o -o %t.wasm -; RUN: obj2yaml %t.wasm | FileCheck %s - -target triple = "wasm32-unknown-unknown" - -@start_alias = alias void (), void ()* @_start - -; Function Attrs: nounwind uwtable -define void @_start() local_unnamed_addr #1 { -entry: - ret void -} - -; CHECK: --- !WASM -; CHECK-NEXT: FileHeader: -; CHECK-NEXT: Version: 0x00000001 -; CHECK-NEXT: Sections: -; CHECK-NEXT: - Type: TYPE -; CHECK-NEXT: Signatures: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ParamTypes: -; CHECK-NEXT: ReturnTypes: [] -; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0 ] -; CHECK-NEXT: - Type: TABLE -; CHECK-NEXT: Tables: -; CHECK-NEXT: - ElemType: FUNCREF -; CHECK-NEXT: Limits: -; CHECK-NEXT: Flags: [ HAS_MAX ] -; CHECK-NEXT: Initial: 0x00000001 -; CHECK-NEXT: Maximum: 0x00000001 -; CHECK-NEXT: - Type: MEMORY -; CHECK-NEXT: Memories: -; CHECK-NEXT: - Initial: 0x00000002 -; 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: 66560 -; CHECK-NEXT: - Type: EXPORT -; CHECK-NEXT: Exports: -; CHECK-NEXT: - Name: memory -; CHECK-NEXT: Kind: MEMORY -; CHECK-NEXT: Index: 0 -; CHECK-NEXT: - Name: _start -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 -; CHECK-NEXT: - Name: start_alias -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 0 -; CHECK-NEXT: - Type: CODE -; CHECK-NEXT: Functions: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: name -; CHECK-NEXT: FunctionNames: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start -; CHECK-NEXT: ... diff --git a/lld/test/wasm/alias.s b/lld/test/wasm/alias.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/alias.s @@ -0,0 +1,64 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld --export=start_alias %t.o -o %t.wasm +# RUN: obj2yaml %t.wasm | FileCheck %s + + .globl _start +_start: + .functype _start () -> () + end_function + + .globl start_alias + .type start_alias,@function +.set start_alias, _start + +# CHECK: --- !WASM +# CHECK-NEXT: FileHeader: +# CHECK-NEXT: Version: 0x00000001 +# CHECK-NEXT: Sections: +# CHECK-NEXT: - Type: TYPE +# CHECK-NEXT: Signatures: +# CHECK-NEXT: - Index: 0 +# CHECK-NEXT: ParamTypes: +# CHECK-NEXT: ReturnTypes: [] +# CHECK-NEXT: - Type: FUNCTION +# CHECK-NEXT: FunctionTypes: [ 0 ] +# CHECK-NEXT: - Type: TABLE +# CHECK-NEXT: Tables: +# CHECK-NEXT: - ElemType: FUNCREF +# CHECK-NEXT: Limits: +# CHECK-NEXT: Flags: [ HAS_MAX ] +# CHECK-NEXT: Initial: 0x00000001 +# CHECK-NEXT: Maximum: 0x00000001 +# CHECK-NEXT: - Type: MEMORY +# CHECK-NEXT: Memories: +# CHECK-NEXT: - Initial: 0x00000002 +# 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: 66560 +# CHECK-NEXT: - Type: EXPORT +# CHECK-NEXT: Exports: +# CHECK-NEXT: - Name: memory +# CHECK-NEXT: Kind: MEMORY +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: - Name: _start +# CHECK-NEXT: Kind: FUNCTION +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: - Name: start_alias +# CHECK-NEXT: Kind: FUNCTION +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: - Type: CODE +# CHECK-NEXT: Functions: +# CHECK-NEXT: - Index: 0 +# CHECK-NEXT: Locals: +# CHECK-NEXT: Body: 0B +# CHECK-NEXT: - Type: CUSTOM +# CHECK-NEXT: Name: name +# CHECK-NEXT: FunctionNames: +# CHECK-NEXT: - Index: 0 +# CHECK-NEXT: Name: _start +# CHECK-NEXT: ... diff --git a/lld/test/wasm/archive-export.ll b/lld/test/wasm/archive-export.ll --- a/lld/test/wasm/archive-export.ll +++ b/lld/test/wasm/archive-export.ll @@ -1,6 +1,6 @@ Test that --export will also fetch lazy symbols from archives -RUN: llc -filetype=obj %S/Inputs/start.ll -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o RUN: rm -f %t.a diff --git a/lld/test/wasm/archive-no-index.ll b/lld/test/wasm/archive-no-index.ll deleted file mode 100644 --- a/lld/test/wasm/archive-no-index.ll +++ /dev/null @@ -1,13 +0,0 @@ -; Tests error on archive file without a symbol table -; RUN: llvm-as -o %t.o %s -; RUN: llvm-as -o %t.archive.o %S/Inputs/archive1.ll -; RUN: rm -f %t.a -; RUN: llvm-ar crS %t.a %t.archive.o - -; RUN: not wasm-ld -o out.wasm %t.o %t.a 2>&1 | FileCheck %s - -define i32 @_start() { - ret i32 0 -} - -; CHECK: archive has no index; run ranlib to add one diff --git a/lld/test/wasm/archive-no-index.s b/lld/test/wasm/archive-no-index.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/archive-no-index.s @@ -0,0 +1,14 @@ +# Tests error on archive file without a symbol table +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: llvm-as -o %t.archive.o %S/Inputs/archive1.ll +# RUN: rm -f %t.a +# RUN: llvm-ar crS %t.a %t.archive.o + +# RUN: not wasm-ld -o out.wasm %t.o %t.a 2>&1 | FileCheck %s + + .globl _start +_start: + .functype _start () -> () + end_function + +# CHECK: archive has no index; run ranlib to add one diff --git a/lld/test/wasm/archive-weak-undefined.ll b/lld/test/wasm/archive-weak-undefined.ll --- a/lld/test/wasm/archive-weak-undefined.ll +++ b/lld/test/wasm/archive-weak-undefined.ll @@ -1,7 +1,7 @@ ; Test that weak undefined symbols do not fetch members from archive files. ; RUN: llc -filetype=obj %s -o %t.o -; RUN: llc -filetype=obj %S/Inputs/ret32.ll -o %t.ret32.o -; RUN: llc -filetype=obj %S/Inputs/hello.ll -o %t.hello.o +; 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 %p/Inputs/hello.s -o %t.hello.o ; RUN: rm -f %t.a ; RUN: llvm-ar rcs %t.a %t.ret32.o %t.hello.o diff --git a/lld/test/wasm/archive.ll b/lld/test/wasm/archive.ll --- a/lld/test/wasm/archive.ll +++ b/lld/test/wasm/archive.ll @@ -2,7 +2,7 @@ ; RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o ; RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o ; RUN: llc -filetype=obj %S/Inputs/archive3.ll -o %t.a3.o -; RUN: llc -filetype=obj %S/Inputs/hello.ll -o %t.hello.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o ; RUN: rm -f %t.a ; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o ; RUN: rm -f %t.imports diff --git a/lld/test/wasm/bss-only.ll b/lld/test/wasm/bss-only.ll deleted file mode 100644 --- a/lld/test/wasm/bss-only.ll +++ /dev/null @@ -1,14 +0,0 @@ -; RUN: llc -filetype=obj %s -o %t.o -; RUN: wasm-ld -no-gc-sections --no-entry %t.o -o %t.wasm -; RUN: obj2yaml %t.wasm | FileCheck %s - -; Test that the data section is skipped entirely when there are only -; bss segments - -target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32-unknown-unknown" - -@a = global [1000 x i8] zeroinitializer, align 1 -@b = global i32 0 - -; CHECK-NOT: - Type: DATA diff --git a/lld/test/wasm/bss-only.s b/lld/test/wasm/bss-only.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/bss-only.s @@ -0,0 +1,43 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld -no-gc-sections --no-entry --export=__data_end %t.o -o %t.wasm +# RUN: obj2yaml %t.wasm | FileCheck %s + +# Test that the data section is skipped entirely when there are only +# bss segments + + .section .bss.a,"",@ + .globl a +a: + .skip 1000 + .size a, 1000 + + .section .bss.b,"",@ + .globl b +b: + .int32 0 + .size b, 4 + +# CHECK-NOT: - Type: DATA + +# 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: 67568 +# CHECK-NEXT: - Index: 1 +# CHECK-NEXT: Type: I32 +# CHECK-NEXT: Mutable: false +# CHECK-NEXT: InitExpr: +# CHECK-NEXT: Opcode: I32_CONST +# CHECK-NEXT: Value: 2028 +# CHECK-NEXT: - Type: EXPORT +# CHECK-NEXT: Exports: +# CHECK-NEXT: - Name: memory +# CHECK-NEXT: Kind: MEMORY +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: - Name: __data_end +# CHECK-NEXT: Kind: GLOBAL +# CHECK-NEXT: Index: 1 diff --git a/lld/test/wasm/call-indirect.ll b/lld/test/wasm/call-indirect.ll --- a/lld/test/wasm/call-indirect.ll +++ b/lld/test/wasm/call-indirect.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/call-indirect.ll -o %t2.o ; 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 @@ -121,9 +121,7 @@ ; CHECK-NEXT: Body: 42010B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: - Type: I32 -; CHECK-NEXT: Count: 1 -; CHECK-NEXT: Body: 4100280284888080002100410028028088808000118080808000001A2000118180808000001A0B +; CHECK-NEXT: Body: 28028088808000118080808000001A28028488808000118180808000001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B diff --git a/lld/test/wasm/compress-relocs.ll b/lld/test/wasm/compress-relocs.ll --- a/lld/test/wasm/compress-relocs.ll +++ b/lld/test/wasm/compress-relocs.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/call-indirect.ll -o %t2.o ; 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 ; RUN: wasm-ld --export-dynamic -O2 -o %t-opt.wasm %t2.o %t.o @@ -22,5 +22,5 @@ ; ERROR: wasm-ld: error: --compress-relocations is incompatible with output debug information. Please pass --strip-debug or --strip-all -; CHECK: Body: 4100280284888080002100410028028088808000118080808000001A2000118180808000001A0B -; COMPRESS: Body: 41002802840821004100280280081100001A20001101001A0B +; CHECK: Body: 28028088808000118080808000001A28028488808000118180808000001A0B +; COMPRESS: Body: 280280081100001A280284081101001A0B diff --git a/lld/test/wasm/conflict.test b/lld/test/wasm/conflict.test --- a/lld/test/wasm/conflict.test +++ b/lld/test/wasm/conflict.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o # RUN: not wasm-ld -o %t.wasm %t.ret32.o %t.ret32.o 2>&1 | FileCheck %s # CHECK: duplicate symbol: ret32 diff --git a/lld/test/wasm/data-layout.ll b/lld/test/wasm/data-layout.ll --- a/lld/test/wasm/data-layout.ll +++ b/lld/test/wasm/data-layout.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o ; RUN: llc -filetype=obj %s -o %t.o target triple = "wasm32-unknown-unknown" diff --git a/lld/test/wasm/demangle.ll b/lld/test/wasm/demangle.ll deleted file mode 100644 --- a/lld/test/wasm/demangle.ll +++ /dev/null @@ -1,19 +0,0 @@ -; RUN: llc -filetype=obj %s -o %t.o -; RUN: not wasm-ld -o %t.wasm %t.o 2>&1 | FileCheck %s - -; CHECK: error: {{.*}}.o: undefined symbol: foo(int) - -; RUN: not wasm-ld --no-demangle \ -; RUN: -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-NODEMANGLE %s - -; CHECK-NODEMANGLE: error: {{.*}}.o: undefined symbol: _Z3fooi - -target triple = "wasm32-unknown-unknown" - -declare void @_Z3fooi(i32); - -define hidden void @_start() local_unnamed_addr { -entry: - call void @_Z3fooi(i32 1) - ret void -} diff --git a/lld/test/wasm/demangle.s b/lld/test/wasm/demangle.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/demangle.s @@ -0,0 +1,18 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: not wasm-ld -o %t.wasm %t.o 2>&1 | FileCheck %s + +# CHECK: error: {{.*}}.o: undefined symbol: foo(int) + +# RUN: not wasm-ld --no-demangle \ +# RUN: -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-NODEMANGLE %s + +# CHECK-NODEMANGLE: error: {{.*}}.o: undefined symbol: _Z3fooi + + .globl _start +_start: + .functype _start () -> () + i32.const 1 + call _Z3fooi + end_function + +.functype _Z3fooi (i32) -> () diff --git a/lld/test/wasm/emit-relocs-fpic.s b/lld/test/wasm/emit-relocs-fpic.s --- a/lld/test/wasm/emit-relocs-fpic.s +++ b/lld/test/wasm/emit-relocs-fpic.s @@ -1,5 +1,5 @@ # RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s -# RUN: llc --relocation-model=pic -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o # RUN: wasm-ld -pie --export-all --no-gc-sections --no-entry --emit-relocs -o %t.wasm %t.o %t.ret32.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/emit-relocs.ll b/lld/test/wasm/emit-relocs.ll --- a/lld/test/wasm/emit-relocs.ll +++ b/lld/test/wasm/emit-relocs.ll @@ -1,5 +1,5 @@ ; RUN: llc -filetype=obj %s -o %t.o -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o ; RUN: wasm-ld --emit-relocs -o %t.wasm %t.o %t.ret32.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/entry-signature.ll b/lld/test/wasm/entry-signature.ll deleted file mode 100644 --- a/lld/test/wasm/entry-signature.ll +++ /dev/null @@ -1,10 +0,0 @@ -; Verify that the entry point signature can be flexible. -; RUN: llc -filetype=obj %s -o %t.o -; RUN: wasm-ld -o %t1.wasm %t.o - -target triple = "wasm32-unknown-unknown-wasm" - -define hidden i32 @_start(i32, i64) local_unnamed_addr #0 { -entry: - ret i32 0 -} diff --git a/lld/test/wasm/entry-signature.s b/lld/test/wasm/entry-signature.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/entry-signature.s @@ -0,0 +1,8 @@ +# Verify that the entry point signature can be flexible. +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld -o %t1.wasm %t.o + + .globl _start +_start: + .functype _start (i64) -> (f32) + end_function diff --git a/lld/test/wasm/export-empty.test b/lld/test/wasm/export-empty.test --- a/lld/test/wasm/export-empty.test +++ b/lld/test/wasm/export-empty.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o RUN: not wasm-ld --export "" %t.o -o %t.wasm 2>&1 | FileCheck --match-full-lines %s CHECK: wasm-ld: error: symbol exported via --export not found: diff --git a/lld/test/wasm/export-optional-lazy.ll b/lld/test/wasm/export-optional-lazy.ll deleted file mode 100644 --- a/lld/test/wasm/export-optional-lazy.ll +++ /dev/null @@ -1,25 +0,0 @@ -; Optional linker-synthetic symbols are only created if they are undefined -; in the final output. -; This test is for a regression where an explicit --export of an lazy archive -; symbol caused an undefined reference to an optional symbol to occur *after* -; the optional symbols were created. - -; RUN: llc -filetype=obj %s -o %t.o -; RUN: llc -filetype=obj %S/Inputs/optional-symbol.ll -o %t.a1.o -; RUN: rm -f %t.a -; RUN: llvm-ar rcs %t.a %t.a1.o -; RUN: wasm-ld --export=get_optional %t.o %t.a -o %t.wasm -; RUN: obj2yaml %t.wasm | FileCheck %s - -target triple = "wasm32-unknown-unknown" - -define void @_start() { -entry: - ret void -} - -; CHECK: FunctionNames: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: get_optional diff --git a/lld/test/wasm/export-optional-lazy.test b/lld/test/wasm/export-optional-lazy.test new file mode 100644 --- /dev/null +++ b/lld/test/wasm/export-optional-lazy.test @@ -0,0 +1,18 @@ +Optional linker-synthetic symbols are only created if they are undefined +in the final output. +This test is for a regression where an explicit --export of an lazy archive +symbol caused an undefined reference to an optional symbol to occur *after* +the optional symbols were created. + +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/optional-symbol.s -o %t.a1.o +RUN: rm -f %t.a +RUN: llvm-ar rcs %t.a %t.a1.o +RUN: wasm-ld --export=get_optional %t.o %t.a -o %t.wasm +RUN: obj2yaml %t.wasm | FileCheck %s + +CHECK: FunctionNames: +CHECK-NEXT: - Index: 0 +CHECK-NEXT: Name: _start +CHECK-NEXT: - Index: 1 +CHECK-NEXT: Name: get_optional diff --git a/lld/test/wasm/export-table.test b/lld/test/wasm/export-table.test --- a/lld/test/wasm/export-table.test +++ b/lld/test/wasm/export-table.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o # RUN: wasm-ld --export-table -o %t.wasm %t.start.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/fatal-warnings.ll b/lld/test/wasm/fatal-warnings.ll --- a/lld/test/wasm/fatal-warnings.ll +++ b/lld/test/wasm/fatal-warnings.ll @@ -1,5 +1,5 @@ ; RUN: llc -filetype=obj %s -o %t.main.o -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.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 diff --git a/lld/test/wasm/function-imports-first.ll b/lld/test/wasm/function-imports-first.ll --- a/lld/test/wasm/function-imports-first.ll +++ b/lld/test/wasm/function-imports-first.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; 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.o %t.ret32.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/function-imports.ll b/lld/test/wasm/function-imports.ll --- a/lld/test/wasm/function-imports.ll +++ b/lld/test/wasm/function-imports.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; 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 diff --git a/lld/test/wasm/function-index.test b/lld/test/wasm/function-index.test --- a/lld/test/wasm/function-index.test +++ b/lld/test/wasm/function-index.test @@ -1,5 +1,5 @@ -# RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o -# RUN: llc -filetype=obj %p/Inputs/ret64.ll -o %t.ret64.o +# 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 %p/Inputs/ret64.s -o %t.ret64.o # RUN: wasm-ld -r -o %t.wasm %t.ret32.o %t.ret64.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/global-base.test b/lld/test/wasm/global-base.test --- a/lld/test/wasm/global-base.test +++ b/lld/test/wasm/global-base.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o RUN: wasm-ld --export=__global_base --export=__data_end --allow-undefined -o %t.wasm %t.o RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=CHECK-1024 diff --git a/lld/test/wasm/growable-table.test b/lld/test/wasm/growable-table.test --- a/lld/test/wasm/growable-table.test +++ b/lld/test/wasm/growable-table.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o # RUN: wasm-ld --export-table --growable-table -o %t.wasm %t.start.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/import-attribute-mismatch.ll b/lld/test/wasm/import-attribute-mismatch.ll deleted file mode 100644 --- a/lld/test/wasm/import-attribute-mismatch.ll +++ /dev/null @@ -1,18 +0,0 @@ -; RUN: llc -filetype=obj %s -o %t1.o -; RUN: llc -filetype=obj %S/Inputs/import-attributes.ll -o %t2.o -; RUN: not wasm-ld --export call_foo --allow-undefined -o %t.wasm %t1.o %t2.o 2>&1 | FileCheck %s - -target triple = "wasm32-unknown-unknown-wasm" - -define void @_start() { - call void @foo(); - ret void -} - -declare void @foo() #0 - -attributes #0 = { "wasm-import-module"="bar" } - -; CHECK: wasm-ld: error: import module mismatch for symbol: foo -; CHECK: >>> defined as bar in {{.*}}1.o -; CHECK: >>> defined as baz in {{.*}}2.o diff --git a/lld/test/wasm/import-attribute-mismatch.s b/lld/test/wasm/import-attribute-mismatch.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/import-attribute-mismatch.s @@ -0,0 +1,16 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t1.o %s +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %S/Inputs/import-attributes.s -o %t2.o +# RUN: not wasm-ld --export call_foo --allow-undefined -o %t.wasm %t1.o %t2.o 2>&1 | FileCheck %s + + .globl _start +_start: + .functype _start () -> () + call foo + end_function + +.functype foo () -> () +.import_module foo, bar + +# CHECK: wasm-ld: error: import module mismatch for symbol: foo +# CHECK: >>> defined as bar in {{.*}}1.o +# CHECK: >>> defined as baz in {{.*}}2.o diff --git a/lld/test/wasm/import-memory.test b/lld/test/wasm/import-memory.test --- a/lld/test/wasm/import-memory.test +++ b/lld/test/wasm/import-memory.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o # RUN: wasm-ld --import-memory -o %t.wasm %t.start.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/import-table.test b/lld/test/wasm/import-table.test --- a/lld/test/wasm/import-table.test +++ b/lld/test/wasm/import-table.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o # RUN: wasm-ld --import-table -o %t.wasm %t.start.o # RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/invalid-stack-size.test b/lld/test/wasm/invalid-stack-size.test --- a/lld/test/wasm/invalid-stack-size.test +++ b/lld/test/wasm/invalid-stack-size.test @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o ; RUN: not wasm-ld -o %t.wasm -z stack-size=1 %t.o 2>&1 | FileCheck %s ; CHECK: error: stack size must be 16-byte aligned diff --git a/lld/test/wasm/large-memory.test b/lld/test/wasm/large-memory.test --- a/lld/test/wasm/large-memory.test +++ b/lld/test/wasm/large-memory.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o ; Verify we can parse large integers such as when we ask for 2G of total ; memory. diff --git a/lld/test/wasm/load-undefined.test b/lld/test/wasm/load-undefined.test --- a/lld/test/wasm/load-undefined.test +++ b/lld/test/wasm/load-undefined.test @@ -1,9 +1,9 @@ ; Verify that the -u / --undefined option is able to pull in symbols from ; an archive, and doesn't error when uses to pull in a symbol already loaded. ; -; RUN: llc -filetype=obj %S/Inputs/ret64.ll -o %t.o -; RUN: llc -filetype=obj %S/Inputs/ret32.ll -o %t2.o -; RUN: llc -filetype=obj %S/Inputs/start.ll -o %t.start.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret64.s -o %t.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t2.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o ; RUN: rm -f %t2.a ; RUN: llvm-ar rcs %t2.a %t2.o ; RUN: wasm-ld %t.start.o --no-gc-sections %t2.a %t.o -o %t.wasm -u ret32 --undefined ret64 diff --git a/lld/test/wasm/no-tls.ll b/lld/test/wasm/no-tls.ll new file mode 100644 --- /dev/null +++ b/lld/test/wasm/no-tls.ll @@ -0,0 +1,48 @@ +; Testing that __tls_size and __tls_align are correctly emitted when there are +; no thread_local variables. + +; RUN: llc -mattr=+bulk-memory,+atomics -filetype=obj %s -o %t.o + +target triple = "wasm32-unknown-unknown" + +define void @_start() local_unnamed_addr { +entry: + ret void +} + +; RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --allow-undefined -o %t.wasm %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s +; CHECK: - Type: GLOBAL +; CHECK-NEXT: Globals: + +; __stack_pointer +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66576 + +; __tls_base +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 + +; __tls_size +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 + +; __tls_align +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1 diff --git a/lld/test/wasm/no-tls.test b/lld/test/wasm/no-tls.test deleted file mode 100644 --- a/lld/test/wasm/no-tls.test +++ /dev/null @@ -1,41 +0,0 @@ -; Testing that __tls_size and __tls_align are correctly emitted when there are -; no thread_local variables. - -RUN: llc -mattr=+bulk-memory,+atomics -filetype=obj %p/Inputs/start.ll -o %t.o - -RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --allow-undefined -o %t.wasm %t.o -RUN: obj2yaml %t.wasm | FileCheck %s -CHECK: - Type: GLOBAL -CHECK-NEXT: Globals: - -; __stack_pointer -CHECK-NEXT: - Index: 0 -CHECK-NEXT: Type: I32 -CHECK-NEXT: Mutable: true -CHECK-NEXT: InitExpr: -CHECK-NEXT: Opcode: I32_CONST -CHECK-NEXT: Value: 66576 - -; __tls_base -CHECK-NEXT: - Index: 1 -CHECK-NEXT: Type: I32 -CHECK-NEXT: Mutable: true -CHECK-NEXT: InitExpr: -CHECK-NEXT: Opcode: I32_CONST -CHECK-NEXT: Value: 0 - -; __tls_size -CHECK-NEXT: - Index: 2 -CHECK-NEXT: Type: I32 -CHECK-NEXT: Mutable: false -CHECK-NEXT: InitExpr: -CHECK-NEXT: Opcode: I32_CONST -CHECK-NEXT: Value: 0 - -; __tls_align -CHECK-NEXT: - Index: 3 -CHECK-NEXT: Type: I32 -CHECK-NEXT: Mutable: false -CHECK-NEXT: InitExpr: -CHECK-NEXT: Opcode: I32_CONST -CHECK-NEXT: Value: 1 diff --git a/lld/test/wasm/optional-symbol.ll b/lld/test/wasm/optional-symbol.ll deleted file mode 100644 --- a/lld/test/wasm/optional-symbol.ll +++ /dev/null @@ -1,14 +0,0 @@ -; RUN: llc -filetype=obj -o %t.o %s -; RUN: wasm-ld --export=get_handle %t.o -o %t.wasm - -target triple = "wasm32-unknown-unknown" - -@__dso_handle = external global i8* - -define i8** @get_handle() { - ret i8** @__dso_handle -} - -define void @_start() { - ret void -} diff --git a/lld/test/wasm/optional-symbol.s b/lld/test/wasm/optional-symbol.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/optional-symbol.s @@ -0,0 +1,13 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld --export=get_handle %t.o -o %t.wasm + + .globl get_handle +get_handle: + .functype get_handle () -> (i32) + i32.const __dso_handle + end_function + + .globl _start +_start: + .functype _start () -> () + end_function diff --git a/lld/test/wasm/pic-static.ll b/lld/test/wasm/pic-static.ll --- a/lld/test/wasm/pic-static.ll +++ b/lld/test/wasm/pic-static.ll @@ -1,7 +1,7 @@ ; Test that PIC code can be linked into static binaries. ; In this case the GOT entries will end up as internalized wasm globals with ; fixed values. -; RUN: llc -relocation-model=pic -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o ; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o ; RUN: wasm-ld --allow-undefined --export-all -o %t.wasm %t.o %t.ret32.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/relocatable.ll b/lld/test/wasm/relocatable.ll --- a/lld/test/wasm/relocatable.ll +++ b/lld/test/wasm/relocatable.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o ; RUN: llc -filetype=obj %s -o %t.o ; RUN: wasm-ld -r -o %t.wasm %t.hello.o %t.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/responsefile.test b/lld/test/wasm/responsefile.test --- a/lld/test/wasm/responsefile.test +++ b/lld/test/wasm/responsefile.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj -o %t.o %p/Inputs/ret32.ll +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.o RUN: echo "%/t.o -o %/t.wasm -e ret32" > %t.rsp RUN: wasm-ld @%t.rsp --initial-memory=655360 diff --git a/lld/test/wasm/shared-needed.ll b/lld/test/wasm/shared-needed.ll --- a/lld/test/wasm/shared-needed.ll +++ b/lld/test/wasm/shared-needed.ll @@ -1,5 +1,5 @@ ; RUN: llc -filetype=obj %s -o %t.o -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o ; RUN: wasm-ld -shared -o %t1.so %t.o ; RUN: obj2yaml %t1.so | FileCheck %s -check-prefix=SO1 diff --git a/lld/test/wasm/signature-mismatch-export.ll b/lld/test/wasm/signature-mismatch-export.ll --- a/lld/test/wasm/signature-mismatch-export.ll +++ b/lld/test/wasm/signature-mismatch-export.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o ; RUN: llc -filetype=obj %s -o %t.main.o ; RUN: wasm-ld --export=ret32 -o %t.wasm %t.main.o %t.ret32.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/signature-mismatch-unknown.ll b/lld/test/wasm/signature-mismatch-unknown.ll --- a/lld/test/wasm/signature-mismatch-unknown.ll +++ b/lld/test/wasm/signature-mismatch-unknown.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o ; RUN: llc -filetype=obj %s -o %t.main.o ; RUN: wasm-ld --fatal-warnings -o %t.wasm %t.ret32.o %t.main.o ; RUN: wasm-ld --fatal-warnings -o %t.wasm %t.main.o %t.ret32.o @@ -7,7 +7,7 @@ ; references ret32: ; %t.main.o: Does not call ret32 directly; used the wrong signature. ; %t.call-ret32.o: Calls ret32 directly; uses the correct signature. -; RUN: llc -filetype=obj %p/Inputs/call-ret32.ll -o %t.call-ret32.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/call-ret32.s -o %t.call-ret32.o ; RUN: wasm-ld --export=call_ret32 --fatal-warnings -o %t.wasm %t.main.o %t.call-ret32.o %t.ret32.o ; RUN: wasm-ld --export=call_ret32 --fatal-warnings -o %t.wasm %t.call-ret32.o %t.main.o %t.ret32.o diff --git a/lld/test/wasm/signature-mismatch-weak.ll b/lld/test/wasm/signature-mismatch-weak.ll --- a/lld/test/wasm/signature-mismatch-weak.ll +++ b/lld/test/wasm/signature-mismatch-weak.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/weak-symbol1.ll -o %t.weak.o -; RUN: llc -filetype=obj %p/Inputs/strong-symbol.ll -o %t.strong.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/weak-symbol1.s -o %t.weak.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/strong-symbol.s -o %t.strong.o ; RUN: llc -filetype=obj %s -o %t.o ; RUN: wasm-ld -o %t.wasm %t.o %t.strong.o %t.weak.o 2>&1 | FileCheck %s diff --git a/lld/test/wasm/signature-mismatch.ll b/lld/test/wasm/signature-mismatch.ll --- a/lld/test/wasm/signature-mismatch.ll +++ b/lld/test/wasm/signature-mismatch.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o -; RUN: llc -filetype=obj %p/Inputs/call-ret32.ll -o %t.call.o +; 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 %p/Inputs/call-ret32.s -o %t.call.o ; RUN: llc -filetype=obj %s -o %t.main.o ; RUN: wasm-ld --export=call_ret32 --export=ret32 -o %t.wasm %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=WARN @@ -76,7 +76,7 @@ ; RELOC-NEXT: - Index: 3 ; RELOC-NEXT: Kind: FUNCTION ; RELOC-NEXT: Name: call_ret32 -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; RELOC-NEXT: Flags: [ ] ; RELOC-NEXT: Function: 3 ; RELOC-NEXT: - Index: 4 ; RELOC-NEXT: Kind: DATA diff --git a/lld/test/wasm/stack-first.test b/lld/test/wasm/stack-first.test --- a/lld/test/wasm/stack-first.test +++ b/lld/test/wasm/stack-first.test @@ -3,7 +3,7 @@ ; stack size of 512. This means (since the stack grows down) the stack pointer ; global should be initialized to 512. -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base -o %t.wasm %t.o RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/strip-all.test b/lld/test/wasm/strip-all.test --- a/lld/test/wasm/strip-all.test +++ b/lld/test/wasm/strip-all.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o RUN: wasm-ld --strip-all -o %t.wasm %t.start.o RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/strip-debug.test b/lld/test/wasm/strip-debug.test --- a/lld/test/wasm/strip-debug.test +++ b/lld/test/wasm/strip-debug.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o RUN: wasm-ld --strip-debug -o %t.wasm %t.start.o RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/symbol-type-mismatch.ll b/lld/test/wasm/symbol-type-mismatch.ll deleted file mode 100644 --- a/lld/test/wasm/symbol-type-mismatch.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llc -filetype=obj %s -o %t.o -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o -; RUN: not wasm-ld -o %t.wasm %t.o %t.ret32.o 2>&1 | FileCheck %s - -target triple = "wasm32-unknown-unknown" - -@ret32 = extern_weak global i32, align 4 - -; CHECK: error: symbol type mismatch: ret32 -; CHECK: >>> defined as WASM_SYMBOL_TYPE_DATA in {{.*}}symbol-type-mismatch.ll.tmp.o -; CHECK: >>> defined as WASM_SYMBOL_TYPE_FUNCTION in {{.*}}.ret32.o diff --git a/lld/test/wasm/symbol-type-mismatch.s b/lld/test/wasm/symbol-type-mismatch.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/symbol-type-mismatch.s @@ -0,0 +1,9 @@ +# 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: not wasm-ld -o %t.wasm %t.o %t.ret32.o 2>&1 | FileCheck %s + +.weak ret32 + +# CHECK: error: symbol type mismatch: ret32 +# CHECK: >>> defined as WASM_SYMBOL_TYPE_DATA in {{.*}}symbol-type-mismatch.s.tmp.o +# CHECK: >>> defined as WASM_SYMBOL_TYPE_FUNCTION in {{.*}}.ret32.o diff --git a/lld/test/wasm/trace-symbol.ll b/lld/test/wasm/trace-symbol.ll --- a/lld/test/wasm/trace-symbol.ll +++ b/lld/test/wasm/trace-symbol.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +; 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 diff --git a/lld/test/wasm/trace.test b/lld/test/wasm/trace.test --- a/lld/test/wasm/trace.test +++ b/lld/test/wasm/trace.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.foo.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.foo.o # Check -t RUN: wasm-ld %t.foo.o -o %t.t.out.wasm -t 2>&1 | FileCheck %s diff --git a/lld/test/wasm/undefined-entry.test b/lld/test/wasm/undefined-entry.test --- a/lld/test/wasm/undefined-entry.test +++ b/lld/test/wasm/undefined-entry.test @@ -1,4 +1,4 @@ -RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o RUN: not wasm-ld -o %t.wasm %t.ret32.o 2>&1 | FileCheck %s RUN: not wasm-ld --allow-undefined -o %t.wasm %t.ret32.o 2>&1 | FileCheck %s RUN: not wasm-ld -entry=foo -o %t.wasm %t.ret32.o 2>&1 | FileCheck %s -check-prefix=CHECK-CUSTOM diff --git a/lld/test/wasm/version.ll b/lld/test/wasm/version.ll deleted file mode 100644 --- a/lld/test/wasm/version.ll +++ /dev/null @@ -1,15 +0,0 @@ -; RUN: llc -filetype=obj %s -o %t.o -; RUN: wasm-ld -o %t.wasm %t.o -; RUN: llvm-readobj --file-headers %t.wasm | FileCheck %s - -target triple = "wasm32-unknown-unknown" - -define hidden void @_start() local_unnamed_addr #0 { -entry: - ret void -} - -; CHECK: Format: WASM -; CHECK: Arch: wasm32 -; CHECK: AddressSize: 32bit -; CHECK: Version: 0x1 diff --git a/lld/test/wasm/version.s b/lld/test/wasm/version.s new file mode 100644 --- /dev/null +++ b/lld/test/wasm/version.s @@ -0,0 +1,13 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld -o %t.wasm %t.o +# RUN: llvm-readobj --file-headers %t.wasm | FileCheck %s + + .globl _start +_start: + .functype _start () -> () + end_function + +# CHECK: Format: WASM +# CHECK: Arch: wasm32 +# CHECK: AddressSize: 32bit +# CHECK: Version: 0x1 diff --git a/lld/test/wasm/visibility-hidden.ll b/lld/test/wasm/visibility-hidden.ll --- a/lld/test/wasm/visibility-hidden.ll +++ b/lld/test/wasm/visibility-hidden.ll @@ -1,5 +1,5 @@ ; RUN: llc -filetype=obj -o %t.o %s -; RUN: llc -filetype=obj %S/Inputs/hidden.ll -o %t2.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hidden.s -o %t2.o ; RUN: rm -f %t2.a ; RUN: llvm-ar rcs %t2.a %t2.o diff --git a/lld/test/wasm/weak-symbols.ll b/lld/test/wasm/weak-symbols.ll --- a/lld/test/wasm/weak-symbols.ll +++ b/lld/test/wasm/weak-symbols.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/weak-symbol1.ll -o %t1.o -; RUN: llc -filetype=obj %p/Inputs/weak-symbol2.ll -o %t2.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/weak-symbol1.s -o %t1.o +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/weak-symbol2.s -o %t2.o ; RUN: llc -filetype=obj %s -o %t.o ; RUN: wasm-ld --export-dynamic -o %t.wasm %t.o %t1.o %t2.o ; RUN: obj2yaml %t.wasm | FileCheck %s diff --git a/lld/test/wasm/whole-archive.test b/lld/test/wasm/whole-archive.test --- a/lld/test/wasm/whole-archive.test +++ b/lld/test/wasm/whole-archive.test @@ -1,5 +1,5 @@ -RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o -RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o +RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o RUN: rm -f %t.a RUN: llvm-ar rcs %t.a %t.ret32.o