Source file test/fixedbugs/issue39459.go

     1  // compile
     2  
     3  // Copyright 2020 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package p
     8  
     9  type T struct { // big enough to be an unSSAable type
    10  	a, b, c, d, e, f int
    11  }
    12  
    13  func f(x interface{}, p *int) {
    14  	_ = *p // trigger nil check here, removing it from below
    15  	switch x := x.(type) {
    16  	case *T:
    17  		// Zero twice, so one of them will be removed by the deadstore pass
    18  		*x = T{}
    19  		*p = 0 // store op to prevent Zero ops from being optimized by the earlier opt pass rewrite rules
    20  		*x = T{}
    21  	}
    22  }
    23  

View as plain text