[lld] 48129cf - [lld][WebAsssembly] Convert more tests from IR to assembly. NFC

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 13:53:16 PDT 2022


Author: Sam Clegg
Date: 2022-07-29T13:52:52-07:00
New Revision: 48129cf0ed5053ed3fdf4f928180635e84892614

URL: https://github.com/llvm/llvm-project/commit/48129cf0ed5053ed3fdf4f928180635e84892614
DIFF: https://github.com/llvm/llvm-project/commit/48129cf0ed5053ed3fdf4f928180635e84892614.diff

LOG: [lld][WebAsssembly] Convert more tests from IR to assembly. NFC

Differential Revision: https://reviews.llvm.org/D130738

Added: 
    lld/test/wasm/archive-weak-undefined.s
    lld/test/wasm/wrap.s

Modified: 
    

Removed: 
    lld/test/wasm/archive-weak-undefined.ll
    lld/test/wasm/wrap.ll


################################################################################
diff  --git a/lld/test/wasm/archive-weak-undefined.ll b/lld/test/wasm/archive-weak-undefined.ll
deleted file mode 100644
index 297f01c803432..0000000000000
--- a/lld/test/wasm/archive-weak-undefined.ll
+++ /dev/null
@@ -1,43 +0,0 @@
-;; Test that weak undefined symbols do not fetch members from archive files.
-; RUN: llc -filetype=obj %s -o %t.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
-
-; RUN: wasm-ld %t.o %t.a -o %t.wasm
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-;; Also test with the library symbols being read first
-; RUN: wasm-ld %t.a %t.o -o %t2.wasm
-; RUN: obj2yaml %t2.wasm | FileCheck %s
-
-; RUN: wasm-ld -u hello_str %t.o %t.a -o %t2.wasm
-; RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=CHECK-DATA
-
-target triple = "wasm32-unknown-unknown"
-
-; Weak external function symbol
-declare extern_weak i32 @ret32()
-
-; Weak external data symbol
- at hello_str = extern_weak global i8*, align 4
-
-define void @_start() {
-  br i1 icmp ne (i8** @hello_str, i8** null), label %if.then, label %if.end
-
-if.then:
-  %call1 = call i32 @ret32()
-  br label %if.end
-
-if.end:
-  ret void
-}
-
-; Ensure we have no data section.  If we do, would mean that hello_str was
-; pulled out of the library.
-; CHECK-NOT:  Type:            DATA
-; CHECK-DATA: Type:            DATA
-
-; CHECK: Name: 'undefined_weak:ret32'
-; CHECK-NOT: Name: ret32

diff  --git a/lld/test/wasm/archive-weak-undefined.s b/lld/test/wasm/archive-weak-undefined.s
new file mode 100644
index 0000000000000..ec95787bd0ee5
--- /dev/null
+++ b/lld/test/wasm/archive-weak-undefined.s
@@ -0,0 +1,43 @@
+## Test that weak undefined symbols do not fetch members from archive files.
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.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
+
+# RUN: wasm-ld %t.o %t.a -o %t.wasm
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+## Also test with the library symbols being read first
+# RUN: wasm-ld %t.a %t.o -o %t2.wasm
+# RUN: obj2yaml %t2.wasm | FileCheck %s
+
+# RUN: wasm-ld -u hello_str %t.o %t.a -o %t2.wasm
+# RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=CHECK-DATA
+
+# Weak external function symbol
+.weak ret32
+.functype ret32 () -> (i32)
+
+# Weak external data symbol
+.weak hello_str
+
+.globl  _start
+_start:
+  .functype _start () -> ()
+  block
+  i32.const hello_str
+  i32.eqz
+  br_if 0
+  call ret32
+  drop
+  end_block
+  end_function
+
+# Ensure we have no data section.  If we do, would mean that hello_str was
+# pulled out of the library.
+# CHECK-NOT:  Type:            DATA
+# CHECK-DATA: Type:            DATA
+
+# CHECK: Name: 'undefined_weak:ret32'
+# CHECK-NOT: Name: ret32

diff  --git a/lld/test/wasm/wrap.ll b/lld/test/wasm/wrap.ll
deleted file mode 100644
index df705b9d60187..0000000000000
--- a/lld/test/wasm/wrap.ll
+++ /dev/null
@@ -1,40 +0,0 @@
-; RUN: llc -filetype=obj %s -o %t.o
-; RUN: wasm-ld -wrap nosuchsym -wrap foo -o %t.wasm %t.o
-; RUN: wasm-ld -emit-relocs -wrap foo -o %t.wasm %t.o
-; RUN: obj2yaml %t.wasm | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-define i32 @foo() {
-  ret i32 1
-}
-
-define void @_start() {
-entry:
-  call i32 @foo()
-  ret void
-}
-
-declare i32 @__real_foo()
-
-define i32 @__wrap_foo() {
-  %rtn = call i32 @__real_foo()
-  ret i32 %rtn
-}
-
-; CHECK:      - Type:            CODE
-; CHECK-NEXT:   Relocations:     
-; CHECK-NEXT:     - Type:            R_WASM_FUNCTION_INDEX_LEB
-; CHECK-NEXT:       Index:           2
-; CHECK-NEXT:       Offset:          0x9
-; CHECK-NEXT:     - Type:            R_WASM_FUNCTION_INDEX_LEB
-; CHECK-NEXT:       Index:           0
-; CHECK-NEXT:       Offset:          0x13
-
-; CHECK:        FunctionNames:
-; CHECK-NEXT:      - Index:           0
-; CHECK-NEXT:        Name:            foo
-; CHECK-NEXT:      - Index:           1
-; CHECK-NEXT:        Name:            _start
-; CHECK-NEXT:      - Index:           2
-; CHECK-NEXT:        Name:            __wrap_foo

diff  --git a/lld/test/wasm/wrap.s b/lld/test/wasm/wrap.s
new file mode 100644
index 0000000000000..6c6b8baa82b69
--- /dev/null
+++ b/lld/test/wasm/wrap.s
@@ -0,0 +1,42 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
+# RUN: wasm-ld -wrap nosuchsym -wrap foo -o %t.wasm %t.o
+# RUN: wasm-ld -emit-relocs -wrap foo -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+.functype __real_foo () -> (i32)
+.globl foo
+.globl _start
+.globl __wrap_foo
+
+foo:
+  .functype foo () -> (i32)
+  i32.const 1
+  end_function
+
+_start:
+  .functype _start () -> ()
+  call  foo
+  drop
+  end_function
+
+__wrap_foo:
+  .functype __wrap_foo () -> (i32)
+  call  __real_foo
+  end_function
+
+# CHECK:      - Type:            CODE
+# CHECK-NEXT:   Relocations:
+# CHECK-NEXT:     - Type:            R_WASM_FUNCTION_INDEX_LEB
+# CHECK-NEXT:       Index:           2
+# CHECK-NEXT:       Offset:
+# CHECK-NEXT:     - Type:            R_WASM_FUNCTION_INDEX_LEB
+# CHECK-NEXT:       Index:           0
+# CHECK-NEXT:       Offset:
+
+# CHECK:        FunctionNames:
+# CHECK-NEXT:      - Index:           0
+# CHECK-NEXT:        Name:            foo
+# CHECK-NEXT:      - Index:           1
+# CHECK-NEXT:        Name:            _start
+# CHECK-NEXT:      - Index:           2
+# CHECK-NEXT:        Name:            __wrap_foo


        


More information about the llvm-commits mailing list