]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: allow static init for unsafe.Pointer(&x) where x is global
authorRuss Cox <rsc@golang.org>
Mon, 29 Jun 2015 16:49:25 +0000 (12:49 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 7 Jul 2015 21:51:57 +0000 (21:51 +0000)
commit9f90f31c3a3ac8fc306bb63c0fd80299afcddbc2
treec2ff9f6933d085a388bc5b78ccbdabcd65db02dd
parentd6e6baa702269ea6d2e61d4fa726bff48560c82c
cmd/compile: allow static init for unsafe.Pointer(&x) where x is global

This avoids both a write barrier and then dynamic initialization
globals of the form

var x something
var xp = unsafe.Pointer(&x)

Using static initialization avoids emitting a relocation for &x,
which helps cgo.

Fixes #9411.

Change-Id: I0dbf480859cce6ab57ab805d1b8609c45b48f156
Reviewed-on: https://go-review.googlesource.com/11693
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/walk.go
test/sinit.go