]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: setup to move Addrconst, Patch into cmd/internal/obj
authorRuss Cox <rsc@golang.org>
Mon, 21 Dec 2020 06:14:36 +0000 (01:14 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 21 Dec 2020 19:23:27 +0000 (19:23 +0000)
Deleting the Pc assignment from Patch is safe because the actual PCs
are not assigned until well after the compiler is done patching jumps.
And it proves that replacing uses of Patch with SetTarget will be safe later.

Change-Id: Iffcbe03f0b5949ccd4c91e79c1272cd06be0f434
Reviewed-on: https://go-review.googlesource.com/c/go/+/279296
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/gsubr.go
src/cmd/internal/obj/link.go

index 79ca669dfbba90d580a45472e70510af017cdccf..ddb431d5abf68acd66f58ed539d1b6d5f64ca938 100644 (file)
@@ -321,15 +321,9 @@ func ggloblsym(s *obj.LSym, width int32, flags int16) {
 }
 
 func Addrconst(a *obj.Addr, v int64) {
-       a.Sym = nil
-       a.Type = obj.TYPE_CONST
-       a.Offset = v
+       a.SetConst(v)
 }
 
 func Patch(p *obj.Prog, to *obj.Prog) {
-       if p.To.Type != obj.TYPE_BRANCH {
-               base.Fatalf("patch: not a branch")
-       }
        p.To.SetTarget(to)
-       p.To.Offset = to.Pc
 }
index eaebfaf4b63140c914b01bf8079f8f213c3d3beb..7b5c990a5de7de462928e515de2aa0c9297c49ff 100644 (file)
@@ -250,6 +250,12 @@ func (a *Addr) SetTarget(t *Prog) {
        a.Val = t
 }
 
+func (a *Addr) SetConst(v int64) {
+       a.Sym = nil
+       a.Type = TYPE_CONST
+       a.Offset = v
+}
+
 // Prog describes a single machine instruction.
 //
 // The general instruction form is: