From: Keith Randall Date: Mon, 19 Oct 2015 23:13:58 +0000 (-0700) Subject: [dev.ssa] cmd/compile: Don't rematerialize getg X-Git-Tag: go1.7beta1~1623^2^2~137 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2dc88eead8d28c6d84f60e30746d90a76f920be6;p=gostls13.git [dev.ssa] cmd/compile: Don't rematerialize getg It isn't safe in functions that also call setg. Change-Id: I76a7bf0401b4b6c8a129c245b15a2d6f06080e94 Reviewed-on: https://go-review.googlesource.com/16095 Reviewed-by: Todd Neal --- diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 6418bb375d..72b056cd8d 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -982,7 +982,11 @@ func (v *Value) rematerializeable() bool { // which can't be moved. return false } - // TODO: maybe not OpAMD64LoweredGetG? + if v.Op == OpAMD64LoweredGetG { + // It would almost always be ok to rematerialize this op. + // The annoying exception is functions that call runtime.setg. + return false + } if len(v.Args) == 0 { return true }