From: Russ Cox Date: Wed, 30 May 2012 20:10:53 +0000 (-0400) Subject: cmd/6l, cmd/8l: fix chaining bug in jump rewrite X-Git-Tag: go1.1rc2~3051 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b91cf5058514f70750076c25af07d904d2ee7c1b;p=gostls13.git 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 --- diff --git a/src/cmd/6l/pass.c b/src/cmd/6l/pass.c index ecbebbbdc7..758f61d651 100644 --- a/src/cmd/6l/pass.c +++ b/src/cmd/6l/pass.c @@ -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; diff --git a/src/cmd/8l/pass.c b/src/cmd/8l/pass.c index d92c2f55a0..9704e3530e 100644 --- a/src/cmd/8l/pass.c +++ b/src/cmd/8l/pass.c @@ -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;