[llvm] r258597 - [WebAssembly] Fix RegNumbering for the stack pointer
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 17:20:43 PST 2016
Author: dschuff
Date: Fri Jan 22 19:20:43 2016
New Revision: 258597
URL: http://llvm.org/viewvc/llvm-project?rev=258597&view=rev
Log:
[WebAssembly] Fix RegNumbering for the stack pointer
Previously it failed to add NumArgRegs to the offset and so clobbered an
already-used register. Now just start the numbering after the arg regs
and don't duplicate the add. Test coverage for this coming shortly with
the implementation of byval.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp?rev=258597&r1=258596&r2=258597&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp Fri Jan 22 19:20:43 2016
@@ -74,6 +74,8 @@ bool WebAssemblyRegNumbering::runOnMachi
case WebAssembly::ARGUMENT_I64:
case WebAssembly::ARGUMENT_F32:
case WebAssembly::ARGUMENT_F64:
+ DEBUG(dbgs() << "Arg VReg " << MI.getOperand(0).getReg() << " -> WAReg "
+ << MI.getOperand(1).getImm() << "\n");
MFI.setWAReg(MI.getOperand(0).getReg(), MI.getOperand(1).getImm());
break;
default:
@@ -84,26 +86,32 @@ bool WebAssemblyRegNumbering::runOnMachi
// Then assign regular WebAssembly registers for all remaining used
// virtual registers. TODO: Consider sorting the registers by frequency of
// use, to maximize usage of small immediate fields.
- unsigned NumArgRegs = MFI.getParams().size();
unsigned NumVRegs = MF.getRegInfo().getNumVirtRegs();
unsigned NumStackRegs = 0;
- unsigned CurReg = 0;
+ // Start the numbering for locals after the arg regs
+ unsigned CurReg = MFI.getParams().size();
for (unsigned VRegIdx = 0; VRegIdx < NumVRegs; ++VRegIdx) {
unsigned VReg = TargetRegisterInfo::index2VirtReg(VRegIdx);
// Handle stackified registers.
if (MFI.isVRegStackified(VReg)) {
+ DEBUG(dbgs() << "VReg " << VReg << " -> WAReg "
+ << (INT32_MIN | NumStackRegs) << "\n");
MFI.setWAReg(VReg, INT32_MIN | NumStackRegs++);
continue;
}
// Skip unused registers.
if (MRI.use_empty(VReg))
continue;
- if (MFI.getWAReg(VReg) == WebAssemblyFunctionInfo::UnusedReg)
- MFI.setWAReg(VReg, NumArgRegs + CurReg++);
+ if (MFI.getWAReg(VReg) == WebAssemblyFunctionInfo::UnusedReg) {
+ DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " << CurReg << "\n");
+ MFI.setWAReg(VReg, CurReg++);
+ }
}
// Allocate locals for used physical registers
- if (FrameInfo.getStackSize() > 0)
+ if (FrameInfo.getStackSize() > 0) {
+ DEBUG(dbgs() << "PReg SP " << CurReg << "\n");
MFI.addPReg(WebAssembly::SP32, CurReg++);
+ }
return true;
}
More information about the llvm-commits
mailing list