Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
3 changed files
with
133 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 different 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: ] |