Created
April 6, 2011 21:42
-
-
Save jnthn/906599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/compilers/imcc/reg_alloc.c b/compilers/imcc/reg_alloc.c | |
index de0f3e0..300216d 100644 | |
--- a/compilers/imcc/reg_alloc.c | |
+++ b/compilers/imcc/reg_alloc.c | |
@@ -391,6 +391,9 @@ reg_sort_f(ARGIN(const void *a), ARGIN(const void *b)) | |
const SymReg * const ra = *(const SymReg * const *)a; | |
const SymReg * const rb = *(const SymReg * const *)b; | |
+ if (!ra->first_ins || !rb->first_ins) | |
+ return 0; | |
+ | |
if (ra->first_ins->index < rb->first_ins->index) | |
return -1; | |
@@ -473,7 +476,7 @@ build_reglist(PARROT_INTERP, ARGMOD(IMC_Unit *unit)) | |
/* we might have unused symbols here, from optimizations */ | |
for (i = count = unused = 0; i < n_symbols; i++) { | |
- if (!unit->reglist[i]->first_ins) | |
+ if (!unit->reglist[i]->first_ins && !(unit->reglist[i]->usage & U_LEXICAL)) | |
unused++; | |
else if (i == count) | |
count++; | |
@@ -716,7 +719,7 @@ vanilla_reg_alloc(PARROT_INTERP, ARGMOD(IMC_Unit *unit)) | |
SymReg *r; | |
for (r = hsh->data[i]; r; r = r->next) { | |
/* TODO Ignore non-volatiles */ | |
- if (REG_NEEDS_ALLOC(r) && r->use_count) | |
+ if (REG_NEEDS_ALLOC(r)) | |
r->color = -1; | |
} | |
} | |
@@ -732,7 +735,7 @@ vanilla_reg_alloc(PARROT_INTERP, ARGMOD(IMC_Unit *unit)) | |
for (r = hsh->data[i]; r; r = r->next) { | |
if (r->set != reg_set) | |
continue; | |
- if (REG_NEEDS_ALLOC(r) && (r->color == -1) && r->use_count) { | |
+ if (REG_NEEDS_ALLOC(r) && (r->color == -1)) { | |
if (set_contains(avail, first_reg)) | |
first_reg = first_avail(interp, unit, reg_set, NULL); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment