diff --git a/oracle/testdata/src/main/describe-json.go b/oracle/testdata/src/main/describe-json.go index 56c29321a9..906bfaf8f0 100644 --- a/oracle/testdata/src/main/describe-json.go +++ b/oracle/testdata/src/main/describe-json.go @@ -15,7 +15,7 @@ func main() { // if i == nil { i = new(D) } - _ = i // @describe desc-val-i "i" + print(i) // @describe desc-val-i "\\bi\\b" go main() // @describe desc-stmt "go" } diff --git a/oracle/testdata/src/main/describe-json.golden b/oracle/testdata/src/main/describe-json.golden index 48b85f0b68..db917ee90a 100644 --- a/oracle/testdata/src/main/describe-json.golden +++ b/oracle/testdata/src/main/describe-json.golden @@ -98,7 +98,7 @@ "mode": "describe", "describe": { "desc": "identifier", - "pos": "testdata/src/main/describe-json.go:18:6", + "pos": "testdata/src/main/describe-json.go:18:8", "detail": "value", "value": { "type": "I", diff --git a/oracle/testdata/src/main/describe.go b/oracle/testdata/src/main/describe.go index ed4eea6b1f..20a04b16d5 100644 --- a/oracle/testdata/src/main/describe.go +++ b/oracle/testdata/src/main/describe.go @@ -45,7 +45,7 @@ func main() { // @describe func-def-main "main" if i != nil { i = D{} // @describe var-ref-i-D "i" } - _ = i // @describe var-ref-i "i" + print(i) // @describe var-ref-i "\\bi\\b" // const objects const localpi = 3.141 // @describe const-local-pi "localpi" diff --git a/ssa/lift.go b/ssa/lift.go index 3a68c129bd..3cf1e04196 100644 --- a/ssa/lift.go +++ b/ssa/lift.go @@ -209,8 +209,8 @@ func lift(fn *Function) { nps := newPhis[b] j := 0 for _, np := range nps { - if len(*np.phi.Referrers()) == 0 { - continue // unreferenced phi + if !phiIsLive(np.phi) { + continue // discard it } nps[j] = np j++ @@ -266,6 +266,19 @@ func lift(fn *Function) { fn.Locals = fn.Locals[:j] } +func phiIsLive(phi *Phi) bool { + for _, instr := range *phi.Referrers() { + if instr == phi { + continue // self-refs don't count + } + if _, ok := instr.(*DebugRef); ok { + continue // debug refs don't count + } + return true + } + return false +} + type blockSet struct{ big.Int } // (inherit methods from Int) // add adds b to the set and returns true if the set changed.