summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2018-02-09 23:13:22 +0000
committerDan Gohman <dan433584@gmail.com>2018-02-09 23:13:22 +0000
commitdb1916a64620b3261fed450cbde047c730d758b5 (patch)
treeea5c58b41aae499f81679568893c6062ec390f88 /llvm/test
parent861bec2b7c69d885586725b9b0166913dbae6826 (diff)
downloadbcm5719-llvm-db1916a64620b3261fed450cbde047c730d758b5.tar.gz
bcm5719-llvm-db1916a64620b3261fed450cbde047c730d758b5.zip
[WebAssembly] Add mechanisms for specifying an explicit import module name.
This adds a wasm-import-module function attribute and a .import_module assembler directive, for specifying module import names for WebAssembly. Currently these may only be used for function symbols; global variables may be considered in the future. WebAssembly has a two-level namespace scheme for symbols, and it's normally the linker's job to assign the module name, which is the first-level name. The attributes here allow users to specify their own module names explicitly, which is useful for tools generating bindings to modules defined in other languages. This feature is not fully usable yet. It will evolve along with the ongoing symbol table and lld changes. Differential Revision: https://reviews.llvm.org/D42520 llvm-svn: 324778
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/WebAssembly/import-module.ll19
-rw-r--r--llvm/test/MC/WebAssembly/external-func-address.ll9
2 files changed, 27 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/import-module.ll b/llvm/test/CodeGen/WebAssembly/import-module.ll
new file mode 100644
index 00000000000..e748b7ec1c7
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/import-module.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+define void @test() {
+ call void @foo()
+ call void @plain()
+ ret void
+}
+
+declare void @foo() #0
+declare void @plain()
+
+attributes #0 = { "wasm-import-module"="bar" }
+
+; CHECK-NOT: .import_module plain
+; CHECK: .import_module foo, bar
+; CHECK-NOT: .import_module plain
diff --git a/llvm/test/MC/WebAssembly/external-func-address.ll b/llvm/test/MC/WebAssembly/external-func-address.ll
index 940f54cb077..05a335b848a 100644
--- a/llvm/test/MC/WebAssembly/external-func-address.ll
+++ b/llvm/test/MC/WebAssembly/external-func-address.ll
@@ -5,6 +5,11 @@ target triple = "wasm32-unknown-unknown-wasm"
; Verify that addresses of external functions generate correctly typed
; imports and relocations or type R_TABLE_INDEX_I32.
+declare void @f0(i32) #0
+@ptr_to_f0 = hidden global void (i32)* @f0, align 4
+
+attributes #0 = { "wasm-import-module"="somewhere" }
+
declare void @f1(i32) #1
@ptr_to_f1 = hidden global void (i32)* @f1, align 4
@@ -24,6 +29,8 @@ declare void @f1(i32) #1
; CHECK-NEXT: Field: __linear_memory
; CHECK: - Module: env
; CHECK-NEXT: Field: __indirect_function_table
+; CHECK: - Module: somewhere
+; CHECK-NEXT: Field: f0
; CHECK: - Module: env
; CHECK-NEXT: Field: f1
; CHECK-NEXT: Kind: FUNCTION
@@ -33,7 +40,7 @@ declare void @f1(i32) #1
; CHECK-NEXT: - Offset:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
-; CHECK-NEXT: Functions: [ 0 ]
+; CHECK-NEXT: Functions: [ 0, 1 ]
; CHECK: - Type: DATA
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32
OpenPOWER on IntegriCloud