diff options
author | Cherry Zhang <cherryyz@google.com> | 2021-04-20 20:33:43 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2021-04-21 14:15:55 +0000 |
commit | daee726a0b7c932ed418e623ef29697c77d113a8 (patch) | |
tree | 82ff0fc7b4c809dc9e71c3aa2246276cd5717d4f /src/cmd/compile/internal/ssa | |
parent | 4d56576ec02e3e3b4459bc23eb1601e6e96f3cfc (diff) | |
download | go-daee726a0b7c932ed418e623ef29697c77d113a8.tar.gz go-daee726a0b7c932ed418e623ef29697c77d113a8.zip |
cmd/compile: don't accumulate duplicated named slots
Currently, in expand_calls, for each appearance of a named
variables's component, we add the named slot to f.Names list. If
a variable appears many times, we add it to f.Names many times.
Furthure, for each duplicated named slot, its entry in
f.NamedValues is a slice that contains all Values associated with
that name. This leads to quadratic behavior when iterating named
values like
for _, name := range f.Names {
for _, v := range f.NamedValues[name] {
...
}
}
This CL makes it not to add duplicated entries to f.Names.
Change-Id: I82a8d009db81ecf48b4577e0bca501feff677cdf
Reviewed-on: https://go-review.googlesource.com/c/go/+/312093
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa')
-rw-r--r-- | src/cmd/compile/internal/ssa/expand_calls.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 46c2388e7b..48e40bb00a 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -1378,9 +1378,11 @@ func expandCalls(f *Func) { // Leaf types may have debug locations if !x.isAlreadyExpandedAggregateType(v.Type) { for _, l := range locs { + if _, ok := f.NamedValues[l]; !ok { + f.Names = append(f.Names, l) + } f.NamedValues[l] = append(f.NamedValues[l], v) } - f.Names = append(f.Names, locs...) continue } // Not-leaf types that had debug locations need to lose them. |