cmd/6l, cmd/8l: fix chaining bug in jump rewrite

The code was inconsistent about when it used
brchain(x) and when it used x directly, with the result
that you could end up emitting code for brchain(x) but
leave the jump pointing at an unemitted x.

R=ken2
CC=golang-dev
https://golang.org/cl/6250077
This commit is contained in:
Russ Cox 2012-05-30 16:10:53 -04:00
parent 37f046bac6
commit b91cf50585
2 changed files with 16 additions and 14 deletions

View File

@ -192,6 +192,10 @@ loop:
* recurse to follow one path.
* continue loop on the other.
*/
if((q = brchain(p->pcond)) != P)
p->pcond = q;
if((q = brchain(p->link)) != P)
p->link = q;
if(p->from.type == D_CONST) {
if(p->from.offset == 1) {
/*
@ -204,8 +208,8 @@ loop:
p->pcond = q;
}
} else {
q = brchain(p->link);
if(q != P && q->mark)
q = p->link;
if(q->mark)
if(a != ALOOP) {
p->as = relinv(a);
p->link = p->pcond;
@ -213,12 +217,9 @@ loop:
}
}
xfol(p->link, last);
q = brchain(p->pcond);
if(q->mark) {
p->pcond = q;
if(p->pcond->mark)
return;
}
p = q;
p = p->pcond;
goto loop;
}
p = p->link;

View File

@ -184,6 +184,10 @@ loop:
* recurse to follow one path.
* continue loop on the other.
*/
if((q = brchain(p->pcond)) != P)
p->pcond = q;
if((q = brchain(p->link)) != P)
p->link = q;
if(p->from.type == D_CONST) {
if(p->from.offset == 1) {
/*
@ -196,8 +200,8 @@ loop:
p->pcond = q;
}
} else {
q = brchain(p->link);
if(q != P && q->mark)
q = p->link;
if(q->mark)
if(a != ALOOP) {
p->as = relinv(a);
p->link = p->pcond;
@ -205,12 +209,9 @@ loop:
}
}
xfol(p->link, last);
q = brchain(p->pcond);
if(q->mark) {
p->pcond = q;
if(p->pcond->mark)
return;
}
p = q;
p = p->pcond;
goto loop;
}
p = p->link;