aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/deadstore.go
diff options
context:
space:
mode:
authorMichael Munday <mike.munday@ibm.com>2018-07-17 08:39:30 +0100
committerMichael Munday <mike.munday@ibm.com>2018-07-17 14:58:54 +0000
commit1546ab5a3925b07c86f05ccfa4c8b4c2b818790e (patch)
treecf72fa9d67043c73136a39a3815045397a5aedc4 /src/cmd/compile/internal/ssa/deadstore.go
parent5890e25b7ccb2d2249b2f8a02ef5dbc36047868b (diff)
downloadgo-1546ab5a3925b07c86f05ccfa4c8b4c2b818790e.tar.gz
go-1546ab5a3925b07c86f05ccfa4c8b4c2b818790e.zip
cmd/compile: keep autos if their address reaches a control value
Autos must be kept if their address reaches the control value of a block. We didn't see this before because it is rare for an auto's address to reach a control value without also reaching a phi or being written to memory. We can probably optimize away the comparisons that lead to this scenario since autos cannot alias with pointers from elsewhere, however for now we take the conservative approach and just ensure the auto is properly initialised if its address reaches a control value. Fixes #26407. Change-Id: I02265793f010a9e001c3e1a5397c290c6769d4de Reviewed-on: https://go-review.googlesource.com/124335 Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/deadstore.go')
-rw-r--r--src/cmd/compile/internal/ssa/deadstore.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/deadstore.go b/src/cmd/compile/internal/ssa/deadstore.go
index 6359588129..ca6bce972e 100644
--- a/src/cmd/compile/internal/ssa/deadstore.go
+++ b/src/cmd/compile/internal/ssa/deadstore.go
@@ -262,6 +262,14 @@ func elimDeadAutosGeneric(f *Func) {
for _, v := range b.Values {
changed = visit(v) || changed
}
+ // keep the auto if its address reaches a control value
+ if b.Control == nil {
+ continue
+ }
+ if n, ok := addr[b.Control]; ok && !used[n] {
+ used[n] = true
+ changed = true
+ }
}
if !changed {
break