[llvm] db7b1af - [WebAssembly] Covert llvm/test/MC/WebAssembly/reloc-code.ll to asm. NFC
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 25 07:12:44 PST 2022
Author: Sam Clegg
Date: 2022-02-25T07:12:32-08:00
New Revision: db7b1af8ef8f59600cbb6e529164acdbe4c8f0a2
URL: https://github.com/llvm/llvm-project/commit/db7b1af8ef8f59600cbb6e529164acdbe4c8f0a2
DIFF: https://github.com/llvm/llvm-project/commit/db7b1af8ef8f59600cbb6e529164acdbe4c8f0a2.diff
LOG: [WebAssembly] Covert llvm/test/MC/WebAssembly/reloc-code.ll to asm. NFC
Also increase coverage of call_indirect via explict function table
(enabled when reference types is enabled) in
llvm/test/CodeGen/WebAssembly/call-indirect.ll (I believe this
was an oversight that it was not added in https://reviews.llvm.org/D90948)
Differential Revision: https://reviews.llvm.org/D120521
Added:
llvm/test/MC/WebAssembly/reloc-code.s
Modified:
llvm/test/CodeGen/WebAssembly/call-indirect.ll
Removed:
llvm/test/MC/WebAssembly/reloc-code.ll
################################################################################
diff --git a/llvm/test/CodeGen/WebAssembly/call-indirect.ll b/llvm/test/CodeGen/WebAssembly/call-indirect.ll
index 7a174318d4732..d5bb749d8a1d7 100644
--- a/llvm/test/CodeGen/WebAssembly/call-indirect.ll
+++ b/llvm/test/CodeGen/WebAssembly/call-indirect.ll
@@ -1,4 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -O2 | FileCheck --check-prefix=CHECK %s
+; RUN: llc < %s -asm-verbose=false -O2 | FileCheck --check-prefixes=CHECK,NOREF %s
+; RUN: llc < %s -asm-verbose=false -mattr=+reference-types -O2 | FileCheck --check-prefixes=CHECK,REF %s
; RUN: llc < %s -asm-verbose=false -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=OBJ %s
; Test that compilation units with call_indirect but without any
@@ -9,7 +10,8 @@ target triple = "wasm32-unknown-unknown"
; CHECK-LABEL: call_indirect_void:
; CHECK-NEXT: .functype call_indirect_void (i32) -> ()
; CHECK-NEXT: local.get 0
-; CHECK-NEXT: call_indirect () -> ()
+; REF: call_indirect __indirect_function_table, () -> ()
+; NOREF: call_indirect () -> ()
; CHECK-NEXT: end_function
define void @call_indirect_void(void ()* %callee) {
call void %callee()
diff --git a/llvm/test/MC/WebAssembly/reloc-code.ll b/llvm/test/MC/WebAssembly/reloc-code.ll
deleted file mode 100644
index e80fbcf80cd35..0000000000000
--- a/llvm/test/MC/WebAssembly/reloc-code.ll
+++ /dev/null
@@ -1,110 +0,0 @@
-; RUN: llc -filetype=obj %s -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
-; RUN: llc -filetype=obj -mattr=+reference-types %s -o - | llvm-readobj -r --expand-relocs - | FileCheck --check-prefix=REF %s
-
-target triple = "wasm32-unknown-unknown"
-
-; Pointers to functions of two
diff erent types
- at a = global i64 ()* inttoptr (i64 5 to i64 ()*), align 8
- at b = global i32 ()* inttoptr (i32 7 to i32 ()*), align 8
-
-; External functions
-declare i32 @c()
-declare i32 @d()
-
-define i32 @f1() {
-entry:
- %aa = load i64 ()*, i64 ()** @a, align 8
- %bb = load i32 ()*, i32 ()** @b, align 8
- %tmp1 = call i64 %aa()
- %tmp2 = call i32 %bb()
- %tmp3 = call i32 @c()
- %tmp4 = call i32 @d()
- ret i32 %tmp2
-}
-
-
-; CHECK: Format: WASM
-; CHECK: Relocations [
-; CHECK-NEXT: Section (5) CODE {
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
-; CHECK-NEXT: Offset: 0x9
-; CHECK-NEXT: Symbol: b
-; CHECK-NEXT: Addend: 0
-; CHECK-NEXT: }
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
-; CHECK-NEXT: Offset: 0x14
-; CHECK-NEXT: Symbol: a
-; CHECK-NEXT: Addend: 0
-; CHECK-NEXT: }
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
-; CHECK-NEXT: Offset: 0x1A
-; CHECK-NEXT: Index: 0x1
-; CHECK-NEXT: }
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
-; CHECK-NEXT: Offset: 0x24
-; CHECK-NEXT: Index: 0x0
-; CHECK-NEXT: }
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
-; CHECK-NEXT: Offset: 0x2D
-; CHECK-NEXT: Symbol: c
-; CHECK-NEXT: }
-; CHECK-NEXT: Relocation {
-; CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
-; CHECK-NEXT: Offset: 0x34
-; CHECK-NEXT: Symbol: d
-; CHECK-NEXT: }
-; CHECK-NEXT: }
-; CHECK-NEXT: ]
-
-; REF: Format: WASM
-; REF: Relocations [
-; REF-NEXT: Section (5) CODE {
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
-; REF-NEXT: Offset: 0x9
-; REF-NEXT: Symbol: b
-; REF-NEXT: Addend: 0
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
-; REF-NEXT: Offset: 0x14
-; REF-NEXT: Symbol: a
-; REF-NEXT: Addend: 0
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
-; REF-NEXT: Offset: 0x1A
-; REF-NEXT: Index: 0x1
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_TABLE_NUMBER_LEB (20)
-; REF-NEXT: Offset: 0x1F
-; REF-NEXT: Symbol: __indirect_function_table
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
-; REF-NEXT: Offset: 0x28
-; REF-NEXT: Index: 0x0
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_TABLE_NUMBER_LEB (20)
-; REF-NEXT: Offset: 0x2D
-; REF-NEXT: Symbol: __indirect_function_table
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
-; REF-NEXT: Offset: 0x35
-; REF-NEXT: Symbol: c
-; REF-NEXT: }
-; REF-NEXT: Relocation {
-; REF-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
-; REF-NEXT: Offset: 0x3C
-; REF-NEXT: Symbol: d
-; REF-NEXT: }
-; REF-NEXT: }
-; REF-NEXT: ]
diff --git a/llvm/test/MC/WebAssembly/reloc-code.s b/llvm/test/MC/WebAssembly/reloc-code.s
new file mode 100644
index 0000000000000..cd301098f9a8c
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/reloc-code.s
@@ -0,0 +1,129 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %s -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+reference-types -filetype=obj %s -o - | llvm-readobj -r --expand-relocs - | FileCheck --check-prefix=REF %s
+
+# External functions
+.functype c () -> (i32)
+.functype d () -> (i32)
+
+.globl f1
+.globl a
+.globl b
+
+f1:
+ .functype f1 () -> (i32)
+
+ # Call functions at `a` and `b` indirectly.
+ i32.const 0
+ i32.load a
+ call_indirect () -> (i64)
+ drop
+
+ i32.const 0
+ i32.load b
+ call_indirect () -> (i32)
+ drop
+
+ # Call functions `c` and `d` directly
+ call c
+ drop
+ call d
+ end_function
+
+# Pointers to functions of two
diff erent types
+.section .data.a,"",@
+.p2align 3
+a:
+ .int32 5
+ .size a, 4
+
+.section .data.b,"",@
+.p2align 3
+b:
+ .int32 7
+ .size b, 4
+
+# CHECK: Format: WASM
+# CHECK: Relocations [
+# CHECK-NEXT: Section (5) CODE {
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
+# CHECK-NEXT: Offset: 0x7
+# CHECK-NEXT: Symbol: a
+# CHECK-NEXT: Addend: 0
+# CHECK-NEXT: }
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
+# CHECK-NEXT: Offset: 0xD
+# CHECK-NEXT: Index: 0x1
+# CHECK-NEXT: }
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
+# CHECK-NEXT: Offset: 0x18
+# CHECK-NEXT: Symbol: b
+# CHECK-NEXT: Addend: 0
+# CHECK-NEXT: }
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
+# CHECK-NEXT: Offset: 0x1E
+# CHECK-NEXT: Index: 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
+# CHECK-NEXT: Offset: 0x26
+# CHECK-NEXT: Symbol: c
+# CHECK-NEXT: }
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
+# CHECK-NEXT: Offset: 0x2D
+# CHECK-NEXT: Symbol: d
+# CHECK-NEXT: }
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+# REF: Format: WASM
+# REF: Relocations [
+# REF-NEXT: Section (5) CODE {
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
+# REF-NEXT: Offset: 0x7
+# REF-NEXT: Symbol: a
+# REF-NEXT: Addend: 0
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
+# REF-NEXT: Offset: 0xD
+# REF-NEXT: Index: 0x1
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_TABLE_NUMBER_LEB (20)
+# REF-NEXT: Offset: 0x12
+# REF-NEXT: Symbol: __indirect_function_table
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
+# REF-NEXT: Offset: 0x1C
+# REF-NEXT: Symbol: b
+# REF-NEXT: Addend: 0
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_TYPE_INDEX_LEB (6)
+# REF-NEXT: Offset: 0x22
+# REF-NEXT: Index: 0x0
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_TABLE_NUMBER_LEB (20)
+# REF-NEXT: Offset: 0x27
+# REF-NEXT: Symbol: __indirect_function_table
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
+# REF-NEXT: Offset: 0x2E
+# REF-NEXT: Symbol: c
+# REF-NEXT: }
+# REF-NEXT: Relocation {
+# REF-NEXT: Type: R_WASM_FUNCTION_INDEX_LEB (0)
+# REF-NEXT: Offset: 0x35
+# REF-NEXT: Symbol: d
+# REF-NEXT: }
+# REF-NEXT: }
+# REF-NEXT: ]
More information about the llvm-commits
mailing list