]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: replace Node.HasCall with walk.mayCall
authorMatthew Dempsky <mdempsky@google.com>
Sun, 17 Jan 2021 00:59:19 +0000 (16:59 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Sun, 17 Jan 2021 05:07:59 +0000 (05:07 +0000)
commit78e5aabcdb8aeae58a6437a3051fde3555ee0bf2
treecf53ecab78c8b906a36969655d1bde33bcdb4d4e
parent6de9423445840351a4cc7b17d732f0b5e922ef1a
[dev.regabi] cmd/compile: replace Node.HasCall with walk.mayCall

After CL 284220, we now only need to detect expressions that contain
function calls in the arguments list of further function calls. So we
can simplify Node.HasCall/fncall/etc a lot.

Instead of incrementally tracking whether an expression contains
function calls all throughout walk, simply check once at the point of
using an expression as a function call argument. Since any expression
checked here will itself become a function call argument, it won't be
checked again because we'll short circuit at the enclosing function
call.

Also, restructure the recursive walk code to use mayCall, and trim
down the list of acceptable expressions. It should be okay to be
stricter, since we'll now only see function call arguments and after
they've already been walked.

It's possible I was overly aggressive removing Ops here. But if so,
we'll get an ICE, and it'll be easy to re-add them. I think this is
better than the alternative of accidentally allowing expressions
through that risk silently clobbering the stack.

Passes toolstash -cmp.

Change-Id: I585ef35dcccd9f4018e4bf2c3f9ccb1514a826f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/284223
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/mini.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/stmt.go
src/cmd/compile/internal/walk/assign.go
src/cmd/compile/internal/walk/expr.go
src/cmd/compile/internal/walk/walk.go