diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/userstack.ll | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp index 0e0cac4ee68..cbf59d1a3ce 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp @@ -125,7 +125,7 @@ void WebAssemblyFrameLowering::emitPrologue(MachineFunction &MF, 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) diff --git a/llvm/test/CodeGen/WebAssembly/userstack.ll b/llvm/test/CodeGen/WebAssembly/userstack.ll index ac41c947a49..f4f9e1c9fa7 100644 --- a/llvm/test/CodeGen/WebAssembly/userstack.ll +++ b/llvm/test/CodeGen/WebAssembly/userstack.ll @@ -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@FUNCTION, [[FP]] ; CHECK-NEXT: i32.const $push[[L6:.+]]=, __stack_pointer ; CHECK-NEXT: i32.store [[SP]]=, 0($pop[[L6]]), [[FP]] |

