[llvm] r261453 - [WebAssembly] Write stack pointer back to memory when FP is used
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 20 14:18:47 PST 2016
Author: dschuff
Date: Sat Feb 20 16:18:47 2016
New Revision: 261453
URL: http://llvm.org/viewvc/llvm-project?rev=261453&view=rev
Log:
[WebAssembly] Write stack pointer back to memory when FP is used
The stack pointer is bumped when there is a frame pointer or when there
are static-size objects, but was only getting written back when there
were static-size objects.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp?rev=261453&r1=261452&r2=261453&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp Sat Feb 20 16:18:47 2016
@@ -125,7 +125,7 @@ void WebAssemblyFrameLowering::emitProlo
WebAssembly::FP32)
.addReg(WebAssembly::SP32);
}
- if (StackSize) {
+ if (StackSize || hasFP(MF)) {
SPAddr = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
// The SP32 register now has the new stacktop. Also write it back to memory.
BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::CONST_I32), SPAddr)
Modified: llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/userstack.ll?rev=261453&r1=261452&r2=261453&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/userstack.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/userstack.ll Sat Feb 20 16:18:47 2016
@@ -135,7 +135,8 @@ define void @dynamic_alloca(i32 %alloc)
; CHECK-NEXT: i32.load [[SP:.+]]=, 0($pop[[L1]])
; CHECK-NEXT: copy_local [[FP:.+]]=, [[SP]]
; Target independent codegen bumps the stack pointer
- ; FIXME: we need to write the value back to memory
+ ; CHECK: i32.const $push[[L4:.+]]=, __stack_pointer{{$}}
+ ; CHECK-NEXT: i32.store [[SP]]=, 0($pop[[L4]]), [[SP]]
%r = alloca i32, i32 %alloc
; Target-independent codegen also calculates the store addr
store i32 0, i32* %r
@@ -193,6 +194,8 @@ declare i8* @llvm.frameaddress(i32)
; CHECK: i32.const $push[[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[SP:.+]]=, 0($pop[[L1]])
; CHECK-NEXT: copy_local [[FP:.+]]=, [[SP]]
+; CHECK-NEXT: i32.const $push[[L2:.+]]=, __stack_pointer{{$}}
+; CHECK-NEXT: i32.store [[SP]]=, 0($pop[[L2]]), [[SP]]
; CHECK-NEXT: call use_i8_star at FUNCTION, [[FP]]
; CHECK-NEXT: i32.const $push[[L6:.+]]=, __stack_pointer
; CHECK-NEXT: i32.store [[SP]]=, 0($pop[[L6]]), [[FP]]
More information about the llvm-commits
mailing list