Commit b871bc10 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #964 from kmod/rewrite_failed

Fix a rare 'assert R11 is not used' crash
parents 00b022aa d3b4a490
...@@ -619,7 +619,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_ ...@@ -619,7 +619,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_
assembler::Register dest_reg = dest.asRegister(); assembler::Register dest_reg = dest.asRegister();
assert(dest_reg != reg); // should have been caught by the previous case assert(dest_reg != reg); // should have been caught by the previous case
rewriter->allocReg(dest); rewriter->allocReg(dest, otherThan);
rewriter->assembler->mov(reg, dest_reg); rewriter->assembler->mov(reg, dest_reg);
rewriter->addLocationToVar(this, dest_reg); rewriter->addLocationToVar(this, dest_reg);
...@@ -858,7 +858,7 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, const Rewrit ...@@ -858,7 +858,7 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, const Rewrit
} }
void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> args, void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> args,
llvm::ArrayRef<RewriterVar*> args_xmm) { llvm::ArrayRef<RewriterVar*> args_xmm, Location preserve) {
if (has_side_effects) if (has_side_effects)
assert(done_guarding); assert(done_guarding);
...@@ -879,7 +879,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar ...@@ -879,7 +879,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar
if (!marked_inside_ic) { if (!marked_inside_ic) {
uintptr_t counter_addr = (uintptr_t)(&picked_slot->num_inside); uintptr_t counter_addr = (uintptr_t)(&picked_slot->num_inside);
if (isLargeConstant(counter_addr)) { if (isLargeConstant(counter_addr)) {
assembler::Register reg = allocReg(Location::any(), getReturnDestination()); assembler::Register reg = allocReg(Location::any(), preserve);
assembler->mov(assembler::Immediate(counter_addr), reg); assembler->mov(assembler::Immediate(counter_addr), reg);
assembler->incl(assembler::Indirect(reg, 0)); assembler->incl(assembler::Indirect(reg, 0));
} else { } else {
...@@ -900,7 +900,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar ...@@ -900,7 +900,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar
{ {
// this forces the register allocator to spill this register: // this forces the register allocator to spill this register:
assembler::Register r2 = allocReg(l); assembler::Register r2 = allocReg(l, preserve);
if (failed) if (failed)
return; return;
assert(r == r2); assert(r == r2);
...@@ -977,7 +977,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar ...@@ -977,7 +977,7 @@ void Rewriter::_setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> ar
if (need_to_spill) { if (need_to_spill) {
if (check_reg.type == Location::Register) { if (check_reg.type == Location::Register) {
spillRegister(check_reg.asRegister()); spillRegister(check_reg.asRegister(), preserve);
if (failed) if (failed)
return; return;
} else { } else {
...@@ -1012,8 +1012,10 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr ...@@ -1012,8 +1012,10 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr
// RewriterVarUsage scratch = createNewVar(Location::any()); // RewriterVarUsage scratch = createNewVar(Location::any());
assembler::Register r = allocReg(assembler::R11); assembler::Register r = allocReg(assembler::R11);
if (failed)
return;
_setupCall(has_side_effects, args, args_xmm); _setupCall(has_side_effects, args, args_xmm, assembler::R11);
for (RewriterVar* arg : args) { for (RewriterVar* arg : args) {
arg->bumpUse(); arg->bumpUse();
...@@ -1699,7 +1701,7 @@ assembler::Register Rewriter::allocReg(Location dest, Location otherThan) { ...@@ -1699,7 +1701,7 @@ assembler::Register Rewriter::allocReg(Location dest, Location otherThan) {
assembler::Register reg(dest.regnum); assembler::Register reg(dest.regnum);
if (vars_by_location.count(reg)) { if (vars_by_location.count(reg)) {
spillRegister(reg); spillRegister(reg, otherThan);
} }
assert(failed || vars_by_location.count(reg) == 0); assert(failed || vars_by_location.count(reg) == 0);
......
...@@ -489,7 +489,8 @@ protected: ...@@ -489,7 +489,8 @@ protected:
void _slowpathJump(bool condition_eq); void _slowpathJump(bool condition_eq);
void _trap(); void _trap();
void _loadConst(RewriterVar* result, int64_t val); void _loadConst(RewriterVar* result, int64_t val);
void _setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> args, llvm::ArrayRef<RewriterVar*> args_xmm); void _setupCall(bool has_side_effects, llvm::ArrayRef<RewriterVar*> args, llvm::ArrayRef<RewriterVar*> args_xmm,
Location preserve = Location::any());
void _call(RewriterVar* result, bool has_side_effects, void* func_addr, llvm::ArrayRef<RewriterVar*> args, void _call(RewriterVar* result, bool has_side_effects, void* func_addr, llvm::ArrayRef<RewriterVar*> args,
llvm::ArrayRef<RewriterVar*> args_xmm); llvm::ArrayRef<RewriterVar*> args_xmm);
void _add(RewriterVar* result, RewriterVar* a, int64_t b, Location dest); void _add(RewriterVar* result, RewriterVar* a, int64_t b, Location dest);
......
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