aboutsummaryrefslogtreecommitdiff
path: root/test/sinit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-06-29 12:49:25 -0400
committerRuss Cox <rsc@golang.org>2015-07-07 21:51:57 +0000
commit9f90f31c3a3ac8fc306bb63c0fd80299afcddbc2 (patch)
treec2ff9f6933d085a388bc5b78ccbdabcd65db02dd /test/sinit.go
parentd6e6baa702269ea6d2e61d4fa726bff48560c82c (diff)
downloadgo-9f90f31c3a3ac8fc306bb63c0fd80299afcddbc2.tar.gz
go-9f90f31c3a3ac8fc306bb63c0fd80299afcddbc2.zip
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>
Diffstat (limited to 'test/sinit.go')
-rw-r--r--test/sinit.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/sinit.go b/test/sinit.go
index df1a4cc930..188a5301a2 100644
--- a/test/sinit.go
+++ b/test/sinit.go
@@ -10,6 +10,8 @@
package p
+import "unsafe"
+
// Should be no init func in the assembly.
// All these initializations should be done at link time.
@@ -284,3 +286,6 @@ type Mer interface {
}
var _ Mer = (*T1)(nil)
+
+var Byte byte
+var PtrByte unsafe.Pointer = unsafe.Pointer(&Byte)