]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/ir: add batch-mode reassignment detection oracle
authorThan McIntosh <thanm@google.com>
Thu, 2 Nov 2023 15:25:07 +0000 (11:25 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 21 Nov 2023 16:20:36 +0000 (16:20 +0000)
commit8be8bfeaa2e9fb9372d8507f076c6307e8237c54
tree6f46be16d4db205858630688bc5615029c47381f
parent515f3c0da643a3c2dfcf494ac0a7cf8f65002f38
cmd/compile/internal/ir: add batch-mode reassignment detection oracle

Add a new helper type 'ReassignOracle', useful for doing "batch mode"
reassignment analysis, e.g. deciding whether a given ir.Name or (chain
of connected names) has a single definition and is never reassigned.

The intended usage model is for clients to create/initialize a
ReassignOracle for a given function, then make a series of queries
using it (with the understanding that changing/mutating the func body
IR can invalidate the info cached in the oracle). This oracle is
intended to provide the same sort of analysis that ir.StaticValue and
ir.Reassigned carry out, but at a much reduced cost in compile
time.

Notes:
- the new helper isn't actually used for anything useful in this
  patch; it will be hooked into the inline heuristics code as part of
  a subsequent CL.
- this is probably not an ideal long-term solution; it would be better
  to switch to a scheme based a flag on ir.Name, as opposed to a
  side table.

Change-Id: I283e748e440a9f595df495f6aa48ee9c498702d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/539319
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/ir/check_reassign_no.go [new file with mode: 0644]
src/cmd/compile/internal/ir/check_reassign_yes.go [new file with mode: 0644]
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/reassign_consistency_check.go [new file with mode: 0644]
src/cmd/compile/internal/ir/reassignment.go [new file with mode: 0644]