| ... | @@ -352,15 +352,15 @@ pub fn RegisterManager( | ... | @@ -352,15 +352,15 @@ pub fn RegisterManager( |
| 352 | ) AllocateRegistersError!void { | 352 | ) AllocateRegistersError!void { |
| 353 | log.debug("getReg {} for inst {?}", .{ regAtTrackedIndex(tracked_index), inst }); | 353 | log.debug("getReg {} for inst {?}", .{ regAtTrackedIndex(tracked_index), inst }); |
| 354 | if (!self.isRegIndexFree(tracked_index)) { | 354 | if (!self.isRegIndexFree(tracked_index)) { |
| 355 | self.markRegIndexAllocated(tracked_index); | | |
| 356 | | | |
| 357 | // Move the instruction that was previously there to a | 355 | // Move the instruction that was previously there to a |
| 358 | // stack allocation. | 356 | // stack allocation. |
| 359 | const spilled_inst = self.registers[tracked_index]; | 357 | try self.getFunction().spillInstruction( |
| 360 | if (inst) |tracked_inst| self.registers[tracked_index] = tracked_inst; | 358 | regAtTrackedIndex(tracked_index), |
| 361 | try self.getFunction().spillInstruction(regAtTrackedIndex(tracked_index), spilled_inst); | 359 | self.registers[tracked_index], |
| 362 | if (inst == null) self.freeRegIndex(tracked_index); | 360 | ); |
| 363 | } else self.getRegIndexAssumeFree(tracked_index, inst); | 361 | self.freeRegIndex(tracked_index); |
| | 362 | } |
| | 363 | self.getRegIndexAssumeFree(tracked_index, inst); |
| 364 | } | 364 | } |
| 365 | pub fn getReg(self: *Self, reg: Register, inst: ?Air.Inst.Index) AllocateRegistersError!void { | 365 | pub fn getReg(self: *Self, reg: Register, inst: ?Air.Inst.Index) AllocateRegistersError!void { |
| 366 | log.debug("getting reg: {}", .{reg}); | 366 | log.debug("getting reg: {}", .{reg}); |