summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-04-02 22:47:29 -0400
committerCherry Zhang <cherryyz@google.com>2020-04-03 14:12:25 +0000
commite18a5ba0ca142c64aa03c6fb500d69cbbaab1bb6 (patch)
tree1b3fc169d772a1a06ff8bc7f0f2b8f73f140b8fb
parent5dde10c3044f75fbcc29193608a7b7156a3c9ef6 (diff)
downloadgo-git-e18a5ba0ca142c64aa03c6fb500d69cbbaab1bb6.tar.gz
cmd/link: in stack bound check, don't check a call repetitively
In stack bound check pass, check a call once, not over and over again. Fix an accidental quadratic behavior... In particular, switching to the new linker caused MIPS builders noticeably slower. This CL fixes it. Change-Id: Idd00c79e80af6278652c92a1d9d7bb2d194e9490 Reviewed-on: https://go-review.googlesource.com/c/go/+/227078 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Austin Clements <austin@google.com>
-rw-r--r--src/cmd/link/internal/ld/lib.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 3f21fc54ef..f7b8e04ddf 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -2360,6 +2360,7 @@ func (sc *stkChk) check(up *chain, depth int) int {
relocs := ldr.Relocs(s)
var ch1 chain
pcsp := obj.NewPCIter(uint32(ctxt.Arch.MinLC))
+ ri := 0
for pcsp.Init(info.Pcsp()); !pcsp.Done; pcsp.Next() {
// pcsp.value is in effect for [pcsp.pc, pcsp.nextpc).
@@ -2370,8 +2371,8 @@ func (sc *stkChk) check(up *chain, depth int) int {
}
// Process calls in this span.
- for i := 0; i < relocs.Count(); i++ {
- r := relocs.At2(i)
+ for ; ri < relocs.Count(); ri++ {
+ r := relocs.At2(ri)
if uint32(r.Off()) >= pcsp.NextPC {
break
}