]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/mips: don't emit spurious CALLIND relocations
authorCherry Zhang <cherryyz@google.com>
Fri, 3 Apr 2020 02:12:38 +0000 (22:12 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 3 Apr 2020 13:43:12 +0000 (13:43 +0000)
Generate a CALLIND relocation only for indirect calls, not for
indirect jumps. In particular, the RET instruction is lowered to
JMP (LR), an indirect jump, and occurs frequently. The large
amount of spurious relocations causes the linker to do a lot of
extra work.

Change-Id: Ie0edc04609788f5a687fd00c22558c3f83867697
Reviewed-on: https://go-review.googlesource.com/c/go/+/227079
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/obj/mips/asm0.go

index 5bbcb01444caa15b158af1ad39c61e4736087dac..13d875ed3abaa164384dbea0723e389eb6fe4350 100644 (file)
@@ -1355,10 +1355,12 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
                        r = int(o.param)
                }
                o1 = OP_RRR(c.oprrr(p.As), uint32(0), uint32(p.To.Reg), uint32(r))
-               rel := obj.Addrel(c.cursym)
-               rel.Off = int32(c.pc)
-               rel.Siz = 0
-               rel.Type = objabi.R_CALLIND
+               if p.As == obj.ACALL {
+                       rel := obj.Addrel(c.cursym)
+                       rel.Off = int32(c.pc)
+                       rel.Siz = 0
+                       rel.Type = objabi.R_CALLIND
+               }
 
        case 19: /* mov $lcon,r ==> lu+or */
                // NOTE: this case does not use REGTMP. If it ever does,