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
359359 Mem *m;
360360 Ref *ra[4];
361361
362− for (r=0; bsiter(b->out, &r) && r<Tmp0; r++)
363− radd(cur, r, r);
364362 if (rtype(b->jmp.arg) == RTmp)
365363 b->jmp.arg = ralloc(cur, b->jmp.arg.val);
366364 curi = &insb[NIns];
@@ -534,6 +532,8 @@ rega(Fn *fn) · 167 unmodified lines
534532 rl[j] = t;
535533 }
536534 }
535+ for (r=0; bsiter(b->out, &r) && r<Tmp0; r++)
536+ radd(&cur, r, r);
537537 for (j=0; j<x; j++)
538538 ralloctry(&cur, rl[j], 1);
539539 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