]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: avoid general traversal in deadcode
authorRuss Cox <rsc@golang.org>
Fri, 4 Dec 2020 04:56:16 +0000 (23:56 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 4 Dec 2020 16:52:56 +0000 (16:52 +0000)
commit9ab3d854ad95d06f5dd0874050ee57dd63c5a746
tree1a26924602d50e382ec510ec2d94dd9084980ec8
parentbb5aa2b664331087d3230732cb0d11c8e87b9e98
[dev.regabi] cmd/compile: avoid general traversal in deadcode

deadcode is trying to walk the statements it can find,
but it can sweep in other nodes too. Stop doing that:
only walk known statements containing statements.

Otherwise, if we put panics in expression accessors that
shouldn't be used anymore, deadcode can trip them.

deadcode would be a good candidate to rewrite using
EditChildren, but that would certainly cause toolstash
changes, since deadcode is so ad-hoc about exactly
which parts of the function it looks at. For now just
remove the general traversal and leave as is.

Passes buildall w/ toolstash -cmp.

Change-Id: I06481eb87350905597600203c4fa724d55645b46
Reviewed-on: https://go-review.googlesource.com/c/go/+/275377
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/typecheck.go