mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
[dev.ssa] cmd/compile/internal/ssa: reuse Aux values for PEXTERN
This improves cse and works correctly now that divide by zero is checked explicitly. Change-Id: If54fbe403ed5230b897afc5def644ba9f0056dfd Reviewed-on: https://go-review.googlesource.com/16454 Run-TryBot: Todd Neal <todd@tneal.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a347ab7cd1
commit
74180dd7da
|
@ -2265,7 +2265,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value {
|
|||
switch n.Class {
|
||||
case PEXTERN:
|
||||
// global variable
|
||||
aux := &ssa.ExternSymbol{n.Type, n.Sym}
|
||||
aux := s.lookupSymbol(n, &ssa.ExternSymbol{n.Type, n.Sym})
|
||||
v := s.entryNewValue1A(ssa.OpAddr, t, aux, s.sb)
|
||||
// TODO: Make OpAddr use AuxInt as well as Aux.
|
||||
if n.Xoffset != 0 {
|
||||
|
|
|
@ -77,11 +77,39 @@ func testExtStore() {
|
|||
}
|
||||
}
|
||||
|
||||
var b int
|
||||
|
||||
// testDeadStorePanic_ssa ensures that we don't optimize away stores
|
||||
// that could be read by after recover(). Modeled after fixedbugs/issue1304.
|
||||
func testDeadStorePanic_ssa(a int) (r int) {
|
||||
switch {
|
||||
}
|
||||
defer func() {
|
||||
recover()
|
||||
r = a
|
||||
}()
|
||||
a = 2 // store
|
||||
b := a - a // optimized to zero
|
||||
c := 4
|
||||
a = c / b // store, but panics
|
||||
a = 3 // store
|
||||
r = a
|
||||
return
|
||||
}
|
||||
|
||||
func testDeadStorePanic() {
|
||||
if want, got := 2, testDeadStorePanic_ssa(1); want != got {
|
||||
fmt.Println("testDeadStorePanic failed. want =", want, ", got =", got)
|
||||
failed = true
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
testLoadStoreOrder()
|
||||
testStoreSize()
|
||||
testExtStore()
|
||||
testDeadStorePanic()
|
||||
|
||||
if failed {
|
||||
panic("failed")
|
||||
|
|
Loading…
Reference in a new issue