[WebAssembly] Stackify code emitted by eliminateFrameIndex and SP writeback
authorDerek Schuff <dschuff@google.com>
Thu, 17 Mar 2016 17:00:29 +0000 (17:00 +0000)
committerDerek Schuff <dschuff@google.com>
Thu, 17 Mar 2016 17:00:29 +0000 (17:00 +0000)
commitd4207ba0f6d5f110f5d0def0d1f675c6a3b05668
tree609cd049cfbd5255e9125b9cd50cffffbc8f6d32
parent93bbc7cd66aa98120a8b0411d90a619aec8df6e3
[WebAssembly] Stackify code emitted by eliminateFrameIndex and SP writeback

Summary:
MRI::eliminateFrameIndex can emit several instructions to do address
calculations; these can usually be stackified. Because instructions with
FI operands can have subsequent operands which may be expression trees,
find the top of the leftmost tree and insert the code before it, to keep
the LIFO property.

Also use stackified registers when writing back the SP value to memory
in the epilog; it's unnecessary because SP will not be used after the
epilog, and it results in better code.

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

llvm-svn: 263725
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
llvm/test/CodeGen/WebAssembly/byval.ll
llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll
llvm/test/CodeGen/WebAssembly/userstack.ll