History

fix allocation ordering bug in rega

When we process one block, we start by allocating registers for all the temporaries live at the exit of the block. Before this patch we processed temps first, then in doblk() we would mark globally live registers allocated. This meant that temps could get wrongly assigned a live register. The fix is simple: we now process registers first at block exits, then allocate temps.

Quentin Carbonneaux committed 3 years ago

Commit 87dc3ea1 parent 0db06da1 file · +2 −2Browse files

Unified · Split

rega.c+2−2
@@ -359,8 +359,6 @@ doblk(Blk *b, RMap *cur) · 358 unmodified lines
359 Mem *m;359 Mem *m;
360 Ref *ra[4];360 Ref *ra[4];
361 361
362 for (r=0; bsiter(b->out, &r) && r<Tmp0; r++)
363 radd(cur, r, r);
364 if (rtype(b->jmp.arg) == RTmp)362 if (rtype(b->jmp.arg) == RTmp)
365 b->jmp.arg = ralloc(cur, b->jmp.arg.val);363 b->jmp.arg = ralloc(cur, b->jmp.arg.val);
366 curi = &insb[NIns];364 curi = &insb[NIns];
@@ -534,6 +532,8 @@ rega(Fn *fn) · 167 unmodified lines
534 rl[j] = t;532 rl[j] = t;
535 }533 }
536 }534 }
535 for (r=0; bsiter(b->out, &r) && r<Tmp0; r++)
536 radd(&cur, r, r);
537 for (j=0; j<x; j++)537 for (j=0; j<x; j++)
538 ralloctry(&cur, rl[j], 1);538 ralloctry(&cur, rl[j], 1);
539 for (j=0; j<x; j++)539 for (j=0; j<x; j++)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t