aboutsummaryrefslogtreecommitdiff
path: root/src/liblink
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-29 15:35:56 -0500
committerRuss Cox <rsc@golang.org>2015-02-03 18:22:35 +0000
commit6654188190cb8ff2be716417cc1b5086b20a5fa3 (patch)
tree7f0d54120937ae580f3b4b2e17025350fa97d491 /src/liblink
parente66ad16ddbfe0534e187905b499a28fbcc9c1143 (diff)
downloadgo-6654188190cb8ff2be716417cc1b5086b20a5fa3.tar.xz
liblink: remove dead computation of p->back in span6/span8
Originally, when this code was part of 6l/8l, every new Prog was constructed starting with zprg, which set back=2, and then this code walked over the list setting back=1 for backward branches, back=0 otherwise. The initial back=2 setting was used to identify forward branches (the branched-to instruction had back == 2 since it hadn't yet been set to 0 or 1). When the code was extracted into liblink and linked directly with 6a/6g/8a/8g, those programs created the Prog struct and did not set back=2, breaking this backward branch detection. No one noticed, because the next loop recomputes the information. The only requirement for the next loop is that p->back == 0 or 1 for each of the Progs in the list. The initialization of the zprg with back=2 would cause problems in this second loop, for the few liblink-internally-generated instructions that are created by copying zprg, except that the first loop was making sure that back == 0 or 1. The first loop's manipulation of p->back can thus be deleted, provided we also delete the zprg.back = 2 initializations. This is awful and my fault. I apologize. While we're here, remove the .scale = 1 from the zprg init too. Anything that sets up a scaled index should set the scale itself. (And mostly those come from outside liblink anyway.) Tested by checking that all generated code is bit-for-bit identical to before this CL. Change-Id: I7f6e0b33ce9ccd5b7dc25e0f00429fedd0957c8c Reviewed-on: https://go-review.googlesource.com/3574 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/liblink')
-rw-r--r--src/liblink/asm6.c5
-rw-r--r--src/liblink/asm8.c5
-rw-r--r--src/liblink/obj6.c1
-rw-r--r--src/liblink/obj8.c3
4 files changed, 0 insertions, 14 deletions
diff --git a/src/liblink/asm6.c b/src/liblink/asm6.c
index ee248d272a..71d24821e0 100644
--- a/src/liblink/asm6.c
+++ b/src/liblink/asm6.c
@@ -1615,14 +1615,9 @@ span6(Link *ctxt, LSym *s)
instinit();
for(p = ctxt->cursym->text; p != nil; p = p->link) {
- n = 0;
if(p->to.type == TYPE_BRANCH)
if(p->pcond == nil)
p->pcond = p;
- if((q = p->pcond) != nil)
- if(q->back != 2)
- n = 1;
- p->back = n;
if(p->as == AADJSP) {
p->to.type = TYPE_REG;
p->to.reg = REG_SP;
diff --git a/src/liblink/asm8.c b/src/liblink/asm8.c
index 5d6a7f7d4f..e8508eb07a 100644
--- a/src/liblink/asm8.c
+++ b/src/liblink/asm8.c
@@ -1231,14 +1231,9 @@ span8(Link *ctxt, LSym *s)
instinit();
for(p = s->text; p != nil; p = p->link) {
- n = 0;
if(p->to.type == TYPE_BRANCH)
if(p->pcond == nil)
p->pcond = p;
- if((q = p->pcond) != nil)
- if(q->back != 2)
- n = 1;
- p->back = n;
if(p->as == AADJSP) {
p->to.type = TYPE_REG;
p->to.reg = REG_SP;
diff --git a/src/liblink/obj6.c b/src/liblink/obj6.c
index 12e0606453..15dd9e99a7 100644
--- a/src/liblink/obj6.c
+++ b/src/liblink/obj6.c
@@ -36,7 +36,6 @@
#include "../runtime/stack.h"
static Prog zprg = {
- .back = 2,
.as = AGOK,
.from = {
.type = TYPE_NONE,
diff --git a/src/liblink/obj8.c b/src/liblink/obj8.c
index 16b0e07eac..37ef8a490e 100644
--- a/src/liblink/obj8.c
+++ b/src/liblink/obj8.c
@@ -36,17 +36,14 @@
#include "../runtime/stack.h"
static Prog zprg = {
- .back = 2,
.as = AGOK,
.from = {
.type = TYPE_NONE,
.index = REG_NONE,
- .scale = 1,
},
.to = {
.type = TYPE_NONE,
.index = REG_NONE,
- .scale = 1,
},
};