diff options
author | JF Bastien <jfb@google.com> | 2016-01-30 14:11:26 +0000 |
---|---|---|
committer | JF Bastien <jfb@google.com> | 2016-01-30 14:11:26 +0000 |
commit | fbc89d21dd7c878d5238d90eafd597aff46f33e0 (patch) | |
tree | fb836ed49391bbe5e3ebf2853e5ab9f314f8374f /llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp | |
parent | 6e75b138f2d2f860454a9e5ebd80279776e8a420 (diff) | |
download | bcm5719-llvm-fbc89d21dd7c878d5238d90eafd597aff46f33e0.tar.gz bcm5719-llvm-fbc89d21dd7c878d5238d90eafd597aff46f33e0.zip |
WebAssembly: don't optimize frameindex store
The previous code was incorrect (can't getReg a frameindex). We could instead optimize it to reduce tree height, but I'm not sure that's worthwhile yet because we then try to eliminate the frameindex.
This patch also fixes frame index elimination for operations which may load or store: it used to assume the base was operand 2 and immediate offset operand 1. That's not true for stores, where they're 4 and 3.
llvm-svn: 259305
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp index 46f271c20af..3397f598759 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp @@ -74,8 +74,9 @@ void WebAssemblyRegisterInfo::eliminateFrameIndex( // generate broken code. report_fatal_error("Memory offset field overflow"); } - MI.getOperand(1).setImm(Offset); - MI.getOperand(2).ChangeToRegister(WebAssembly::SP32, /*IsDef=*/false); + MI.getOperand(FIOperandNum - 1).setImm(Offset); + MI.getOperand(FIOperandNum) + .ChangeToRegister(WebAssembly::SP32, /*IsDef=*/false); } else { // Otherwise create an i32.add SP, offset and make it the operand. auto &MRI = MF.getRegInfo(); |