Commit e3850872 authored by Travis Hance's avatar Travis Hance

don't spill constant variables onto the stack

parent 227d1a8e
...@@ -471,10 +471,6 @@ assembler::Immediate RewriterVar::tryGetAsImmediate(bool* is_immediate) { ...@@ -471,10 +471,6 @@ assembler::Immediate RewriterVar::tryGetAsImmediate(bool* is_immediate) {
assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_reg, Location otherThan) { assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_reg, Location otherThan) {
assert(dest.type == Location::Register || dest.type == Location::AnyReg); assert(dest.type == Location::Register || dest.type == Location::AnyReg);
// assembler::Register reg = var->rewriter->allocReg(l);
// var->rewriter->addLocationToVar(var, reg);
// return reg;
assert(locations.size());
#ifndef NDEBUG #ifndef NDEBUG
if (!allow_constant_in_reg) { if (!allow_constant_in_reg) {
for (Location l : locations) { for (Location l : locations) {
...@@ -483,6 +479,15 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_ ...@@ -483,6 +479,15 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_
} }
#endif #endif
if (locations.size() == 0 && this->is_constant) {
assembler::Register reg = rewriter->allocReg(dest, otherThan);
rewriter->const_loader.loadConstIntoReg(this->constant_value, reg);
rewriter->addLocationToVar(this, reg);
return reg;
}
assert(locations.size());
// Not sure if this is worth it, // Not sure if this is worth it,
// but first try to see if we're already in this specific register // but first try to see if we're already in this specific register
for (Location l : locations) { for (Location l : locations) {
...@@ -1287,7 +1292,8 @@ void Rewriter::spillRegister(assembler::Register reg, Location preserve) { ...@@ -1287,7 +1292,8 @@ void Rewriter::spillRegister(assembler::Register reg, Location preserve) {
assert(var); assert(var);
// There may be no need to spill if the var is held in a different location already. // There may be no need to spill if the var is held in a different location already.
if (var->locations.size() > 1) { // There is no need to spill if it is a constant
if (var->locations.size() > 1 || var->is_constant) {
removeLocationFromVar(var, reg); removeLocationFromVar(var, reg);
return; return;
} }
......
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