summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/WebAssembly
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-06-16 23:59:10 +0000
committerSam Clegg <sbc@chromium.org>2017-06-16 23:59:10 +0000
commit9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805 (patch)
tree831fda1fcb2d777624a62553479acb958f043e43 /llvm/test/MC/WebAssembly
parent4f1fca270acd736cbde43773d1fd83b3b3d2164f (diff)
downloadbcm5719-llvm-9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805.tar.gz
bcm5719-llvm-9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805.zip
[WebAssembly] Use __stack_pointer global when writing wasm binary
This ensures that symbolic relocations are generated for stack pointer manipulations. These relocations are of type R_WEBASSEMBLY_GLOBAL_INDEX_LEB. This change also adds support for reading relocations of this type in WasmObjectFile.cpp. Since its a globally imported symbol this does mean that the get_global/set_global instruction won't be valid until the objects are linked that global used in no longer an imported global. Differential Revision: https://reviews.llvm.org/D34172 llvm-svn: 305616
Diffstat (limited to 'llvm/test/MC/WebAssembly')
-rw-r--r--llvm/test/MC/WebAssembly/func-address.ll5
-rw-r--r--llvm/test/MC/WebAssembly/stack-ptr.ll21
2 files changed, 23 insertions, 3 deletions
diff --git a/llvm/test/MC/WebAssembly/func-address.ll b/llvm/test/MC/WebAssembly/func-address.ll
index c0a9d9a801f..15c09e0ebd8 100644
--- a/llvm/test/MC/WebAssembly/func-address.ll
+++ b/llvm/test/MC/WebAssembly/func-address.ll
@@ -25,11 +25,10 @@ entry:
; CHECK: Section {
; CHECK: Type: ELEM (0x9)
; CHECK: Size: 7
-; CHECK: Offset: 165
; CHECK: }
; CHECK: Relocations [
-; CHECK: Section (9) CODE {
+; CHECK: Section (8) CODE {
; CHECK: Relocation {
; CHECK: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
; CHECK: Offset: 0x4
@@ -42,7 +41,7 @@ entry:
; CHECK: }
; CHECK: Relocation {
; CHECK: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
-; CHECK: Offset: 0x1A
+; CHECK: Offset: 0x1E
; CHECK: Index: 0x0
; CHECK: }
; CHECK: }
diff --git a/llvm/test/MC/WebAssembly/stack-ptr.ll b/llvm/test/MC/WebAssembly/stack-ptr.ll
new file mode 100644
index 00000000000..98d1311e154
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -0,0 +1,21 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+; Function that uses explict stack, and should generate a reference to
+; __stack_pointer, along with the corresponding reloction entry.
+define hidden void @foo() #0 {
+entry:
+ alloca i32, align 4
+ ret void
+}
+
+; CHECK: - Type: IMPORT
+; CHECK: Imports:
+; CHECK: - Module: env
+; CHECK: Field: __stack_pointer
+; CHECK: Kind: GLOBAL
+; CHECK: GlobalType: I32
+; CHECK: GlobalMutable: false
+; CHECK: - Type: CODE
+; CHECK: Relocations:
+; CHECK: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB
+; CHECK: Index: 0
OpenPOWER on IntegriCloud