1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/test/CodeGen/WebAssembly/userstack.ll
Derek Schuff b1cc2b699b [WebAssembly] Implement eliminateCallFramePseudo
Summary:
Implement eliminateCallFramePsuedo to handle ADJCALLSTACKUP/DOWN
pseudo-instructions. Add a test calling a vararg function which causes non-0
adjustments. This revealed an issue with RegisterCoalescer wherein it
eliminates a COPY from SP32 to a vreg but failes to update the live ranges
of EXPR_STACK, causing a machineinstr verifier failure (so this test
is commented out).

Also add a dynamic alloca test, which causes a callseq_end dag node with
a 0 (instead of undef) second argument to be generated. We currently fail to
select that, so adjust the ADJCALLSTACKUP tablegen code to handle it.

Differential Revision: http://reviews.llvm.org/D15587

llvm-svn: 255844
2015-12-16 23:21:30 +00:00

82 lines
2.7 KiB
LLVM

; RUN: llc < %s -asm-verbose=false | FileCheck %s
; RUN: llc < %s -asm-verbose=false -fast-isel | FileCheck %s
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
; CHECK-LABEL: alloca32:
; Check that there is an extra local for the stack pointer.
; CHECK: .local i32, i32, i32, i32{{$}}
define void @alloca32() {
; CHECK: i32.const [[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]])
; CHECK-NEXT: i32.const [[L2:.+]]=, 16
; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]]
%retval = alloca i32
; CHECK: i32.const $push[[L3:.+]]=, 0
; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]]
store i32 0, i32* %retval
; CHECK: i32.const [[L4:.+]]=, 16
; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L4]]
; CHECK-NEXT: i32.const [[L5:.+]]=, __stack_pointer
; CHECK-NEXT: i32.store [[SP]]=, 0([[L5]]), [[SP]]
ret void
}
; CHECK-LABEL: alloca3264:
; CHECK: .local i32, i32, i32, i32{{$}}
define void @alloca3264() {
; CHECK: i32.const [[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]])
; CHECK-NEXT: i32.const [[L2:.+]]=, 16
; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]]
%r1 = alloca i32
%r2 = alloca double
; CHECK: i32.const $push[[L3:.+]]=, 0
; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]]
store i32 0, i32* %r1
; CHECK: i64.const $push[[L4:.+]]=, 0
; CHECK: i64.store {{.*}}=, 0([[SP]]), $pop[[L4]]
store double 0.0, double* %r2
; CHECK: i32.const [[L4:.+]]=, 16
; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L4]]
; CHECK-NEXT: i32.const [[L5:.+]]=, __stack_pointer
; CHECK-NEXT: i32.store [[SP]]=, 0([[L5]]), [[SP]]
ret void
}
; CHECK-LABEL: allocarray:
; CHECK: .local i32, i32, i32, i32, i32, i32{{$}}
define void @allocarray() {
; CHECK: i32.const [[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]])
; CHECK-NEXT: i32.const [[L2:.+]]=, 32
; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]]
%r = alloca [5 x i32]
; CHECK: i32.const $push[[L3:.+]]=, 1
; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]]
%p = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 0
store i32 1, i32* %p
; CHECK: i32.const $push[[L4:.+]]=, 4
; CHECK: i32.const [[L5:.+]]=, 12
; CHECK: i32.add [[L5]]=, [[SP]], [[L5]]
; CHECK: i32.add $push[[L6:.+]]=, [[L5]], $pop[[L4]]
; CHECK: i32.store {{.*}}=, 0($pop[[L6]]), ${{.+}}
%p2 = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 1
store i32 1, i32* %p2
; CHECK: i32.const [[L7:.+]]=, 32
; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L7]]
; CHECK-NEXT: i32.const [[L8:.+]]=, __stack_pointer
; CHECK-NEXT: i32.store [[SP]]=, 0([[L7]]), [[SP]]
ret void
}
define void @dynamic_alloca(i32 %alloc) {
; TODO: Support frame pointers
;%r = alloca i32, i32 %alloc
;store i32 0, i32* %r
ret void
}
; TODO: test aligned alloc