diff options
author | Dan Gohman <dan433584@gmail.com> | 2017-02-24 23:46:05 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2017-02-24 23:46:05 +0000 |
commit | 8f5a7d69ccf823994c090895f5c783f82e511fb6 (patch) | |
tree | 3b6227483b1a25e659c00e284f7e78ea3847299f /test/CodeGen/WebAssembly | |
parent | cdc2ace6920c405510e289b763c67482d396d901 (diff) |
[WebAssembly] Add support for using a wasm global for the stack pointer.
This replaces the __stack_pointer variable which was allocated in linear
memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/WebAssembly')
-rw-r--r-- | test/CodeGen/WebAssembly/stack-alignment.ll | 102 |
1 files changed, 57 insertions, 45 deletions
diff --git a/test/CodeGen/WebAssembly/stack-alignment.ll b/test/CodeGen/WebAssembly/stack-alignment.ll index 3bb6617f877..95aa1f9dbf0 100644 --- a/test/CodeGen/WebAssembly/stack-alignment.ll +++ b/test/CodeGen/WebAssembly/stack-alignment.ll @@ -1,21 +1,23 @@ ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32-unknown-unknown" +target triple = "wasm32-unknown-unknown-wasm" declare void @somefunc(i32*) ; CHECK-LABEL: underalign: -; CHECK: i32.load $push[[L1:.+]]=, __stack_pointer{{.+}} +; CHECK: get_global $push[[L1:.+]]=, 0{{$}} ; CHECK-NEXT: i32.const $push[[L2:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L10:.+]]=, $pop[[L1]], $pop[[L2]] -; CHECK-NEXT: tee_local $push{{.+}}=, $[[SP:.+]]=, $pop[[L10]] +; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L10]] -; CHECK: i32.add $push[[underaligned:.+]]=, $[[SP]], $pop{{.+}} +; CHECK: get_local $push[[L3:.+]]=, [[SP]]{{$}} +; CHECK: i32.add $push[[underaligned:.+]]=, $pop[[L3]], $pop{{.+}} ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[underaligned]] -; CHECK: i32.add $push[[L5:.+]]=, $[[SP]], $pop{{.+}} -; CHECK-NEXT: i32.store __stack_pointer($pop{{.+}}), $pop[[L5]] +; CHECK: get_local $push[[M4:.+]]=, [[SP]]{{$}} +; CHECK: i32.add $push[[L5:.+]]=, $pop[[M4]], $pop{{.+}} +; CHECK-NEXT: set_global 0, $pop[[L5]] define void @underalign() { entry: %underaligned = alloca i32, align 8 @@ -24,18 +26,19 @@ entry: } ; CHECK-LABEL: overalign: -; CHECK: i32.load $push[[L10:.+]]=, __stack_pointer -; CHECK-NEXT: tee_local $push[[L9:.+]]=, $[[BP:.+]]=, $pop[[L10]] +; CHECK: get_global $push[[L10:.+]]=, 0{{$}} +; CHECK-NEXT: tee_local $push[[L9:.+]]=, [[BP:.+]], $pop[[L10]] ; CHECK-NEXT: i32.const $push[[L2:.+]]=, 32 ; CHECK-NEXT: i32.sub $push[[L8:.+]]=, $pop[[L9]], $pop[[L2]] ; CHECK-NEXT: i32.const $push[[L3:.+]]=, -32 ; CHECK-NEXT: i32.and $push[[L7:.+]]=, $pop[[L8]], $pop[[L3]] -; CHECK-NEXT: tee_local $push{{.+}}=, $[[SP:.+]]=, $pop[[L7]] +; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L7]] -; CHECK: call somefunc@FUNCTION, $[[SP]] +; CHECK: get_local $push[[M5:.+]]=, [[SP]]{{$}} +; CHECK: call somefunc@FUNCTION, $pop[[M5]]{{$}} -; CHECK: copy_local $push[[L5:.+]]=, $[[BP]] -; CHECK-NEXT: i32.store __stack_pointer($pop{{.+}}), $pop[[L5]] +; CHECK: get_local $push[[M6:.+]]=, [[BP]]{{$}} +; CHECK-NEXT: set_global 0, $pop[[M6]] define void @overalign() { entry: %overaligned = alloca i32, align 32 @@ -44,19 +47,21 @@ entry: } ; CHECK-LABEL: over_and_normal_align: -; CHECK: i32.load $push[[L14:.+]]=, __stack_pointer -; CHECK-NEXT: tee_local $push[[L13:.+]]=, $[[BP:.+]]=, $pop[[L14]] +; CHECK: get_global $push[[L14:.+]]=, 0{{$}} +; CHECK-NEXT: tee_local $push[[L13:.+]]=, [[BP:.+]], $pop[[L14]] ; CHECK: i32.sub $push[[L12:.+]]=, $pop[[L13]], $pop{{.+}} ; CHECK: i32.and $push[[L11:.+]]=, $pop[[L12]], $pop{{.+}} -; CHECK-NEXT: tee_local $push{{.+}}=, $[[SP]]=, $pop[[L11]] +; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L11]] -; CHECK: i32.add $push[[L6:.+]]=, $[[SP]], $pop{{.+}} +; CHECK: get_local $push[[M6:.+]]=, [[SP]]{{$}} +; CHECK: i32.add $push[[L6:.+]]=, $pop[[M6]], $pop{{.+}} ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[L6]] -; CHECK: i32.add $push[[L8:.+]]=, $[[SP]], $pop{{.+}} +; CHECK: get_local $push[[M7:.+]]=, [[SP]]{{$}} +; CHECK: i32.add $push[[L8:.+]]=, $pop[[M7]], $pop{{.+}} ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[L8]] -; CHECK: copy_local $push[[L9:.+]]=, $[[BP]] -; CHECK-NEXT: i32.store __stack_pointer({{.+}}), $pop[[L9]] +; CHECK: get_local $push[[L6:.+]]=, [[BP]]{{$}} +; CHECK-NEXT: set_global 0, $pop[[L6]] define void @over_and_normal_align() { entry: %over = alloca i32, align 32 @@ -67,14 +72,16 @@ entry: } ; CHECK-LABEL: dynamic_overalign: -; CHECK: i32.load $push[[L18:.+]]=, __stack_pointer -; CHECK-NEXT: tee_local $push[[L17:.+]]=, $[[SP:.+]]=, $pop[[L18]] -; CHECK-NEXT: copy_local $[[BP:.+]]=, $pop[[L17]] -; CHECK: tee_local $push{{.+}}=, $[[SP_2:.+]]=, $pop{{.+}} +; CHECK: get_global $push[[L18:.+]]=, 0{{$}} +; CHECK-NEXT: tee_local $push[[L17:.+]]=, [[SP:.+]], $pop[[L18]] +; CHECK-NEXT: set_local [[BP:.+]], $pop[[L17]] +; CHECK: tee_local $push{{.+}}=, [[SP_2:.+]], $pop{{.+}} -; CHECK: call somefunc@FUNCTION, $[[SP_2]] +; CHECK: get_local $push[[M8:.+]]=, [[SP_2]]{{$}} +; CHECK: call somefunc@FUNCTION, $pop[[M8]] -; CHECK: i32.store __stack_pointer($pop{{.+}}), $[[BP]] +; CHECK: get_local $push[[M9:.+]]=, [[BP]]{{$}} +; CHECK-NEXT: set_global 0, $pop[[M9]] define void @dynamic_overalign(i32 %num) { entry: %dynamic = alloca i32, i32 %num, align 32 @@ -83,20 +90,22 @@ entry: } ; CHECK-LABEL: overalign_and_dynamic: -; CHECK: i32.load $push[[L21:.+]]=, __stack_pointer -; CHECK-NEXT: tee_local $push[[L20:.+]]=, $[[BP:.+]]=, $pop[[L21]] +; CHECK: get_global $push[[L21:.+]]=, 0{{$}} +; CHECK-NEXT: tee_local $push[[L20:.+]]=, [[BP:.+]], $pop[[L21]] ; CHECK: i32.sub $push[[L19:.+]]=, $pop[[L20]], $pop{{.+}} ; CHECK: i32.and $push[[L18:.+]]=, $pop[[L19]], $pop{{.+}} -; CHECK: tee_local $push{{.+}}=, $[[FP:.+]]=, $pop[[L18]] -; CHECK: i32.sub $push[[L16:.+]]=, $[[FP]], $pop{{.+}} -; CHECK-NEXT: tee_local $push{{.+}}=, $[[SP:.+]]=, $pop[[L16]] +; CHECK: tee_local $push{{.+}}=, [[FP:.+]], $pop[[L18]] +; CHECK: get_local $push[[M10:.+]]=, [[FP]]{{$}} +; CHECK: i32.sub $push[[L16:.+]]=, $pop[[M10]], $pop{{.+}} +; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L16]] -; CHECK: copy_local $push[[over:.+]]=, $[[FP]] +; CHECK: get_local $push[[over:.+]]=, [[FP]] ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[over]] -; CHECK-NEXT: call somefunc@FUNCTION, $[[SP]] +; CHECK: get_local $push[[another:.+]]=, [[SP]] +; CHECK-NEXT: call somefunc@FUNCTION, $pop[[another]] -; CHECK: copy_local $push[[L12:.+]]=, $[[BP]] -; CHECK-NEXT: i32.store __stack_pointer($pop{{.+}}), $pop[[L12]] +; CHECK: get_local $push[[M11:.+]]=, [[BP]]{{$}} +; CHECK-NEXT: set_global 0, $pop[[M11]] define void @overalign_and_dynamic(i32 %num) { entry: %over = alloca i32, align 32 @@ -107,24 +116,27 @@ entry: } ; CHECK-LABEL: overalign_static_and_dynamic: -; CHECK: i32.load $push[[L26:.+]]=, __stack_pointer -; CHECK-NEXT: tee_local $push[[L25:.+]]=, $[[BP:.+]]=, $pop[[L26]] +; CHECK: get_global $push[[L26:.+]]=, 0{{$}} +; CHECK-NEXT: tee_local $push[[L25:.+]]=, [[BP:.+]], $pop[[L26]] ; CHECK: i32.sub $push[[L24:.+]]=, $pop[[L25]], $pop{{.+}} ; CHECK: i32.and $push[[L23:.+]]=, $pop[[L24]], $pop{{.+}} -; CHECK: tee_local $push{{.+}}=, $[[FP:.+]]=, $pop[[L23]] -; CHECK: i32.sub $push[[L21:.+]]=, $[[FP]], $pop{{.+}} -; CHECK-NEXT: tee_local $push{{.+}}=, $[[SP:.+]]=, $pop[[L21]] +; CHECK: tee_local $push{{.+}}=, [[FP:.+]], $pop[[L23]] +; CHECK: get_local $push[[M12:.+]]=, [[FP]]{{$}} +; CHECK: i32.sub $push[[L21:.+]]=, $pop[[M12]], $pop{{.+}} +; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L21]] -; CHECK: copy_local $push[[L19:.+]]=, $[[FP]] -; CHECK: tee_local $push[[L18:.+]]=, $[[FP_2:.+]]=, $pop[[L19]] +; CHECK: get_local $push[[L19:.+]]=, [[FP]] +; CHECK: tee_local $push[[L18:.+]]=, [[FP_2:.+]], $pop[[L19]] ; CHECK: i32.add $push[[over:.+]]=, $pop[[L18]], $pop{{.+}} ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[over]] -; CHECK: call somefunc@FUNCTION, $[[SP]] -; CHECK: i32.add $push[[static:.+]]=, $[[FP_2]], $pop{{.+}} +; CHECK: get_local $push[[M12:.+]]=, [[SP]] +; CHECK: call somefunc@FUNCTION, $pop[[M12]] +; CHECK: get_local $push[[M13:.+]]=, [[FP_2]] +; CHECK: i32.add $push[[static:.+]]=, $pop[[M13]], $pop{{.+}} ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[static]] -; CHECK: copy_local $push[[L16:.+]]=, $[[BP]] -; CHECK-NEXT: i32.store __stack_pointer({{.+}}), $pop[[L16]] +; CHECK: get_local $push[[M14:.+]]=, [[BP]]{{$}} +; CHECK-NEXT: set_global 0, $pop[[M14]] define void @overalign_static_and_dynamic(i32 %num) { entry: %over = alloca i32, align 32 |