Commit 4827c6d0 authored by Todd Neal's avatar Todd Neal

[dev.ssa] test: add test of pointer aliasing

This adds a test case with aliased pointers to ensure modifications to
dse don't remove valid stores.

Change-Id: I143653250f46a403835218ec685bcd336d5087ef
Reviewed-on: https://go-review.googlesource.com/19795Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 5949524f
......@@ -123,7 +123,26 @@ func testg() {
}
}
func alias_ssa(ui64 *uint64, ui32 *uint32) uint32 {
*ui32 = 0xffffffff
*ui64 = 0 // store
ret := *ui32 // load from same address, should be zero
*ui64 = 0xffffffffffffffff // store
return ret
}
func testdse() {
x := int64(-1)
// construct two pointers that alias one another
ui64 := (*uint64)(unsafe.Pointer(&x))
ui32 := (*uint32)(unsafe.Pointer(&x))
if want, got := uint32(0), alias_ssa(ui64, ui32); got != want {
fmt.Printf("alias_ssa: wanted %d, got %d\n", want, got)
panic("alias_ssa")
}
}
func main() {
testf()
testg()
testdse()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment