Commit 63d008f9 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Rewriter fix: were trying to reuse a register when it wasn't safe

This register reuse here didn't go through our locations-tracking
infrastructure, and it just assumed it'd be ok to do.  I think it's
only called from places where the register we reuse won't be used
after this function.

This broke though when I added the ability to allocate orig-arg
registers; now, the argument is still dead in that it won't be used
by the function, but it could be "used" if a guard failed.  But this
wasn't being tracked in the locations map, so we ended up trashing
the orig arg despite the lengths we went to to not do that :/
parent 43e18aed
......@@ -1314,12 +1314,12 @@ RewriterVar* Rewriter::allocateAndCopyPlus1(RewriterVar* first_elem, RewriterVar
void Rewriter::_allocateAndCopyPlus1(RewriterVar* result, RewriterVar* first_elem, RewriterVar* rest_ptr, int n_rest) {
int offset = _allocate(result, n_rest + 1);
assembler::Register tmp = first_elem->getInReg();
assembler->mov(tmp, assembler::Indirect(assembler::RSP, 8 * offset + rewrite->getScratchRspOffset()));
assembler::Register first_reg = first_elem->getInReg();
assembler->mov(first_reg, assembler::Indirect(assembler::RSP, 8 * offset + rewrite->getScratchRspOffset()));
if (n_rest > 0) {
assembler::Register src_ptr = rest_ptr->getInReg();
// TODO if this triggers we'll need a way to allocate two distinct registers
assembler::Register tmp = allocReg(Location::any(), /* otherThan */ src_ptr);
assert(tmp != src_ptr);
for (int i = 0; i < n_rest; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment