cmd/compile: switch to ReassignOracle.StaticValue in escape call analysis

Split out of CL 771163; this solves the TODO and saves a double-walk,
without requiring extra fixes needed to use it more broadly.

compilebench results (this CL vs parent):

                         │  parent.txt  │             commit.txt             │
                         │    sec/op    │    sec/op     vs base              │
Template                   153.9m ±  9%   157.1m ±  5%       ~ (p=0.818 n=6)
Unicode                    116.7m ±  7%   115.8m ± 10%       ~ (p=0.699 n=6)
GoTypes                    879.9m ±  3%   876.5m ±  2%       ~ (p=0.937 n=6)
Compiler                   165.3m ±  8%   160.5m ±  8%       ~ (p=0.699 n=6)
SSA                         6.998 ±  0%    7.097 ±  1%  +1.42% (p=0.002 n=6)
Flate                      166.1m ± 10%   163.3m ±  6%       ~ (p=0.310 n=6)
GoParser                   170.3m ±  6%   169.3m ±  5%       ~ (p=0.937 n=6)
Reflect                    388.3m ±  5%   390.2m ±  2%       ~ (p=0.937 n=6)
Tar                        173.7m ±  3%   173.6m ±  5%       ~ (p=0.818 n=6)
XML                        197.6m ±  9%   194.6m ±  8%       ~ (p=0.485 n=6)
LinkCompiler               651.5m ±  7%   637.9m ±  3%       ~ (p=0.394 n=6)
ExternalLinkCompiler        2.194 ±  1%    2.193 ±  2%       ~ (p=0.937 n=6)
LinkWithoutDebugCompiler   419.0m ±  6%   412.4m ±  3%       ~ (p=0.589 n=6)
StdCmd                      29.02 ±  2%    29.36 ±  4%       ~ (p=0.937 n=6)
geomean                    524.6m         522.2m        -0.47%

                         │  parent.txt  │             commit.txt             │
                         │ user-sec/op  │ user-sec/op   vs base              │
Template                   727.8m ± 12%   736.0m ±  8%       ~ (p=0.589 n=6)
Unicode                    156.5m ±  8%   162.3m ±  8%       ~ (p=0.310 n=6)
GoTypes                     4.889 ±  2%    4.898 ±  2%       ~ (p=0.937 n=6)
Compiler                   505.5m ±  6%   491.1m ±  4%       ~ (p=0.394 n=6)
SSA                         36.98 ±  1%    37.35 ±  3%       ~ (p=0.093 n=6)
Flate                      797.3m ±  8%   761.3m ± 13%       ~ (p=0.180 n=6)
GoParser                   677.9m ±  5%   695.3m ±  7%       ~ (p=0.394 n=6)
Reflect                     1.871 ±  8%    1.875 ±  2%       ~ (p=1.000 n=6)
Tar                        763.1m ± 10%   825.0m ± 15%       ~ (p=0.485 n=6)
XML                        915.9m ± 15%   877.2m ± 14%       ~ (p=0.065 n=6)
LinkCompiler                1.035 ±  5%    1.059 ±  5%       ~ (p=0.394 n=6)
ExternalLinkCompiler        2.488 ±  3%    2.509 ±  3%       ~ (p=0.485 n=6)
LinkWithoutDebugCompiler   477.8m ±  2%   478.1m ±  6%       ~ (p=0.937 n=6)
geomean                     1.185          1.192        +0.60%

          │  parent.txt  │              commit.txt              │
          │  text-bytes  │  text-bytes   vs base                │
HelloSize   1.110Mi ± 0%   1.110Mi ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   14.14Mi ± 0%   14.14Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     3.961Mi        3.961Mi       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  data-bytes  │  data-bytes   vs base                │
HelloSize   27.54Ki ± 0%   27.54Ki ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   431.4Ki ± 0%   431.4Ki ± 0%       ~ (p=1.000 n=6) ¹
geomean     109.0Ki        109.0Ki       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  bss-bytes   │  bss-bytes    vs base                │
HelloSize   213.9Ki ± 0%   213.9Ki ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   32.27Mi ± 0%   32.27Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     2.597Mi        2.597Mi       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  exe-bytes   │  exe-bytes    vs base                │
HelloSize   1.782Mi ± 0%   1.782Mi ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   21.29Mi ± 0%   21.29Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     6.158Mi        6.158Mi       +0.00%
¹ all samples are equal

Change-Id: If4d51835045e27e5f67bac901f9edd1dc4da9b97
Reviewed-on: https://go-review.googlesource.com/c/go/+/778300
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Jake Bailey 2026-05-15 10:20:17 -07:00 committed by Keith Randall
parent 84e0c4965a
commit 1bcfdf2df2

View file

@ -42,12 +42,11 @@ func (e *escape) call(ks []hole, call ir.Node) {
var fns []*ir.Name
switch call.Op() {
case ir.OCALLFUNC:
// TODO(thepudds): use an ir.ReassignOracle here.
v := ir.StaticValue(call.Fun)
ro := e.reassignOracle(e.curfn)
v := ro.StaticValue(call.Fun)
if fn := ir.StaticCalleeName(v); fn != nil {
fns = []*ir.Name{fn}
} else if name, ok := v.(*ir.Name); ok {
ro := e.reassignOracle(e.curfn)
fns = resolveAssignedCallees(ro.FuncAssignments(name.Canonical()))
}
}