mirror of
git://c9x.me/qbe.git
synced 2026-04-05 18:09:47 +00:00
fix bug in alias analysis
The handling of phi was incorrect and we would sometimes miss escapes. We now handle phis at the very end of the pass to make sure the defs for their arguments have all been processed.
This commit is contained in:
parent
2d683e0c53
commit
bd7a73d0ea
8
alias.c
8
alias.c
@ -132,7 +132,7 @@ store(Ref r, int sz, Fn *fn)
|
|||||||
void
|
void
|
||||||
fillalias(Fn *fn)
|
fillalias(Fn *fn)
|
||||||
{
|
{
|
||||||
uint n, m;
|
uint n;
|
||||||
int t, sz;
|
int t, sz;
|
||||||
int64_t x;
|
int64_t x;
|
||||||
Blk *b;
|
Blk *b;
|
||||||
@ -146,8 +146,6 @@ fillalias(Fn *fn)
|
|||||||
for (n=0; n<fn->nblk; ++n) {
|
for (n=0; n<fn->nblk; ++n) {
|
||||||
b = fn->rpo[n];
|
b = fn->rpo[n];
|
||||||
for (p=b->phi; p; p=p->link) {
|
for (p=b->phi; p; p=p->link) {
|
||||||
for (m=0; m<p->narg; m++)
|
|
||||||
esc(p->arg[m], fn);
|
|
||||||
assert(rtype(p->to) == RTmp);
|
assert(rtype(p->to) == RTmp);
|
||||||
a = &fn->tmp[p->to.val].alias;
|
a = &fn->tmp[p->to.val].alias;
|
||||||
assert(a->type == ABot);
|
assert(a->type == ABot);
|
||||||
@ -217,4 +215,8 @@ fillalias(Fn *fn)
|
|||||||
if (b->jmp.type != Jretc)
|
if (b->jmp.type != Jretc)
|
||||||
esc(b->jmp.arg, fn);
|
esc(b->jmp.arg, fn);
|
||||||
}
|
}
|
||||||
|
for (b=fn->start; b; b=b->link)
|
||||||
|
for (p=b->phi; p; p=p->link)
|
||||||
|
for (n=0; n<p->narg; n++)
|
||||||
|
esc(p->arg[n], fn);
|
||||||
}
|
}
|
||||||
|
|||||||
21
test/alias1.ssa
Normal file
21
test/alias1.ssa
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export function w $main() {
|
||||||
|
@start
|
||||||
|
%a =l alloc4 4
|
||||||
|
%b =l alloc4 4
|
||||||
|
storew 4, %a
|
||||||
|
storew 5, %b
|
||||||
|
|
||||||
|
@loop
|
||||||
|
# %mem will be %a and %b successively,
|
||||||
|
# but we do not know it when processing
|
||||||
|
# the phi because %b goes through a cpy
|
||||||
|
%mem =l phi @start %a, @loop %bcpy
|
||||||
|
|
||||||
|
%w =w load %mem
|
||||||
|
%eq5 =w ceqw %w, 5
|
||||||
|
%bcpy =l copy %b
|
||||||
|
jnz %eq5, @exit, @loop
|
||||||
|
|
||||||
|
@exit
|
||||||
|
ret 0
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user