mirror of
https://github.com/golang/go
synced 2024-11-17 22:14:43 -07:00
cmd/internal/obj/arm64: rewrite branches that are too far
Fixes #12540. Change-Id: I7893fdc023145b0aca4b4c7df7e08e47edcf5bba Reviewed-on: https://go-review.googlesource.com/16902 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
ec9aae772c
commit
2a031e6a2a
@ -535,9 +535,9 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
buildop(ctxt)
|
||||
}
|
||||
|
||||
bflag := 0
|
||||
c := int32(0)
|
||||
p.Pc = int64(c)
|
||||
bflag := 1
|
||||
c := int64(0)
|
||||
p.Pc = c
|
||||
var m int
|
||||
var o *Optab
|
||||
for p = p.Link; p != nil; p = p.Link {
|
||||
@ -545,7 +545,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
if p.As == ADWORD && (c&7) != 0 {
|
||||
c += 4
|
||||
}
|
||||
p.Pc = int64(c)
|
||||
p.Pc = c
|
||||
o = oplook(ctxt, p)
|
||||
m = int(o.size)
|
||||
if m == 0 {
|
||||
@ -567,13 +567,13 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
if p.As == AB || p.As == obj.ARET || p.As == AERET { /* TODO: other unconditional operations */
|
||||
checkpool(ctxt, p, 0)
|
||||
}
|
||||
c += int32(m)
|
||||
c += int64(m)
|
||||
if ctxt.Blitrl != nil {
|
||||
checkpool(ctxt, p, 1)
|
||||
}
|
||||
}
|
||||
|
||||
cursym.Size = int64(c)
|
||||
cursym.Size = c
|
||||
|
||||
/*
|
||||
* if any procedure is large enough to
|
||||
@ -582,38 +582,38 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
* around jmps to fix. this is rare.
|
||||
*/
|
||||
for bflag != 0 {
|
||||
if ctxt.Debugvlog != 0 {
|
||||
fmt.Fprintf(ctxt.Bso, "%5.2f span1\n", obj.Cputime())
|
||||
}
|
||||
bflag = 0
|
||||
c = 0
|
||||
for p = cursym.Text; p != nil; p = p.Link {
|
||||
for p = cursym.Text.Link; p != nil; p = p.Link {
|
||||
if p.As == ADWORD && (c&7) != 0 {
|
||||
c += 4
|
||||
}
|
||||
p.Pc = int64(c)
|
||||
p.Pc = c
|
||||
o = oplook(ctxt, p)
|
||||
|
||||
/* very large branches
|
||||
if(o->type == 6 && p->cond) {
|
||||
otxt = p->cond->pc - c;
|
||||
if(otxt < 0)
|
||||
otxt = -otxt;
|
||||
if(otxt >= (1L<<17) - 10) {
|
||||
q = ctxt->arch->prg();
|
||||
q->link = p->link;
|
||||
p->link = q;
|
||||
q->as = AB;
|
||||
q->to.type = obj.TYPE_BRANCH;
|
||||
q->cond = p->cond;
|
||||
p->cond = q;
|
||||
q = ctxt->arch->prg();
|
||||
q->link = p->link;
|
||||
p->link = q;
|
||||
q->as = AB;
|
||||
q->to.type = obj.TYPE_BRANCH;
|
||||
q->cond = q->link->link;
|
||||
bflag = 1;
|
||||
/* very large branches */
|
||||
if o.type_ == 7 && p.Pcond != nil {
|
||||
otxt := p.Pcond.Pc - c
|
||||
if otxt <= -(1<<18)+10 || otxt >= (1<<18)-10 {
|
||||
q := ctxt.NewProg()
|
||||
q.Link = p.Link
|
||||
p.Link = q
|
||||
q.As = AB
|
||||
q.To.Type = obj.TYPE_BRANCH
|
||||
q.Pcond = p.Pcond
|
||||
p.Pcond = q
|
||||
q = ctxt.NewProg()
|
||||
q.Link = p.Link
|
||||
p.Link = q
|
||||
q.As = AB
|
||||
q.To.Type = obj.TYPE_BRANCH
|
||||
q.Pcond = q.Link.Link
|
||||
bflag = 1
|
||||
}
|
||||
}
|
||||
*/
|
||||
m = int(o.size)
|
||||
|
||||
if m == 0 {
|
||||
@ -623,12 +623,12 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
continue
|
||||
}
|
||||
|
||||
c += int32(m)
|
||||
c += int64(m)
|
||||
}
|
||||
}
|
||||
|
||||
c += -c & (FuncAlign - 1)
|
||||
cursym.Size = int64(c)
|
||||
cursym.Size = c
|
||||
|
||||
/*
|
||||
* lay out the code, emitting code and data relocations.
|
||||
|
Loading…
Reference in New Issue
Block a user