From: Josh Bleecher Snyder Date: Tue, 28 Apr 2020 17:20:55 +0000 (-0700) Subject: cmd/compile: simplify readonly sym checks in writebarrier pass X-Git-Tag: go1.15beta1~325 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=71e0cd815def852085a1592fbd64a149b437be55;p=gostls13.git cmd/compile: simplify readonly sym checks in writebarrier pass CL 220499 started marking readonly syms as SRODATA earlier, so we can use that in the writebarrier pass now. Passes toolstash-check. Change-Id: Ic4d49714b8bffbe03c8e9a75ca96df4475bae732 Reviewed-on: https://go-review.googlesource.com/c/go/+/230559 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/ssa/writebarrier.go b/src/cmd/compile/internal/ssa/writebarrier.go index cebfbb8c9d..c7fb059475 100644 --- a/src/cmd/compile/internal/ssa/writebarrier.go +++ b/src/cmd/compile/internal/ssa/writebarrier.go @@ -7,9 +7,9 @@ package ssa import ( "cmd/compile/internal/types" "cmd/internal/obj" + "cmd/internal/objabi" "cmd/internal/src" "fmt" - "strings" ) // A ZeroRegion records parts of an object which are known to be zero. @@ -565,8 +565,7 @@ func IsReadOnlyGlobalAddr(v *Value) bool { // Nil pointers are read only. See issue 33438. return true } - // See TODO in OpAddr case in IsSanitizerSafeAddr below. - if v.Op == OpAddr && strings.HasPrefix(v.Aux.(*obj.LSym).Name, `""..stmp_`) { + if v.Op == OpAddr && v.Aux.(*obj.LSym).Type == objabi.SRODATA { return true } return false @@ -614,15 +613,7 @@ func IsSanitizerSafeAddr(v *Value) bool { // read-only once initialized. return true case OpAddr: - sym := v.Aux.(*obj.LSym) - // TODO(mdempsky): Find a cleaner way to - // detect this. It would be nice if we could - // test sym.Type==objabi.SRODATA, but we don't - // initialize sym.Type until after function - // compilation. - if strings.HasPrefix(sym.Name, `""..stmp_`) { - return true - } + return v.Aux.(*obj.LSym).Type == objabi.SRODATA } return false }